babylon.d.txt 2.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. export const Epsilon = 0.001;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Vector3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * 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".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * 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"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1821. /**
  1822. * Unproject from screen space to object space
  1823. * @param source defines the screen space Vector3 to use
  1824. * @param viewportWidth defines the current width of the viewport
  1825. * @param viewportHeight defines the current height of the viewport
  1826. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1827. * @param transform defines the transform (view x projection) matrix to use
  1828. * @returns the new Vector3
  1829. */
  1830. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1831. /**
  1832. * Unproject from screen space to object space
  1833. * @param source defines the screen space Vector3 to use
  1834. * @param viewportWidth defines the current width of the viewport
  1835. * @param viewportHeight defines the current height of the viewport
  1836. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1837. * @param view defines the view matrix to use
  1838. * @param projection defines the projection matrix to use
  1839. * @returns the new Vector3
  1840. */
  1841. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1842. /**
  1843. * Unproject from screen space to object space
  1844. * @param source defines the screen space Vector3 to use
  1845. * @param viewportWidth defines the current width of the viewport
  1846. * @param viewportHeight defines the current height of the viewport
  1847. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1848. * @param view defines the view matrix to use
  1849. * @param projection defines the projection matrix to use
  1850. * @param result defines the Vector3 where to store the result
  1851. */
  1852. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1853. /**
  1854. * Unproject from screen space to object space
  1855. * @param sourceX defines the screen space x coordinate to use
  1856. * @param sourceY defines the screen space y coordinate to use
  1857. * @param sourceZ defines the screen space z coordinate to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @param result defines the Vector3 where to store the result
  1864. */
  1865. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1866. /**
  1867. * Gets the minimal coordinate values between two Vector3
  1868. * @param left defines the first operand
  1869. * @param right defines the second operand
  1870. * @returns the new Vector3
  1871. */
  1872. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1873. /**
  1874. * Gets the maximal coordinate values between two Vector3
  1875. * @param left defines the first operand
  1876. * @param right defines the second operand
  1877. * @returns the new Vector3
  1878. */
  1879. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1880. /**
  1881. * Returns the distance between the vectors "value1" and "value2"
  1882. * @param value1 defines the first operand
  1883. * @param value2 defines the second operand
  1884. * @returns the distance
  1885. */
  1886. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1887. /**
  1888. * Returns the squared distance between the vectors "value1" and "value2"
  1889. * @param value1 defines the first operand
  1890. * @param value2 defines the second operand
  1891. * @returns the squared distance
  1892. */
  1893. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1894. /**
  1895. * Returns a new Vector3 located at the center between "value1" and "value2"
  1896. * @param value1 defines the first operand
  1897. * @param value2 defines the second operand
  1898. * @returns the new Vector3
  1899. */
  1900. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1901. /**
  1902. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1903. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1904. * to something in order to rotate it from its local system to the given target system
  1905. * Note: axis1, axis2 and axis3 are normalized during this operation
  1906. * @param axis1 defines the first axis
  1907. * @param axis2 defines the second axis
  1908. * @param axis3 defines the third axis
  1909. * @returns a new Vector3
  1910. */
  1911. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1912. /**
  1913. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1914. * @param axis1 defines the first axis
  1915. * @param axis2 defines the second axis
  1916. * @param axis3 defines the third axis
  1917. * @param ref defines the Vector3 where to store the result
  1918. */
  1919. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1920. }
  1921. /**
  1922. * Vector4 class created for EulerAngle class conversion to Quaternion
  1923. */
  1924. export class Vector4 {
  1925. /** x value of the vector */
  1926. x: number;
  1927. /** y value of the vector */
  1928. y: number;
  1929. /** z value of the vector */
  1930. z: number;
  1931. /** w value of the vector */
  1932. w: number;
  1933. /**
  1934. * Creates a Vector4 object from the given floats.
  1935. * @param x x value of the vector
  1936. * @param y y value of the vector
  1937. * @param z z value of the vector
  1938. * @param w w value of the vector
  1939. */
  1940. constructor(
  1941. /** x value of the vector */
  1942. x: number,
  1943. /** y value of the vector */
  1944. y: number,
  1945. /** z value of the vector */
  1946. z: number,
  1947. /** w value of the vector */
  1948. w: number);
  1949. /**
  1950. * Returns the string with the Vector4 coordinates.
  1951. * @returns a string containing all the vector values
  1952. */
  1953. toString(): string;
  1954. /**
  1955. * Returns the string "Vector4".
  1956. * @returns "Vector4"
  1957. */
  1958. getClassName(): string;
  1959. /**
  1960. * Returns the Vector4 hash code.
  1961. * @returns a unique hash code
  1962. */
  1963. getHashCode(): number;
  1964. /**
  1965. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1966. * @returns the resulting array
  1967. */
  1968. asArray(): number[];
  1969. /**
  1970. * Populates the given array from the given index with the Vector4 coordinates.
  1971. * @param array array to populate
  1972. * @param index index of the array to start at (default: 0)
  1973. * @returns the Vector4.
  1974. */
  1975. toArray(array: FloatArray, index?: number): Vector4;
  1976. /**
  1977. * Adds the given vector to the current Vector4.
  1978. * @param otherVector the vector to add
  1979. * @returns the updated Vector4.
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1982. /**
  1983. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1984. * @param otherVector the vector to add
  1985. * @returns the resulting vector
  1986. */
  1987. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1988. /**
  1989. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1990. * @param otherVector the vector to add
  1991. * @param result the vector to store the result
  1992. * @returns the current Vector4.
  1993. */
  1994. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1995. /**
  1996. * Subtract in place the given vector from the current Vector4.
  1997. * @param otherVector the vector to subtract
  1998. * @returns the updated Vector4.
  1999. */
  2000. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2001. /**
  2002. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2003. * @param otherVector the vector to add
  2004. * @returns the new vector with the result
  2005. */
  2006. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2007. /**
  2008. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2009. * @param otherVector the vector to subtract
  2010. * @param result the vector to store the result
  2011. * @returns the current Vector4.
  2012. */
  2013. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2014. /**
  2015. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2016. */
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. * @param x value to subtract
  2020. * @param y value to subtract
  2021. * @param z value to subtract
  2022. * @param w value to subtract
  2023. * @returns new vector containing the result
  2024. */
  2025. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2026. /**
  2027. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2028. * @param x value to subtract
  2029. * @param y value to subtract
  2030. * @param z value to subtract
  2031. * @param w value to subtract
  2032. * @param result the vector to store the result in
  2033. * @returns the current Vector4.
  2034. */
  2035. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2036. /**
  2037. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2038. * @returns a new vector with the negated values
  2039. */
  2040. negate(): Vector4;
  2041. /**
  2042. * Multiplies the current Vector4 coordinates by scale (float).
  2043. * @param scale the number to scale with
  2044. * @returns the updated Vector4.
  2045. */
  2046. scaleInPlace(scale: number): Vector4;
  2047. /**
  2048. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2049. * @param scale the number to scale with
  2050. * @returns a new vector with the result
  2051. */
  2052. scale(scale: number): Vector4;
  2053. /**
  2054. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2055. * @param scale the number to scale with
  2056. * @param result a vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. scaleToRef(scale: number, result: Vector4): Vector4;
  2060. /**
  2061. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2062. * @param scale defines the scale factor
  2063. * @param result defines the Vector4 object where to store the result
  2064. * @returns the unmodified current Vector4
  2065. */
  2066. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2067. /**
  2068. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2069. * @param otherVector the vector to compare against
  2070. * @returns true if they are equal
  2071. */
  2072. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2073. /**
  2074. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2075. * @param otherVector vector to compare against
  2076. * @param epsilon (Default: very small number)
  2077. * @returns true if they are equal
  2078. */
  2079. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2080. /**
  2081. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2082. * @param x x value to compare against
  2083. * @param y y value to compare against
  2084. * @param z z value to compare against
  2085. * @param w w value to compare against
  2086. * @returns true if equal
  2087. */
  2088. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2089. /**
  2090. * Multiplies in place the current Vector4 by the given one.
  2091. * @param otherVector vector to multiple with
  2092. * @returns the updated Vector4.
  2093. */
  2094. multiplyInPlace(otherVector: Vector4): Vector4;
  2095. /**
  2096. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2097. * @param otherVector vector to multiple with
  2098. * @returns resulting new vector
  2099. */
  2100. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2101. /**
  2102. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2103. * @param otherVector vector to multiple with
  2104. * @param result vector to store the result
  2105. * @returns the current Vector4.
  2106. */
  2107. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2108. /**
  2109. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2110. * @param x x value multiply with
  2111. * @param y y value multiply with
  2112. * @param z z value multiply with
  2113. * @param w w value multiply with
  2114. * @returns resulting new vector
  2115. */
  2116. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2117. /**
  2118. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2119. * @param otherVector vector to devide with
  2120. * @returns resulting new vector
  2121. */
  2122. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2123. /**
  2124. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2125. * @param otherVector vector to devide with
  2126. * @param result vector to store the result
  2127. * @returns the current Vector4.
  2128. */
  2129. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2130. /**
  2131. * Divides the current Vector3 coordinates by the given ones.
  2132. * @param otherVector vector to devide with
  2133. * @returns the updated Vector3.
  2134. */
  2135. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2136. /**
  2137. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2138. * @param other defines the second operand
  2139. * @returns the current updated Vector4
  2140. */
  2141. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2142. /**
  2143. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2144. * @param other defines the second operand
  2145. * @returns the current updated Vector4
  2146. */
  2147. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2148. /**
  2149. * Gets a new Vector4 from current Vector4 floored values
  2150. * @returns a new Vector4
  2151. */
  2152. floor(): Vector4;
  2153. /**
  2154. * Gets a new Vector4 from current Vector3 floored values
  2155. * @returns a new Vector4
  2156. */
  2157. fract(): Vector4;
  2158. /**
  2159. * Returns the Vector4 length (float).
  2160. * @returns the length
  2161. */
  2162. length(): number;
  2163. /**
  2164. * Returns the Vector4 squared length (float).
  2165. * @returns the length squared
  2166. */
  2167. lengthSquared(): number;
  2168. /**
  2169. * Normalizes in place the Vector4.
  2170. * @returns the updated Vector4.
  2171. */
  2172. normalize(): Vector4;
  2173. /**
  2174. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2175. * @returns this converted to a new vector3
  2176. */
  2177. toVector3(): Vector3;
  2178. /**
  2179. * Returns a new Vector4 copied from the current one.
  2180. * @returns the new cloned vector
  2181. */
  2182. clone(): Vector4;
  2183. /**
  2184. * Updates the current Vector4 with the given one coordinates.
  2185. * @param source the source vector to copy from
  2186. * @returns the updated Vector4.
  2187. */
  2188. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2189. /**
  2190. * Updates the current Vector4 coordinates with the given floats.
  2191. * @param x float to copy from
  2192. * @param y float to copy from
  2193. * @param z float to copy from
  2194. * @param w float to copy from
  2195. * @returns the updated Vector4.
  2196. */
  2197. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2198. /**
  2199. * Updates the current Vector4 coordinates with the given floats.
  2200. * @param x float to set from
  2201. * @param y float to set from
  2202. * @param z float to set from
  2203. * @param w float to set from
  2204. * @returns the updated Vector4.
  2205. */
  2206. set(x: number, y: number, z: number, w: number): Vector4;
  2207. /**
  2208. * Copies the given float to the current Vector3 coordinates
  2209. * @param v defines the x, y, z and w coordinates of the operand
  2210. * @returns the current updated Vector3
  2211. */
  2212. setAll(v: number): Vector4;
  2213. /**
  2214. * Returns a new Vector4 set from the starting index of the given array.
  2215. * @param array the array to pull values from
  2216. * @param offset the offset into the array to start at
  2217. * @returns the new vector
  2218. */
  2219. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2220. /**
  2221. * Updates the given vector "result" from the starting index of the given array.
  2222. * @param array the array to pull values from
  2223. * @param offset the offset into the array to start at
  2224. * @param result the vector to store the result in
  2225. */
  2226. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2227. /**
  2228. * Updates the given vector "result" from the starting index of the given Float32Array.
  2229. * @param array the array to pull values from
  2230. * @param offset the offset into the array to start at
  2231. * @param result the vector to store the result in
  2232. */
  2233. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2234. /**
  2235. * Updates the given vector "result" coordinates from the given floats.
  2236. * @param x float to set from
  2237. * @param y float to set from
  2238. * @param z float to set from
  2239. * @param w float to set from
  2240. * @param result the vector to the floats in
  2241. */
  2242. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2243. /**
  2244. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2245. * @returns the new vector
  2246. */
  2247. static Zero(): Vector4;
  2248. /**
  2249. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2250. * @returns the new vector
  2251. */
  2252. static One(): Vector4;
  2253. /**
  2254. * Returns a new normalized Vector4 from the given one.
  2255. * @param vector the vector to normalize
  2256. * @returns the vector
  2257. */
  2258. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2259. /**
  2260. * Updates the given vector "result" from the normalization of the given one.
  2261. * @param vector the vector to normalize
  2262. * @param result the vector to store the result in
  2263. */
  2264. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2265. /**
  2266. * Returns a vector with the minimum values from the left and right vectors
  2267. * @param left left vector to minimize
  2268. * @param right right vector to minimize
  2269. * @returns a new vector with the minimum of the left and right vector values
  2270. */
  2271. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2272. /**
  2273. * Returns a vector with the maximum values from the left and right vectors
  2274. * @param left left vector to maximize
  2275. * @param right right vector to maximize
  2276. * @returns a new vector with the maximum of the left and right vector values
  2277. */
  2278. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2279. /**
  2280. * Returns the distance (float) between the vectors "value1" and "value2".
  2281. * @param value1 value to calulate the distance between
  2282. * @param value2 value to calulate the distance between
  2283. * @return the distance between the two vectors
  2284. */
  2285. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2286. /**
  2287. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2288. * @param value1 value to calulate the distance between
  2289. * @param value2 value to calulate the distance between
  2290. * @return the distance between the two vectors squared
  2291. */
  2292. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2293. /**
  2294. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2295. * @param value1 value to calulate the center between
  2296. * @param value2 value to calulate the center between
  2297. * @return the center between the two vectors
  2298. */
  2299. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2300. /**
  2301. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2302. * This methods computes transformed normalized direction vectors only.
  2303. * @param vector the vector to transform
  2304. * @param transformation the transformation matrix to apply
  2305. * @returns the new vector
  2306. */
  2307. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2308. /**
  2309. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2310. * This methods computes transformed normalized direction vectors only.
  2311. * @param vector the vector to transform
  2312. * @param transformation the transformation matrix to apply
  2313. * @param result the vector to store the result in
  2314. */
  2315. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2316. /**
  2317. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2318. * This methods computes transformed normalized direction vectors only.
  2319. * @param x value to transform
  2320. * @param y value to transform
  2321. * @param z value to transform
  2322. * @param w value to transform
  2323. * @param transformation the transformation matrix to apply
  2324. * @param result the vector to store the results in
  2325. */
  2326. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2327. /**
  2328. * Creates a new Vector4 from a Vector3
  2329. * @param source defines the source data
  2330. * @param w defines the 4th component (default is 0)
  2331. * @returns a new Vector4
  2332. */
  2333. static FromVector3(source: Vector3, w?: number): Vector4;
  2334. }
  2335. /**
  2336. * Interface for the size containing width and height
  2337. */
  2338. export interface ISize {
  2339. /**
  2340. * Width
  2341. */
  2342. width: number;
  2343. /**
  2344. * Heighht
  2345. */
  2346. height: number;
  2347. }
  2348. /**
  2349. * Size containing widht and height
  2350. */
  2351. export class Size implements ISize {
  2352. /**
  2353. * Width
  2354. */
  2355. width: number;
  2356. /**
  2357. * Height
  2358. */
  2359. height: number;
  2360. /**
  2361. * Creates a Size object from the given width and height (floats).
  2362. * @param width width of the new size
  2363. * @param height height of the new size
  2364. */
  2365. constructor(width: number, height: number);
  2366. /**
  2367. * Returns a string with the Size width and height
  2368. * @returns a string with the Size width and height
  2369. */
  2370. toString(): string;
  2371. /**
  2372. * "Size"
  2373. * @returns the string "Size"
  2374. */
  2375. getClassName(): string;
  2376. /**
  2377. * Returns the Size hash code.
  2378. * @returns a hash code for a unique width and height
  2379. */
  2380. getHashCode(): number;
  2381. /**
  2382. * Updates the current size from the given one.
  2383. * @param src the given size
  2384. */
  2385. copyFrom(src: Size): void;
  2386. /**
  2387. * Updates in place the current Size from the given floats.
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. * @returns the updated Size.
  2391. */
  2392. copyFromFloats(width: number, height: number): Size;
  2393. /**
  2394. * Updates in place the current Size from the given floats.
  2395. * @param width width to set
  2396. * @param height height to set
  2397. * @returns the updated Size.
  2398. */
  2399. set(width: number, height: number): Size;
  2400. /**
  2401. * Multiplies the width and height by numbers
  2402. * @param w factor to multiple the width by
  2403. * @param h factor to multiple the height by
  2404. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2405. */
  2406. multiplyByFloats(w: number, h: number): Size;
  2407. /**
  2408. * Clones the size
  2409. * @returns a new Size copied from the given one.
  2410. */
  2411. clone(): Size;
  2412. /**
  2413. * True if the current Size and the given one width and height are strictly equal.
  2414. * @param other the other size to compare against
  2415. * @returns True if the current Size and the given one width and height are strictly equal.
  2416. */
  2417. equals(other: Size): boolean;
  2418. /**
  2419. * The surface of the Size : width * height (float).
  2420. */
  2421. readonly surface: number;
  2422. /**
  2423. * Create a new size of zero
  2424. * @returns a new Size set to (0.0, 0.0)
  2425. */
  2426. static Zero(): Size;
  2427. /**
  2428. * Sums the width and height of two sizes
  2429. * @param otherSize size to add to this size
  2430. * @returns a new Size set as the addition result of the current Size and the given one.
  2431. */
  2432. add(otherSize: Size): Size;
  2433. /**
  2434. * Subtracts the width and height of two
  2435. * @param otherSize size to subtract to this size
  2436. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2437. */
  2438. subtract(otherSize: Size): Size;
  2439. /**
  2440. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2441. * @param start starting size to lerp between
  2442. * @param end end size to lerp between
  2443. * @param amount amount to lerp between the start and end values
  2444. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2445. */
  2446. static Lerp(start: Size, end: Size, amount: number): Size;
  2447. }
  2448. /**
  2449. * Class used to store quaternion data
  2450. * @see https://en.wikipedia.org/wiki/Quaternion
  2451. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2452. */
  2453. export class Quaternion {
  2454. /** defines the first component (0 by default) */
  2455. x: number;
  2456. /** defines the second component (0 by default) */
  2457. y: number;
  2458. /** defines the third component (0 by default) */
  2459. z: number;
  2460. /** defines the fourth component (1.0 by default) */
  2461. w: number;
  2462. /**
  2463. * Creates a new Quaternion from the given floats
  2464. * @param x defines the first component (0 by default)
  2465. * @param y defines the second component (0 by default)
  2466. * @param z defines the third component (0 by default)
  2467. * @param w defines the fourth component (1.0 by default)
  2468. */
  2469. constructor(
  2470. /** defines the first component (0 by default) */
  2471. x?: number,
  2472. /** defines the second component (0 by default) */
  2473. y?: number,
  2474. /** defines the third component (0 by default) */
  2475. z?: number,
  2476. /** defines the fourth component (1.0 by default) */
  2477. w?: number);
  2478. /**
  2479. * Gets a string representation for the current quaternion
  2480. * @returns a string with the Quaternion coordinates
  2481. */
  2482. toString(): string;
  2483. /**
  2484. * Gets the class name of the quaternion
  2485. * @returns the string "Quaternion"
  2486. */
  2487. getClassName(): string;
  2488. /**
  2489. * Gets a hash code for this quaternion
  2490. * @returns the quaternion hash code
  2491. */
  2492. getHashCode(): number;
  2493. /**
  2494. * Copy the quaternion to an array
  2495. * @returns a new array populated with 4 elements from the quaternion coordinates
  2496. */
  2497. asArray(): number[];
  2498. /**
  2499. * Check if two quaternions are equals
  2500. * @param otherQuaternion defines the second operand
  2501. * @return true if the current quaternion and the given one coordinates are strictly equals
  2502. */
  2503. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2504. /**
  2505. * Clone the current quaternion
  2506. * @returns a new quaternion copied from the current one
  2507. */
  2508. clone(): Quaternion;
  2509. /**
  2510. * Copy a quaternion to the current one
  2511. * @param other defines the other quaternion
  2512. * @returns the updated current quaternion
  2513. */
  2514. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2515. /**
  2516. * Updates the current quaternion with the given float coordinates
  2517. * @param x defines the x coordinate
  2518. * @param y defines the y coordinate
  2519. * @param z defines the z coordinate
  2520. * @param w defines the w coordinate
  2521. * @returns the updated current quaternion
  2522. */
  2523. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2524. /**
  2525. * Updates the current quaternion from the given float coordinates
  2526. * @param x defines the x coordinate
  2527. * @param y defines the y coordinate
  2528. * @param z defines the z coordinate
  2529. * @param w defines the w coordinate
  2530. * @returns the updated current quaternion
  2531. */
  2532. set(x: number, y: number, z: number, w: number): Quaternion;
  2533. /**
  2534. * Adds two quaternions
  2535. * @param other defines the second operand
  2536. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2537. */
  2538. add(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Add a quaternion to the current one
  2541. * @param other defines the quaternion to add
  2542. * @returns the current quaternion
  2543. */
  2544. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2545. /**
  2546. * Subtract two quaternions
  2547. * @param other defines the second operand
  2548. * @returns a new quaternion as the subtraction result of the given one from the current one
  2549. */
  2550. subtract(other: Quaternion): Quaternion;
  2551. /**
  2552. * Multiplies the current quaternion by a scale factor
  2553. * @param value defines the scale factor
  2554. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2555. */
  2556. scale(value: number): Quaternion;
  2557. /**
  2558. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2559. * @param scale defines the scale factor
  2560. * @param result defines the Quaternion object where to store the result
  2561. * @returns the unmodified current quaternion
  2562. */
  2563. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2564. /**
  2565. * Multiplies in place the current quaternion by a scale factor
  2566. * @param value defines the scale factor
  2567. * @returns the current modified quaternion
  2568. */
  2569. scaleInPlace(value: number): Quaternion;
  2570. /**
  2571. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2572. * @param scale defines the scale factor
  2573. * @param result defines the Quaternion object where to store the result
  2574. * @returns the unmodified current quaternion
  2575. */
  2576. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies two quaternions
  2579. * @param q1 defines the second operand
  2580. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2581. */
  2582. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2583. /**
  2584. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2585. * @param q1 defines the second operand
  2586. * @param result defines the target quaternion
  2587. * @returns the current quaternion
  2588. */
  2589. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2590. /**
  2591. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2592. * @param q1 defines the second operand
  2593. * @returns the currentupdated quaternion
  2594. */
  2595. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2596. /**
  2597. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2598. * @param ref defines the target quaternion
  2599. * @returns the current quaternion
  2600. */
  2601. conjugateToRef(ref: Quaternion): Quaternion;
  2602. /**
  2603. * Conjugates in place (1-q) the current quaternion
  2604. * @returns the current updated quaternion
  2605. */
  2606. conjugateInPlace(): Quaternion;
  2607. /**
  2608. * Conjugates in place (1-q) the current quaternion
  2609. * @returns a new quaternion
  2610. */
  2611. conjugate(): Quaternion;
  2612. /**
  2613. * Gets length of current quaternion
  2614. * @returns the quaternion length (float)
  2615. */
  2616. length(): number;
  2617. /**
  2618. * Normalize in place the current quaternion
  2619. * @returns the current updated quaternion
  2620. */
  2621. normalize(): Quaternion;
  2622. /**
  2623. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2624. * @param order is a reserved parameter and is ignore for now
  2625. * @returns a new Vector3 containing the Euler angles
  2626. */
  2627. toEulerAngles(order?: string): Vector3;
  2628. /**
  2629. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2630. * @param result defines the vector which will be filled with the Euler angles
  2631. * @param order is a reserved parameter and is ignore for now
  2632. * @returns the current unchanged quaternion
  2633. */
  2634. toEulerAnglesToRef(result: Vector3): Quaternion;
  2635. /**
  2636. * Updates the given rotation matrix with the current quaternion values
  2637. * @param result defines the target matrix
  2638. * @returns the current unchanged quaternion
  2639. */
  2640. toRotationMatrix(result: Matrix): Quaternion;
  2641. /**
  2642. * Updates the current quaternion from the given rotation matrix values
  2643. * @param matrix defines the source matrix
  2644. * @returns the current updated quaternion
  2645. */
  2646. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2647. /**
  2648. * Creates a new quaternion from a rotation matrix
  2649. * @param matrix defines the source matrix
  2650. * @returns a new quaternion created from the given rotation matrix values
  2651. */
  2652. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2653. /**
  2654. * Updates the given quaternion with the given rotation matrix values
  2655. * @param matrix defines the source matrix
  2656. * @param result defines the target quaternion
  2657. */
  2658. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2659. /**
  2660. * Returns the dot product (float) between the quaternions "left" and "right"
  2661. * @param left defines the left operand
  2662. * @param right defines the right operand
  2663. * @returns the dot product
  2664. */
  2665. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2666. /**
  2667. * Checks if the two quaternions are close to each other
  2668. * @param quat0 defines the first quaternion to check
  2669. * @param quat1 defines the second quaternion to check
  2670. * @returns true if the two quaternions are close to each other
  2671. */
  2672. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2673. /**
  2674. * Creates an empty quaternion
  2675. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2676. */
  2677. static Zero(): Quaternion;
  2678. /**
  2679. * Inverse a given quaternion
  2680. * @param q defines the source quaternion
  2681. * @returns a new quaternion as the inverted current quaternion
  2682. */
  2683. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2684. /**
  2685. * Inverse a given quaternion
  2686. * @param q defines the source quaternion
  2687. * @param result the quaternion the result will be stored in
  2688. * @returns the result quaternion
  2689. */
  2690. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2691. /**
  2692. * Creates an identity quaternion
  2693. * @returns the identity quaternion
  2694. */
  2695. static Identity(): Quaternion;
  2696. /**
  2697. * Gets a boolean indicating if the given quaternion is identity
  2698. * @param quaternion defines the quaternion to check
  2699. * @returns true if the quaternion is identity
  2700. */
  2701. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2702. /**
  2703. * Creates a quaternion from a rotation around an axis
  2704. * @param axis defines the axis to use
  2705. * @param angle defines the angle to use
  2706. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2707. */
  2708. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2709. /**
  2710. * Creates a rotation around an axis and stores it into the given quaternion
  2711. * @param axis defines the axis to use
  2712. * @param angle defines the angle to use
  2713. * @param result defines the target quaternion
  2714. * @returns the target quaternion
  2715. */
  2716. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates a new quaternion from data stored into an array
  2719. * @param array defines the data source
  2720. * @param offset defines the offset in the source array where the data starts
  2721. * @returns a new quaternion
  2722. */
  2723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2724. /**
  2725. * Create a quaternion from Euler rotation angles
  2726. * @param x Pitch
  2727. * @param y Yaw
  2728. * @param z Roll
  2729. * @returns the new Quaternion
  2730. */
  2731. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2732. /**
  2733. * Updates a quaternion from Euler rotation angles
  2734. * @param x Pitch
  2735. * @param y Yaw
  2736. * @param z Roll
  2737. * @param result the quaternion to store the result
  2738. * @returns the updated quaternion
  2739. */
  2740. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Create a quaternion from Euler rotation vector
  2743. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2744. * @returns the new Quaternion
  2745. */
  2746. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2747. /**
  2748. * Updates a quaternion from Euler rotation vector
  2749. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2750. * @param result the quaternion to store the result
  2751. * @returns the updated quaternion
  2752. */
  2753. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2754. /**
  2755. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2756. * @param yaw defines the rotation around Y axis
  2757. * @param pitch defines the rotation around X axis
  2758. * @param roll defines the rotation around Z axis
  2759. * @returns the new quaternion
  2760. */
  2761. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2762. /**
  2763. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2764. * @param yaw defines the rotation around Y axis
  2765. * @param pitch defines the rotation around X axis
  2766. * @param roll defines the rotation around Z axis
  2767. * @param result defines the target quaternion
  2768. */
  2769. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2770. /**
  2771. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2772. * @param alpha defines the rotation around first axis
  2773. * @param beta defines the rotation around second axis
  2774. * @param gamma defines the rotation around third axis
  2775. * @returns the new quaternion
  2776. */
  2777. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2780. * @param alpha defines the rotation around first axis
  2781. * @param beta defines the rotation around second axis
  2782. * @param gamma defines the rotation around third axis
  2783. * @param result defines the target quaternion
  2784. */
  2785. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2786. /**
  2787. * 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)
  2788. * @param axis1 defines the first axis
  2789. * @param axis2 defines the second axis
  2790. * @param axis3 defines the third axis
  2791. * @returns the new quaternion
  2792. */
  2793. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2794. /**
  2795. * 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
  2796. * @param axis1 defines the first axis
  2797. * @param axis2 defines the second axis
  2798. * @param axis3 defines the third axis
  2799. * @param ref defines the target quaternion
  2800. */
  2801. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2802. /**
  2803. * Interpolates between two quaternions
  2804. * @param left defines first quaternion
  2805. * @param right defines second quaternion
  2806. * @param amount defines the gradient to use
  2807. * @returns the new interpolated quaternion
  2808. */
  2809. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2810. /**
  2811. * Interpolates between two quaternions and stores it into a target quaternion
  2812. * @param left defines first quaternion
  2813. * @param right defines second quaternion
  2814. * @param amount defines the gradient to use
  2815. * @param result defines the target quaternion
  2816. */
  2817. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2818. /**
  2819. * Interpolate between two quaternions using Hermite interpolation
  2820. * @param value1 defines first quaternion
  2821. * @param tangent1 defines the incoming tangent
  2822. * @param value2 defines second quaternion
  2823. * @param tangent2 defines the outgoing tangent
  2824. * @param amount defines the target quaternion
  2825. * @returns the new interpolated quaternion
  2826. */
  2827. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2828. }
  2829. /**
  2830. * Class used to store matrix data (4x4)
  2831. */
  2832. export class Matrix {
  2833. private static _updateFlagSeed;
  2834. private static _identityReadOnly;
  2835. private _isIdentity;
  2836. private _isIdentityDirty;
  2837. private _isIdentity3x2;
  2838. private _isIdentity3x2Dirty;
  2839. /**
  2840. * Gets the update flag of the matrix which is an unique number for the matrix.
  2841. * It will be incremented every time the matrix data change.
  2842. * You can use it to speed the comparison between two versions of the same matrix.
  2843. */
  2844. updateFlag: number;
  2845. private readonly _m;
  2846. /**
  2847. * Gets the internal data of the matrix
  2848. */
  2849. readonly m: DeepImmutable<Float32Array>;
  2850. /** @hidden */ markAsUpdated(): void;
  2851. /** @hidden */
  2852. private _updateIdentityStatus;
  2853. /**
  2854. * Creates an empty matrix (filled with zeros)
  2855. */
  2856. constructor();
  2857. /**
  2858. * Check if the current matrix is identity
  2859. * @returns true is the matrix is the identity matrix
  2860. */
  2861. isIdentity(): boolean;
  2862. /**
  2863. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2864. * @returns true is the matrix is the identity matrix
  2865. */
  2866. isIdentityAs3x2(): boolean;
  2867. /**
  2868. * Gets the determinant of the matrix
  2869. * @returns the matrix determinant
  2870. */
  2871. determinant(): number;
  2872. /**
  2873. * Returns the matrix as a Float32Array
  2874. * @returns the matrix underlying array
  2875. */
  2876. toArray(): DeepImmutable<Float32Array>;
  2877. /**
  2878. * Returns the matrix as a Float32Array
  2879. * @returns the matrix underlying array.
  2880. */
  2881. asArray(): DeepImmutable<Float32Array>;
  2882. /**
  2883. * Inverts the current matrix in place
  2884. * @returns the current inverted matrix
  2885. */
  2886. invert(): Matrix;
  2887. /**
  2888. * Sets all the matrix elements to zero
  2889. * @returns the current matrix
  2890. */
  2891. reset(): Matrix;
  2892. /**
  2893. * Adds the current matrix with a second one
  2894. * @param other defines the matrix to add
  2895. * @returns a new matrix as the addition of the current matrix and the given one
  2896. */
  2897. add(other: DeepImmutable<Matrix>): Matrix;
  2898. /**
  2899. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2900. * @param other defines the matrix to add
  2901. * @param result defines the target matrix
  2902. * @returns the current matrix
  2903. */
  2904. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2905. /**
  2906. * Adds in place the given matrix to the current matrix
  2907. * @param other defines the second operand
  2908. * @returns the current updated matrix
  2909. */
  2910. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2911. /**
  2912. * Sets the given matrix to the current inverted Matrix
  2913. * @param other defines the target matrix
  2914. * @returns the unmodified current matrix
  2915. */
  2916. invertToRef(other: Matrix): Matrix;
  2917. /**
  2918. * add a value at the specified position in the current Matrix
  2919. * @param index the index of the value within the matrix. between 0 and 15.
  2920. * @param value the value to be added
  2921. * @returns the current updated matrix
  2922. */
  2923. addAtIndex(index: number, value: number): Matrix;
  2924. /**
  2925. * mutiply the specified position in the current Matrix by a value
  2926. * @param index the index of the value within the matrix. between 0 and 15.
  2927. * @param value the value to be added
  2928. * @returns the current updated matrix
  2929. */
  2930. multiplyAtIndex(index: number, value: number): Matrix;
  2931. /**
  2932. * Inserts the translation vector (using 3 floats) in the current matrix
  2933. * @param x defines the 1st component of the translation
  2934. * @param y defines the 2nd component of the translation
  2935. * @param z defines the 3rd component of the translation
  2936. * @returns the current updated matrix
  2937. */
  2938. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2939. /**
  2940. * Inserts the translation vector in the current matrix
  2941. * @param vector3 defines the translation to insert
  2942. * @returns the current updated matrix
  2943. */
  2944. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2945. /**
  2946. * Gets the translation value of the current matrix
  2947. * @returns a new Vector3 as the extracted translation from the matrix
  2948. */
  2949. getTranslation(): Vector3;
  2950. /**
  2951. * Fill a Vector3 with the extracted translation from the matrix
  2952. * @param result defines the Vector3 where to store the translation
  2953. * @returns the current matrix
  2954. */
  2955. getTranslationToRef(result: Vector3): Matrix;
  2956. /**
  2957. * Remove rotation and scaling part from the matrix
  2958. * @returns the updated matrix
  2959. */
  2960. removeRotationAndScaling(): Matrix;
  2961. /**
  2962. * Multiply two matrices
  2963. * @param other defines the second operand
  2964. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2965. */
  2966. multiply(other: DeepImmutable<Matrix>): Matrix;
  2967. /**
  2968. * Copy the current matrix from the given one
  2969. * @param other defines the source matrix
  2970. * @returns the current updated matrix
  2971. */
  2972. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2973. /**
  2974. * Populates the given array from the starting index with the current matrix values
  2975. * @param array defines the target array
  2976. * @param offset defines the offset in the target array where to start storing values
  2977. * @returns the current matrix
  2978. */
  2979. copyToArray(array: Float32Array, offset?: number): Matrix;
  2980. /**
  2981. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2982. * @param other defines the second operand
  2983. * @param result defines the matrix where to store the multiplication
  2984. * @returns the current matrix
  2985. */
  2986. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2987. /**
  2988. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2989. * @param other defines the second operand
  2990. * @param result defines the array where to store the multiplication
  2991. * @param offset defines the offset in the target array where to start storing values
  2992. * @returns the current matrix
  2993. */
  2994. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2995. /**
  2996. * Check equality between this matrix and a second one
  2997. * @param value defines the second matrix to compare
  2998. * @returns true is the current matrix and the given one values are strictly equal
  2999. */
  3000. equals(value: DeepImmutable<Matrix>): boolean;
  3001. /**
  3002. * Clone the current matrix
  3003. * @returns a new matrix from the current matrix
  3004. */
  3005. clone(): Matrix;
  3006. /**
  3007. * Returns the name of the current matrix class
  3008. * @returns the string "Matrix"
  3009. */
  3010. getClassName(): string;
  3011. /**
  3012. * Gets the hash code of the current matrix
  3013. * @returns the hash code
  3014. */
  3015. getHashCode(): number;
  3016. /**
  3017. * Decomposes the current Matrix into a translation, rotation and scaling components
  3018. * @param scale defines the scale vector3 given as a reference to update
  3019. * @param rotation defines the rotation quaternion given as a reference to update
  3020. * @param translation defines the translation vector3 given as a reference to update
  3021. * @returns true if operation was successful
  3022. */
  3023. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3024. /**
  3025. * Gets specific row of the matrix
  3026. * @param index defines the number of the row to get
  3027. * @returns the index-th row of the current matrix as a new Vector4
  3028. */
  3029. getRow(index: number): Nullable<Vector4>;
  3030. /**
  3031. * Sets the index-th row of the current matrix to the vector4 values
  3032. * @param index defines the number of the row to set
  3033. * @param row defines the target vector4
  3034. * @returns the updated current matrix
  3035. */
  3036. setRow(index: number, row: Vector4): Matrix;
  3037. /**
  3038. * Compute the transpose of the matrix
  3039. * @returns the new transposed matrix
  3040. */
  3041. transpose(): Matrix;
  3042. /**
  3043. * Compute the transpose of the matrix and store it in a given matrix
  3044. * @param result defines the target matrix
  3045. * @returns the current matrix
  3046. */
  3047. transposeToRef(result: Matrix): Matrix;
  3048. /**
  3049. * Sets the index-th row of the current matrix with the given 4 x float values
  3050. * @param index defines the row index
  3051. * @param x defines the x component to set
  3052. * @param y defines the y component to set
  3053. * @param z defines the z component to set
  3054. * @param w defines the w component to set
  3055. * @returns the updated current matrix
  3056. */
  3057. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3058. /**
  3059. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3060. * @param scale defines the scale factor
  3061. * @returns a new matrix
  3062. */
  3063. scale(scale: number): Matrix;
  3064. /**
  3065. * Scale the current matrix values by a factor to a given result matrix
  3066. * @param scale defines the scale factor
  3067. * @param result defines the matrix to store the result
  3068. * @returns the current matrix
  3069. */
  3070. scaleToRef(scale: number, result: Matrix): Matrix;
  3071. /**
  3072. * Scale the current matrix values by a factor and add the result to a given matrix
  3073. * @param scale defines the scale factor
  3074. * @param result defines the Matrix to store the result
  3075. * @returns the current matrix
  3076. */
  3077. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3078. /**
  3079. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3080. * @param ref matrix to store the result
  3081. */
  3082. toNormalMatrix(ref: Matrix): void;
  3083. /**
  3084. * Gets only rotation part of the current matrix
  3085. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3086. */
  3087. getRotationMatrix(): Matrix;
  3088. /**
  3089. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3090. * @param result defines the target matrix to store data to
  3091. * @returns the current matrix
  3092. */
  3093. getRotationMatrixToRef(result: Matrix): Matrix;
  3094. /**
  3095. * Toggles model matrix from being right handed to left handed in place and vice versa
  3096. */
  3097. toggleModelMatrixHandInPlace(): void;
  3098. /**
  3099. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3100. */
  3101. toggleProjectionMatrixHandInPlace(): void;
  3102. /**
  3103. * Creates a matrix from an array
  3104. * @param array defines the source array
  3105. * @param offset defines an offset in the source array
  3106. * @returns a new Matrix set from the starting index of the given array
  3107. */
  3108. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3109. /**
  3110. * Copy the content of an array into a given matrix
  3111. * @param array defines the source array
  3112. * @param offset defines an offset in the source array
  3113. * @param result defines the target matrix
  3114. */
  3115. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3116. /**
  3117. * Stores an array into a matrix after having multiplied each component by a given factor
  3118. * @param array defines the source array
  3119. * @param offset defines the offset in the source array
  3120. * @param scale defines the scaling factor
  3121. * @param result defines the target matrix
  3122. */
  3123. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3124. /**
  3125. * Gets an identity matrix that must not be updated
  3126. */
  3127. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3128. /**
  3129. * Stores a list of values (16) inside a given matrix
  3130. * @param initialM11 defines 1st value of 1st row
  3131. * @param initialM12 defines 2nd value of 1st row
  3132. * @param initialM13 defines 3rd value of 1st row
  3133. * @param initialM14 defines 4th value of 1st row
  3134. * @param initialM21 defines 1st value of 2nd row
  3135. * @param initialM22 defines 2nd value of 2nd row
  3136. * @param initialM23 defines 3rd value of 2nd row
  3137. * @param initialM24 defines 4th value of 2nd row
  3138. * @param initialM31 defines 1st value of 3rd row
  3139. * @param initialM32 defines 2nd value of 3rd row
  3140. * @param initialM33 defines 3rd value of 3rd row
  3141. * @param initialM34 defines 4th value of 3rd row
  3142. * @param initialM41 defines 1st value of 4th row
  3143. * @param initialM42 defines 2nd value of 4th row
  3144. * @param initialM43 defines 3rd value of 4th row
  3145. * @param initialM44 defines 4th value of 4th row
  3146. * @param result defines the target matrix
  3147. */
  3148. 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;
  3149. /**
  3150. * Creates new matrix from a list of values (16)
  3151. * @param initialM11 defines 1st value of 1st row
  3152. * @param initialM12 defines 2nd value of 1st row
  3153. * @param initialM13 defines 3rd value of 1st row
  3154. * @param initialM14 defines 4th value of 1st row
  3155. * @param initialM21 defines 1st value of 2nd row
  3156. * @param initialM22 defines 2nd value of 2nd row
  3157. * @param initialM23 defines 3rd value of 2nd row
  3158. * @param initialM24 defines 4th value of 2nd row
  3159. * @param initialM31 defines 1st value of 3rd row
  3160. * @param initialM32 defines 2nd value of 3rd row
  3161. * @param initialM33 defines 3rd value of 3rd row
  3162. * @param initialM34 defines 4th value of 3rd row
  3163. * @param initialM41 defines 1st value of 4th row
  3164. * @param initialM42 defines 2nd value of 4th row
  3165. * @param initialM43 defines 3rd value of 4th row
  3166. * @param initialM44 defines 4th value of 4th row
  3167. * @returns the new matrix
  3168. */
  3169. 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;
  3170. /**
  3171. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3172. * @param scale defines the scale vector3
  3173. * @param rotation defines the rotation quaternion
  3174. * @param translation defines the translation vector3
  3175. * @returns a new matrix
  3176. */
  3177. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3178. /**
  3179. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3180. * @param scale defines the scale vector3
  3181. * @param rotation defines the rotation quaternion
  3182. * @param translation defines the translation vector3
  3183. * @param result defines the target matrix
  3184. */
  3185. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3186. /**
  3187. * Creates a new identity matrix
  3188. * @returns a new identity matrix
  3189. */
  3190. static Identity(): Matrix;
  3191. /**
  3192. * Creates a new identity matrix and stores the result in a given matrix
  3193. * @param result defines the target matrix
  3194. */
  3195. static IdentityToRef(result: Matrix): void;
  3196. /**
  3197. * Creates a new zero matrix
  3198. * @returns a new zero matrix
  3199. */
  3200. static Zero(): Matrix;
  3201. /**
  3202. * Creates a new rotation matrix for "angle" radians around the X axis
  3203. * @param angle defines the angle (in radians) to use
  3204. * @return the new matrix
  3205. */
  3206. static RotationX(angle: number): Matrix;
  3207. /**
  3208. * Creates a new matrix as the invert of a given matrix
  3209. * @param source defines the source matrix
  3210. * @returns the new matrix
  3211. */
  3212. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3215. * @param angle defines the angle (in radians) to use
  3216. * @param result defines the target matrix
  3217. */
  3218. static RotationXToRef(angle: number, result: Matrix): void;
  3219. /**
  3220. * Creates a new rotation matrix for "angle" radians around the Y axis
  3221. * @param angle defines the angle (in radians) to use
  3222. * @return the new matrix
  3223. */
  3224. static RotationY(angle: number): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationYToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Z axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationZ(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationZToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the given axis
  3245. * @param axis defines the axis to use
  3246. * @param angle defines the angle (in radians) to use
  3247. * @return the new matrix
  3248. */
  3249. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3250. /**
  3251. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3252. * @param axis defines the axis to use
  3253. * @param angle defines the angle (in radians) to use
  3254. * @param result defines the target matrix
  3255. */
  3256. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3257. /**
  3258. * Creates a rotation matrix
  3259. * @param yaw defines the yaw angle in radians (Y axis)
  3260. * @param pitch defines the pitch angle in radians (X axis)
  3261. * @param roll defines the roll angle in radians (X axis)
  3262. * @returns the new rotation matrix
  3263. */
  3264. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3265. /**
  3266. * Creates a rotation matrix and stores it in a given matrix
  3267. * @param yaw defines the yaw angle in radians (Y axis)
  3268. * @param pitch defines the pitch angle in radians (X axis)
  3269. * @param roll defines the roll angle in radians (X axis)
  3270. * @param result defines the target matrix
  3271. */
  3272. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3273. /**
  3274. * Creates a scaling matrix
  3275. * @param x defines the scale factor on X axis
  3276. * @param y defines the scale factor on Y axis
  3277. * @param z defines the scale factor on Z axis
  3278. * @returns the new matrix
  3279. */
  3280. static Scaling(x: number, y: number, z: number): Matrix;
  3281. /**
  3282. * Creates a scaling matrix and stores it in a given matrix
  3283. * @param x defines the scale factor on X axis
  3284. * @param y defines the scale factor on Y axis
  3285. * @param z defines the scale factor on Z axis
  3286. * @param result defines the target matrix
  3287. */
  3288. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3289. /**
  3290. * Creates a translation matrix
  3291. * @param x defines the translation on X axis
  3292. * @param y defines the translation on Y axis
  3293. * @param z defines the translationon Z axis
  3294. * @returns the new matrix
  3295. */
  3296. static Translation(x: number, y: number, z: number): Matrix;
  3297. /**
  3298. * Creates a translation matrix and stores it in a given matrix
  3299. * @param x defines the translation on X axis
  3300. * @param y defines the translation on Y axis
  3301. * @param z defines the translationon Z axis
  3302. * @param result defines the target matrix
  3303. */
  3304. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3305. /**
  3306. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3307. * @param startValue defines the start value
  3308. * @param endValue defines the end value
  3309. * @param gradient defines the gradient factor
  3310. * @returns the new matrix
  3311. */
  3312. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3313. /**
  3314. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3315. * @param startValue defines the start value
  3316. * @param endValue defines the end value
  3317. * @param gradient defines the gradient factor
  3318. * @param result defines the Matrix object where to store data
  3319. */
  3320. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3321. /**
  3322. * Builds a new matrix whose values are computed by:
  3323. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3324. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3325. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3326. * @param startValue defines the first matrix
  3327. * @param endValue defines the second matrix
  3328. * @param gradient defines the gradient between the two matrices
  3329. * @returns the new matrix
  3330. */
  3331. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3332. /**
  3333. * Update a matrix to values which are computed by:
  3334. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3335. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3336. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3337. * @param startValue defines the first matrix
  3338. * @param endValue defines the second matrix
  3339. * @param gradient defines the gradient between the two matrices
  3340. * @param result defines the target matrix
  3341. */
  3342. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3343. /**
  3344. * 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"
  3345. * This function works in left handed mode
  3346. * @param eye defines the final position of the entity
  3347. * @param target defines where the entity should look at
  3348. * @param up defines the up vector for the entity
  3349. * @returns the new matrix
  3350. */
  3351. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3352. /**
  3353. * 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".
  3354. * This function works in left handed mode
  3355. * @param eye defines the final position of the entity
  3356. * @param target defines where the entity should look at
  3357. * @param up defines the up vector for the entity
  3358. * @param result defines the target matrix
  3359. */
  3360. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3361. /**
  3362. * 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"
  3363. * This function works in right handed mode
  3364. * @param eye defines the final position of the entity
  3365. * @param target defines where the entity should look at
  3366. * @param up defines the up vector for the entity
  3367. * @returns the new matrix
  3368. */
  3369. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3370. /**
  3371. * 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".
  3372. * This function works in right handed mode
  3373. * @param eye defines the final position of the entity
  3374. * @param target defines where the entity should look at
  3375. * @param up defines the up vector for the entity
  3376. * @param result defines the target matrix
  3377. */
  3378. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3379. /**
  3380. * Create a left-handed orthographic projection matrix
  3381. * @param width defines the viewport width
  3382. * @param height defines the viewport height
  3383. * @param znear defines the near clip plane
  3384. * @param zfar defines the far clip plane
  3385. * @returns a new matrix as a left-handed orthographic projection matrix
  3386. */
  3387. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3388. /**
  3389. * Store a left-handed orthographic projection to a given matrix
  3390. * @param width defines the viewport width
  3391. * @param height defines the viewport height
  3392. * @param znear defines the near clip plane
  3393. * @param zfar defines the far clip plane
  3394. * @param result defines the target matrix
  3395. */
  3396. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3397. /**
  3398. * Create a left-handed orthographic projection matrix
  3399. * @param left defines the viewport left coordinate
  3400. * @param right defines the viewport right coordinate
  3401. * @param bottom defines the viewport bottom coordinate
  3402. * @param top defines the viewport top coordinate
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Stores a left-handed orthographic projection into a given matrix
  3410. * @param left defines the viewport left coordinate
  3411. * @param right defines the viewport right coordinate
  3412. * @param bottom defines the viewport bottom coordinate
  3413. * @param top defines the viewport top coordinate
  3414. * @param znear defines the near clip plane
  3415. * @param zfar defines the far clip plane
  3416. * @param result defines the target matrix
  3417. */
  3418. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3419. /**
  3420. * Creates a right-handed orthographic projection matrix
  3421. * @param left defines the viewport left coordinate
  3422. * @param right defines the viewport right coordinate
  3423. * @param bottom defines the viewport bottom coordinate
  3424. * @param top defines the viewport top coordinate
  3425. * @param znear defines the near clip plane
  3426. * @param zfar defines the far clip plane
  3427. * @returns a new matrix as a right-handed orthographic projection matrix
  3428. */
  3429. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3430. /**
  3431. * Stores a right-handed orthographic projection into a given matrix
  3432. * @param left defines the viewport left coordinate
  3433. * @param right defines the viewport right coordinate
  3434. * @param bottom defines the viewport bottom coordinate
  3435. * @param top defines the viewport top coordinate
  3436. * @param znear defines the near clip plane
  3437. * @param zfar defines the far clip plane
  3438. * @param result defines the target matrix
  3439. */
  3440. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3441. /**
  3442. * Creates a left-handed perspective projection matrix
  3443. * @param width defines the viewport width
  3444. * @param height defines the viewport height
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a left-handed perspective projection matrix
  3448. */
  3449. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Creates a left-handed perspective projection matrix
  3452. * @param fov defines the horizontal field of view
  3453. * @param aspect defines the aspect ratio
  3454. * @param znear defines the near clip plane
  3455. * @param zfar defines the far clip plane
  3456. * @returns a new matrix as a left-handed perspective projection matrix
  3457. */
  3458. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3459. /**
  3460. * Stores a left-handed perspective projection into a given matrix
  3461. * @param fov defines the horizontal field of view
  3462. * @param aspect defines the aspect ratio
  3463. * @param znear defines the near clip plane
  3464. * @param zfar defines the far clip plane
  3465. * @param result defines the target matrix
  3466. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3467. */
  3468. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3469. /**
  3470. * Creates a right-handed perspective projection matrix
  3471. * @param fov defines the horizontal field of view
  3472. * @param aspect defines the aspect ratio
  3473. * @param znear defines the near clip plane
  3474. * @param zfar defines the far clip plane
  3475. * @returns a new matrix as a right-handed perspective projection matrix
  3476. */
  3477. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3478. /**
  3479. * Stores a right-handed perspective projection into a given matrix
  3480. * @param fov defines the horizontal field of view
  3481. * @param aspect defines the aspect ratio
  3482. * @param znear defines the near clip plane
  3483. * @param zfar defines the far clip plane
  3484. * @param result defines the target matrix
  3485. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3486. */
  3487. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3488. /**
  3489. * Stores a perspective projection for WebVR info a given matrix
  3490. * @param fov defines the field of view
  3491. * @param znear defines the near clip plane
  3492. * @param zfar defines the far clip plane
  3493. * @param result defines the target matrix
  3494. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3495. */
  3496. static PerspectiveFovWebVRToRef(fov: {
  3497. upDegrees: number;
  3498. downDegrees: number;
  3499. leftDegrees: number;
  3500. rightDegrees: number;
  3501. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3502. /**
  3503. * Computes a complete transformation matrix
  3504. * @param viewport defines the viewport to use
  3505. * @param world defines the world matrix
  3506. * @param view defines the view matrix
  3507. * @param projection defines the projection matrix
  3508. * @param zmin defines the near clip plane
  3509. * @param zmax defines the far clip plane
  3510. * @returns the transformation matrix
  3511. */
  3512. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3513. /**
  3514. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3515. * @param matrix defines the matrix to use
  3516. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3517. */
  3518. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3519. /**
  3520. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3521. * @param matrix defines the matrix to use
  3522. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3523. */
  3524. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3525. /**
  3526. * Compute the transpose of a given matrix
  3527. * @param matrix defines the matrix to transpose
  3528. * @returns the new matrix
  3529. */
  3530. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3531. /**
  3532. * Compute the transpose of a matrix and store it in a target matrix
  3533. * @param matrix defines the matrix to transpose
  3534. * @param result defines the target matrix
  3535. */
  3536. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3537. /**
  3538. * Computes a reflection matrix from a plane
  3539. * @param plane defines the reflection plane
  3540. * @returns a new matrix
  3541. */
  3542. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3543. /**
  3544. * Computes a reflection matrix from a plane
  3545. * @param plane defines the reflection plane
  3546. * @param result defines the target matrix
  3547. */
  3548. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3549. /**
  3550. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3551. * @param xaxis defines the value of the 1st axis
  3552. * @param yaxis defines the value of the 2nd axis
  3553. * @param zaxis defines the value of the 3rd axis
  3554. * @param result defines the target matrix
  3555. */
  3556. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3557. /**
  3558. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3559. * @param quat defines the quaternion to use
  3560. * @param result defines the target matrix
  3561. */
  3562. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3563. }
  3564. /**
  3565. * Represens a plane by the equation ax + by + cz + d = 0
  3566. */
  3567. export class Plane {
  3568. /**
  3569. * Normal of the plane (a,b,c)
  3570. */
  3571. normal: Vector3;
  3572. /**
  3573. * d component of the plane
  3574. */
  3575. d: number;
  3576. /**
  3577. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3578. * @param a a component of the plane
  3579. * @param b b component of the plane
  3580. * @param c c component of the plane
  3581. * @param d d component of the plane
  3582. */
  3583. constructor(a: number, b: number, c: number, d: number);
  3584. /**
  3585. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3586. */
  3587. asArray(): number[];
  3588. /**
  3589. * @returns a new plane copied from the current Plane.
  3590. */
  3591. clone(): Plane;
  3592. /**
  3593. * @returns the string "Plane".
  3594. */
  3595. getClassName(): string;
  3596. /**
  3597. * @returns the Plane hash code.
  3598. */
  3599. getHashCode(): number;
  3600. /**
  3601. * Normalize the current Plane in place.
  3602. * @returns the updated Plane.
  3603. */
  3604. normalize(): Plane;
  3605. /**
  3606. * Applies a transformation the plane and returns the result
  3607. * @param transformation the transformation matrix to be applied to the plane
  3608. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3609. */
  3610. transform(transformation: DeepImmutable<Matrix>): Plane;
  3611. /**
  3612. * Calcualtte the dot product between the point and the plane normal
  3613. * @param point point to calculate the dot product with
  3614. * @returns the dot product (float) of the point coordinates and the plane normal.
  3615. */
  3616. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3617. /**
  3618. * Updates the current Plane from the plane defined by the three given points.
  3619. * @param point1 one of the points used to contruct the plane
  3620. * @param point2 one of the points used to contruct the plane
  3621. * @param point3 one of the points used to contruct the plane
  3622. * @returns the updated Plane.
  3623. */
  3624. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3625. /**
  3626. * Checks if the plane is facing a given direction
  3627. * @param direction the direction to check if the plane is facing
  3628. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3629. * @returns True is the vector "direction" is the same side than the plane normal.
  3630. */
  3631. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3632. /**
  3633. * Calculates the distance to a point
  3634. * @param point point to calculate distance to
  3635. * @returns the signed distance (float) from the given point to the Plane.
  3636. */
  3637. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3638. /**
  3639. * Creates a plane from an array
  3640. * @param array the array to create a plane from
  3641. * @returns a new Plane from the given array.
  3642. */
  3643. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3644. /**
  3645. * Creates a plane from three points
  3646. * @param point1 point used to create the plane
  3647. * @param point2 point used to create the plane
  3648. * @param point3 point used to create the plane
  3649. * @returns a new Plane defined by the three given points.
  3650. */
  3651. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3652. /**
  3653. * Creates a plane from an origin point and a normal
  3654. * @param origin origin of the plane to be constructed
  3655. * @param normal normal of the plane to be constructed
  3656. * @returns a new Plane the normal vector to this plane at the given origin point.
  3657. * Note : the vector "normal" is updated because normalized.
  3658. */
  3659. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3660. /**
  3661. * Calculates the distance from a plane and a point
  3662. * @param origin origin of the plane to be constructed
  3663. * @param normal normal of the plane to be constructed
  3664. * @param point point to calculate distance to
  3665. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3666. */
  3667. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3668. }
  3669. /**
  3670. * Class used to represent a viewport on screen
  3671. */
  3672. export class Viewport {
  3673. /** viewport left coordinate */
  3674. x: number;
  3675. /** viewport top coordinate */
  3676. y: number;
  3677. /**viewport width */
  3678. width: number;
  3679. /** viewport height */
  3680. height: number;
  3681. /**
  3682. * Creates a Viewport object located at (x, y) and sized (width, height)
  3683. * @param x defines viewport left coordinate
  3684. * @param y defines viewport top coordinate
  3685. * @param width defines the viewport width
  3686. * @param height defines the viewport height
  3687. */
  3688. constructor(
  3689. /** viewport left coordinate */
  3690. x: number,
  3691. /** viewport top coordinate */
  3692. y: number,
  3693. /**viewport width */
  3694. width: number,
  3695. /** viewport height */
  3696. height: number);
  3697. /**
  3698. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3699. * @param renderWidth defines the rendering width
  3700. * @param renderHeight defines the rendering height
  3701. * @returns a new Viewport
  3702. */
  3703. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3704. /**
  3705. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3706. * @param renderWidth defines the rendering width
  3707. * @param renderHeight defines the rendering height
  3708. * @param ref defines the target viewport
  3709. * @returns the current viewport
  3710. */
  3711. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3712. /**
  3713. * Returns a new Viewport copied from the current one
  3714. * @returns a new Viewport
  3715. */
  3716. clone(): Viewport;
  3717. }
  3718. /**
  3719. * Reprasents a camera frustum
  3720. */
  3721. export class Frustum {
  3722. /**
  3723. * Gets the planes representing the frustum
  3724. * @param transform matrix to be applied to the returned planes
  3725. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3726. */
  3727. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3728. /**
  3729. * Gets the near frustum plane transformed by the transform matrix
  3730. * @param transform transformation matrix to be applied to the resulting frustum plane
  3731. * @param frustumPlane the resuling frustum plane
  3732. */
  3733. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3734. /**
  3735. * Gets the far frustum plane transformed by the transform matrix
  3736. * @param transform transformation matrix to be applied to the resulting frustum plane
  3737. * @param frustumPlane the resuling frustum plane
  3738. */
  3739. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3740. /**
  3741. * Gets the left frustum plane transformed by the transform matrix
  3742. * @param transform transformation matrix to be applied to the resulting frustum plane
  3743. * @param frustumPlane the resuling frustum plane
  3744. */
  3745. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3746. /**
  3747. * Gets the right frustum plane transformed by the transform matrix
  3748. * @param transform transformation matrix to be applied to the resulting frustum plane
  3749. * @param frustumPlane the resuling frustum plane
  3750. */
  3751. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3752. /**
  3753. * Gets the top frustum plane transformed by the transform matrix
  3754. * @param transform transformation matrix to be applied to the resulting frustum plane
  3755. * @param frustumPlane the resuling frustum plane
  3756. */
  3757. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3758. /**
  3759. * Gets the bottom frustum plane transformed by the transform matrix
  3760. * @param transform transformation matrix to be applied to the resulting frustum plane
  3761. * @param frustumPlane the resuling frustum plane
  3762. */
  3763. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3764. /**
  3765. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3766. * @param transform transformation matrix to be applied to the resulting frustum planes
  3767. * @param frustumPlanes the resuling frustum planes
  3768. */
  3769. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3770. }
  3771. /** Defines supported spaces */
  3772. export enum Space {
  3773. /** Local (object) space */
  3774. LOCAL = 0,
  3775. /** World space */
  3776. WORLD = 1,
  3777. /** Bone space */
  3778. BONE = 2
  3779. }
  3780. /** Defines the 3 main axes */
  3781. export class Axis {
  3782. /** X axis */
  3783. static X: Vector3;
  3784. /** Y axis */
  3785. static Y: Vector3;
  3786. /** Z axis */
  3787. static Z: Vector3;
  3788. }
  3789. /** Class used to represent a Bezier curve */
  3790. export class BezierCurve {
  3791. /**
  3792. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3793. * @param t defines the time
  3794. * @param x1 defines the left coordinate on X axis
  3795. * @param y1 defines the left coordinate on Y axis
  3796. * @param x2 defines the right coordinate on X axis
  3797. * @param y2 defines the right coordinate on Y axis
  3798. * @returns the interpolated value
  3799. */
  3800. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3801. }
  3802. /**
  3803. * Defines potential orientation for back face culling
  3804. */
  3805. export enum Orientation {
  3806. /**
  3807. * Clockwise
  3808. */
  3809. CW = 0,
  3810. /** Counter clockwise */
  3811. CCW = 1
  3812. }
  3813. /**
  3814. * Defines angle representation
  3815. */
  3816. export class Angle {
  3817. private _radians;
  3818. /**
  3819. * Creates an Angle object of "radians" radians (float).
  3820. * @param radians the angle in radians
  3821. */
  3822. constructor(radians: number);
  3823. /**
  3824. * Get value in degrees
  3825. * @returns the Angle value in degrees (float)
  3826. */
  3827. degrees(): number;
  3828. /**
  3829. * Get value in radians
  3830. * @returns the Angle value in radians (float)
  3831. */
  3832. radians(): number;
  3833. /**
  3834. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3835. * @param a defines first vector
  3836. * @param b defines second vector
  3837. * @returns a new Angle
  3838. */
  3839. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3840. /**
  3841. * Gets a new Angle object from the given float in radians
  3842. * @param radians defines the angle value in radians
  3843. * @returns a new Angle
  3844. */
  3845. static FromRadians(radians: number): Angle;
  3846. /**
  3847. * Gets a new Angle object from the given float in degrees
  3848. * @param degrees defines the angle value in degrees
  3849. * @returns a new Angle
  3850. */
  3851. static FromDegrees(degrees: number): Angle;
  3852. }
  3853. /**
  3854. * This represents an arc in a 2d space.
  3855. */
  3856. export class Arc2 {
  3857. /** Defines the start point of the arc */
  3858. startPoint: Vector2;
  3859. /** Defines the mid point of the arc */
  3860. midPoint: Vector2;
  3861. /** Defines the end point of the arc */
  3862. endPoint: Vector2;
  3863. /**
  3864. * Defines the center point of the arc.
  3865. */
  3866. centerPoint: Vector2;
  3867. /**
  3868. * Defines the radius of the arc.
  3869. */
  3870. radius: number;
  3871. /**
  3872. * Defines the angle of the arc (from mid point to end point).
  3873. */
  3874. angle: Angle;
  3875. /**
  3876. * Defines the start angle of the arc (from start point to middle point).
  3877. */
  3878. startAngle: Angle;
  3879. /**
  3880. * Defines the orientation of the arc (clock wise/counter clock wise).
  3881. */
  3882. orientation: Orientation;
  3883. /**
  3884. * Creates an Arc object from the three given points : start, middle and end.
  3885. * @param startPoint Defines the start point of the arc
  3886. * @param midPoint Defines the midlle point of the arc
  3887. * @param endPoint Defines the end point of the arc
  3888. */
  3889. constructor(
  3890. /** Defines the start point of the arc */
  3891. startPoint: Vector2,
  3892. /** Defines the mid point of the arc */
  3893. midPoint: Vector2,
  3894. /** Defines the end point of the arc */
  3895. endPoint: Vector2);
  3896. }
  3897. /**
  3898. * Represents a 2D path made up of multiple 2D points
  3899. */
  3900. export class Path2 {
  3901. private _points;
  3902. private _length;
  3903. /**
  3904. * If the path start and end point are the same
  3905. */
  3906. closed: boolean;
  3907. /**
  3908. * Creates a Path2 object from the starting 2D coordinates x and y.
  3909. * @param x the starting points x value
  3910. * @param y the starting points y value
  3911. */
  3912. constructor(x: number, y: number);
  3913. /**
  3914. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3915. * @param x the added points x value
  3916. * @param y the added points y value
  3917. * @returns the updated Path2.
  3918. */
  3919. addLineTo(x: number, y: number): Path2;
  3920. /**
  3921. * 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.
  3922. * @param midX middle point x value
  3923. * @param midY middle point y value
  3924. * @param endX end point x value
  3925. * @param endY end point y value
  3926. * @param numberOfSegments (default: 36)
  3927. * @returns the updated Path2.
  3928. */
  3929. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3930. /**
  3931. * Closes the Path2.
  3932. * @returns the Path2.
  3933. */
  3934. close(): Path2;
  3935. /**
  3936. * Gets the sum of the distance between each sequential point in the path
  3937. * @returns the Path2 total length (float).
  3938. */
  3939. length(): number;
  3940. /**
  3941. * Gets the points which construct the path
  3942. * @returns the Path2 internal array of points.
  3943. */
  3944. getPoints(): Vector2[];
  3945. /**
  3946. * Retreives the point at the distance aways from the starting point
  3947. * @param normalizedLengthPosition the length along the path to retreive the point from
  3948. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3949. */
  3950. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3951. /**
  3952. * Creates a new path starting from an x and y position
  3953. * @param x starting x value
  3954. * @param y starting y value
  3955. * @returns a new Path2 starting at the coordinates (x, y).
  3956. */
  3957. static StartingAt(x: number, y: number): Path2;
  3958. }
  3959. /**
  3960. * Represents a 3D path made up of multiple 3D points
  3961. */
  3962. export class Path3D {
  3963. /**
  3964. * an array of Vector3, the curve axis of the Path3D
  3965. */
  3966. path: Vector3[];
  3967. private _curve;
  3968. private _distances;
  3969. private _tangents;
  3970. private _normals;
  3971. private _binormals;
  3972. private _raw;
  3973. /**
  3974. * new Path3D(path, normal, raw)
  3975. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3976. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3977. * @param path an array of Vector3, the curve axis of the Path3D
  3978. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3979. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3980. */
  3981. constructor(
  3982. /**
  3983. * an array of Vector3, the curve axis of the Path3D
  3984. */
  3985. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3986. /**
  3987. * Returns the Path3D array of successive Vector3 designing its curve.
  3988. * @returns the Path3D array of successive Vector3 designing its curve.
  3989. */
  3990. getCurve(): Vector3[];
  3991. /**
  3992. * Returns an array populated with tangent vectors on each Path3D curve point.
  3993. * @returns an array populated with tangent vectors on each Path3D curve point.
  3994. */
  3995. getTangents(): Vector3[];
  3996. /**
  3997. * Returns an array populated with normal vectors on each Path3D curve point.
  3998. * @returns an array populated with normal vectors on each Path3D curve point.
  3999. */
  4000. getNormals(): Vector3[];
  4001. /**
  4002. * Returns an array populated with binormal vectors on each Path3D curve point.
  4003. * @returns an array populated with binormal vectors on each Path3D curve point.
  4004. */
  4005. getBinormals(): Vector3[];
  4006. /**
  4007. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4008. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4009. */
  4010. getDistances(): number[];
  4011. /**
  4012. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4013. * @param path path which all values are copied into the curves points
  4014. * @param firstNormal which should be projected onto the curve
  4015. * @returns the same object updated.
  4016. */
  4017. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4018. private _compute;
  4019. private _getFirstNonNullVector;
  4020. private _getLastNonNullVector;
  4021. private _normalVector;
  4022. }
  4023. /**
  4024. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4025. * A Curve3 is designed from a series of successive Vector3.
  4026. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4027. */
  4028. export class Curve3 {
  4029. private _points;
  4030. private _length;
  4031. /**
  4032. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4033. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4034. * @param v1 (Vector3) the control point
  4035. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4036. * @param nbPoints (integer) the wanted number of points in the curve
  4037. * @returns the created Curve3
  4038. */
  4039. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4040. /**
  4041. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4042. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4043. * @param v1 (Vector3) the first control point
  4044. * @param v2 (Vector3) the second control point
  4045. * @param v3 (Vector3) the end point of the Cubic Bezier
  4046. * @param nbPoints (integer) the wanted number of points in the curve
  4047. * @returns the created Curve3
  4048. */
  4049. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4050. /**
  4051. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4052. * @param p1 (Vector3) the origin point of the Hermite Spline
  4053. * @param t1 (Vector3) the tangent vector at the origin point
  4054. * @param p2 (Vector3) the end point of the Hermite Spline
  4055. * @param t2 (Vector3) the tangent vector at the end point
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a CatmullRom Spline curve :
  4062. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4063. * @param nbPoints (integer) the wanted number of points between each curve control points
  4064. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4065. * @returns the created Curve3
  4066. */
  4067. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4068. /**
  4069. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4070. * A Curve3 is designed from a series of successive Vector3.
  4071. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4072. * @param points points which make up the curve
  4073. */
  4074. constructor(points: Vector3[]);
  4075. /**
  4076. * @returns the Curve3 stored array of successive Vector3
  4077. */
  4078. getPoints(): Vector3[];
  4079. /**
  4080. * @returns the computed length (float) of the curve.
  4081. */
  4082. length(): number;
  4083. /**
  4084. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4085. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4086. * curveA and curveB keep unchanged.
  4087. * @param curve the curve to continue from this curve
  4088. * @returns the newly constructed curve
  4089. */
  4090. continue(curve: DeepImmutable<Curve3>): Curve3;
  4091. private _computeLength;
  4092. }
  4093. /**
  4094. * Contains position and normal vectors for a vertex
  4095. */
  4096. export class PositionNormalVertex {
  4097. /** the position of the vertex (defaut: 0,0,0) */
  4098. position: Vector3;
  4099. /** the normal of the vertex (defaut: 0,1,0) */
  4100. normal: Vector3;
  4101. /**
  4102. * Creates a PositionNormalVertex
  4103. * @param position the position of the vertex (defaut: 0,0,0)
  4104. * @param normal the normal of the vertex (defaut: 0,1,0)
  4105. */
  4106. constructor(
  4107. /** the position of the vertex (defaut: 0,0,0) */
  4108. position?: Vector3,
  4109. /** the normal of the vertex (defaut: 0,1,0) */
  4110. normal?: Vector3);
  4111. /**
  4112. * Clones the PositionNormalVertex
  4113. * @returns the cloned PositionNormalVertex
  4114. */
  4115. clone(): PositionNormalVertex;
  4116. }
  4117. /**
  4118. * Contains position, normal and uv vectors for a vertex
  4119. */
  4120. export class PositionNormalTextureVertex {
  4121. /** the position of the vertex (defaut: 0,0,0) */
  4122. position: Vector3;
  4123. /** the normal of the vertex (defaut: 0,1,0) */
  4124. normal: Vector3;
  4125. /** the uv of the vertex (default: 0,0) */
  4126. uv: Vector2;
  4127. /**
  4128. * Creates a PositionNormalTextureVertex
  4129. * @param position the position of the vertex (defaut: 0,0,0)
  4130. * @param normal the normal of the vertex (defaut: 0,1,0)
  4131. * @param uv the uv of the vertex (default: 0,0)
  4132. */
  4133. constructor(
  4134. /** the position of the vertex (defaut: 0,0,0) */
  4135. position?: Vector3,
  4136. /** the normal of the vertex (defaut: 0,1,0) */
  4137. normal?: Vector3,
  4138. /** the uv of the vertex (default: 0,0) */
  4139. uv?: Vector2);
  4140. /**
  4141. * Clones the PositionNormalTextureVertex
  4142. * @returns the cloned PositionNormalTextureVertex
  4143. */
  4144. clone(): PositionNormalTextureVertex;
  4145. }
  4146. /**
  4147. * @hidden
  4148. */
  4149. export class Tmp {
  4150. static Color3: Color3[];
  4151. static Color4: Color4[];
  4152. static Vector2: Vector2[];
  4153. static Vector3: Vector3[];
  4154. static Vector4: Vector4[];
  4155. static Quaternion: Quaternion[];
  4156. static Matrix: Matrix[];
  4157. }
  4158. }
  4159. declare module BABYLON {
  4160. /**
  4161. * Class used to enable access to offline support
  4162. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4163. */
  4164. export interface IOfflineProvider {
  4165. /**
  4166. * Gets a boolean indicating if scene must be saved in the database
  4167. */
  4168. enableSceneOffline: boolean;
  4169. /**
  4170. * Gets a boolean indicating if textures must be saved in the database
  4171. */
  4172. enableTexturesOffline: boolean;
  4173. /**
  4174. * Open the offline support and make it available
  4175. * @param successCallback defines the callback to call on success
  4176. * @param errorCallback defines the callback to call on error
  4177. */
  4178. open(successCallback: () => void, errorCallback: () => void): void;
  4179. /**
  4180. * Loads an image from the offline support
  4181. * @param url defines the url to load from
  4182. * @param image defines the target DOM image
  4183. */
  4184. loadImage(url: string, image: HTMLImageElement): void;
  4185. /**
  4186. * Loads a file from offline support
  4187. * @param url defines the URL to load from
  4188. * @param sceneLoaded defines a callback to call on success
  4189. * @param progressCallBack defines a callback to call when progress changed
  4190. * @param errorCallback defines a callback to call on error
  4191. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4192. */
  4193. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4194. }
  4195. }
  4196. declare module BABYLON {
  4197. /**
  4198. * A class serves as a medium between the observable and its observers
  4199. */
  4200. export class EventState {
  4201. /**
  4202. * Create a new EventState
  4203. * @param mask defines the mask associated with this state
  4204. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4205. * @param target defines the original target of the state
  4206. * @param currentTarget defines the current target of the state
  4207. */
  4208. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4209. /**
  4210. * Initialize the current event state
  4211. * @param mask defines the mask associated with this state
  4212. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4213. * @param target defines the original target of the state
  4214. * @param currentTarget defines the current target of the state
  4215. * @returns the current event state
  4216. */
  4217. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4218. /**
  4219. * An Observer can set this property to true to prevent subsequent observers of being notified
  4220. */
  4221. skipNextObservers: boolean;
  4222. /**
  4223. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4224. */
  4225. mask: number;
  4226. /**
  4227. * The object that originally notified the event
  4228. */
  4229. target?: any;
  4230. /**
  4231. * The current object in the bubbling phase
  4232. */
  4233. currentTarget?: any;
  4234. /**
  4235. * This will be populated with the return value of the last function that was executed.
  4236. * If it is the first function in the callback chain it will be the event data.
  4237. */
  4238. lastReturnValue?: any;
  4239. }
  4240. /**
  4241. * Represent an Observer registered to a given Observable object.
  4242. */
  4243. export class Observer<T> {
  4244. /**
  4245. * Defines the callback to call when the observer is notified
  4246. */
  4247. callback: (eventData: T, eventState: EventState) => void;
  4248. /**
  4249. * Defines the mask of the observer (used to filter notifications)
  4250. */
  4251. mask: number;
  4252. /**
  4253. * Defines the current scope used to restore the JS context
  4254. */
  4255. scope: any;
  4256. /** @hidden */ willBeUnregistered: boolean;
  4257. /**
  4258. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4259. */
  4260. unregisterOnNextCall: boolean;
  4261. /**
  4262. * Creates a new observer
  4263. * @param callback defines the callback to call when the observer is notified
  4264. * @param mask defines the mask of the observer (used to filter notifications)
  4265. * @param scope defines the current scope used to restore the JS context
  4266. */
  4267. constructor(
  4268. /**
  4269. * Defines the callback to call when the observer is notified
  4270. */
  4271. callback: (eventData: T, eventState: EventState) => void,
  4272. /**
  4273. * Defines the mask of the observer (used to filter notifications)
  4274. */
  4275. mask: number,
  4276. /**
  4277. * Defines the current scope used to restore the JS context
  4278. */
  4279. scope?: any);
  4280. }
  4281. /**
  4282. * Represent a list of observers registered to multiple Observables object.
  4283. */
  4284. export class MultiObserver<T> {
  4285. private _observers;
  4286. private _observables;
  4287. /**
  4288. * Release associated resources
  4289. */
  4290. dispose(): void;
  4291. /**
  4292. * Raise a callback when one of the observable will notify
  4293. * @param observables defines a list of observables to watch
  4294. * @param callback defines the callback to call on notification
  4295. * @param mask defines the mask used to filter notifications
  4296. * @param scope defines the current scope used to restore the JS context
  4297. * @returns the new MultiObserver
  4298. */
  4299. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4300. }
  4301. /**
  4302. * The Observable class is a simple implementation of the Observable pattern.
  4303. *
  4304. * 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.
  4305. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4306. * 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).
  4307. * 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.
  4308. */
  4309. export class Observable<T> {
  4310. private _observers;
  4311. private _eventState;
  4312. private _onObserverAdded;
  4313. /**
  4314. * Creates a new observable
  4315. * @param onObserverAdded defines a callback to call when a new observer is added
  4316. */
  4317. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4318. /**
  4319. * Create a new Observer with the specified callback
  4320. * @param callback the callback that will be executed for that Observer
  4321. * @param mask the mask used to filter observers
  4322. * @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.
  4323. * @param scope optional scope for the callback to be called from
  4324. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4325. * @returns the new observer created for the callback
  4326. */
  4327. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4328. /**
  4329. * Create a new Observer with the specified callback and unregisters after the next notification
  4330. * @param callback the callback that will be executed for that Observer
  4331. * @returns the new observer created for the callback
  4332. */
  4333. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4334. /**
  4335. * Remove an Observer from the Observable object
  4336. * @param observer the instance of the Observer to remove
  4337. * @returns false if it doesn't belong to this Observable
  4338. */
  4339. remove(observer: Nullable<Observer<T>>): boolean;
  4340. /**
  4341. * Remove a callback from the Observable object
  4342. * @param callback the callback to remove
  4343. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4344. * @returns false if it doesn't belong to this Observable
  4345. */
  4346. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4347. private _deferUnregister;
  4348. private _remove;
  4349. /**
  4350. * Notify all Observers by calling their respective callback with the given data
  4351. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4352. * @param eventData defines the data to send to all observers
  4353. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4354. * @param target defines the original target of the state
  4355. * @param currentTarget defines the current target of the state
  4356. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4357. */
  4358. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4359. /**
  4360. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4361. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4362. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4363. * and it is crucial that all callbacks will be executed.
  4364. * The order of the callbacks is kept, callbacks are not executed parallel.
  4365. *
  4366. * @param eventData The data to be sent to each callback
  4367. * @param mask is used to filter observers defaults to -1
  4368. * @param target defines the callback target (see EventState)
  4369. * @param currentTarget defines he current object in the bubbling phase
  4370. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4371. */
  4372. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4373. /**
  4374. * Notify a specific observer
  4375. * @param observer defines the observer to notify
  4376. * @param eventData defines the data to be sent to each callback
  4377. * @param mask is used to filter observers defaults to -1
  4378. */
  4379. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4380. /**
  4381. * Gets a boolean indicating if the observable has at least one observer
  4382. * @returns true is the Observable has at least one Observer registered
  4383. */
  4384. hasObservers(): boolean;
  4385. /**
  4386. * Clear the list of observers
  4387. */
  4388. clear(): void;
  4389. /**
  4390. * Clone the current observable
  4391. * @returns a new observable
  4392. */
  4393. clone(): Observable<T>;
  4394. /**
  4395. * Does this observable handles observer registered with a given mask
  4396. * @param mask defines the mask to be tested
  4397. * @return whether or not one observer registered with the given mask is handeled
  4398. **/
  4399. hasSpecificMask(mask?: number): boolean;
  4400. }
  4401. }
  4402. declare module BABYLON {
  4403. /**
  4404. * Class used to help managing file picking and drag'n'drop
  4405. * File Storage
  4406. */
  4407. export class FilesInputStore {
  4408. /**
  4409. * List of files ready to be loaded
  4410. */
  4411. static FilesToLoad: {
  4412. [key: string]: File;
  4413. };
  4414. }
  4415. }
  4416. declare module BABYLON {
  4417. /** Defines the cross module used constants to avoid circular dependncies */
  4418. export class Constants {
  4419. /** Defines that alpha blending is disabled */
  4420. static readonly ALPHA_DISABLE: number;
  4421. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4422. static readonly ALPHA_ADD: number;
  4423. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4424. static readonly ALPHA_COMBINE: number;
  4425. /** Defines that alpha blending to DEST - SRC * DEST */
  4426. static readonly ALPHA_SUBTRACT: number;
  4427. /** Defines that alpha blending to SRC * DEST */
  4428. static readonly ALPHA_MULTIPLY: number;
  4429. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4430. static readonly ALPHA_MAXIMIZED: number;
  4431. /** Defines that alpha blending to SRC + DEST */
  4432. static readonly ALPHA_ONEONE: number;
  4433. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4434. static readonly ALPHA_PREMULTIPLIED: number;
  4435. /**
  4436. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4437. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4438. */
  4439. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4440. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4441. static readonly ALPHA_INTERPOLATE: number;
  4442. /**
  4443. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4444. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4445. */
  4446. static readonly ALPHA_SCREENMODE: number;
  4447. /** Defines that the ressource is not delayed*/
  4448. static readonly DELAYLOADSTATE_NONE: number;
  4449. /** Defines that the ressource was successfully delay loaded */
  4450. static readonly DELAYLOADSTATE_LOADED: number;
  4451. /** Defines that the ressource is currently delay loading */
  4452. static readonly DELAYLOADSTATE_LOADING: number;
  4453. /** Defines that the ressource is delayed and has not started loading */
  4454. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4455. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4456. static readonly NEVER: number;
  4457. /** 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 */
  4458. static readonly ALWAYS: number;
  4459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4460. static readonly LESS: number;
  4461. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4462. static readonly EQUAL: number;
  4463. /** 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 */
  4464. static readonly LEQUAL: number;
  4465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4466. static readonly GREATER: number;
  4467. /** 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 */
  4468. static readonly GEQUAL: number;
  4469. /** 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 */
  4470. static readonly NOTEQUAL: number;
  4471. /** Passed to stencilOperation to specify that stencil value must be kept */
  4472. static readonly KEEP: number;
  4473. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4474. static readonly REPLACE: number;
  4475. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4476. static readonly INCR: number;
  4477. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4478. static readonly DECR: number;
  4479. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4480. static readonly INVERT: number;
  4481. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4482. static readonly INCR_WRAP: number;
  4483. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4484. static readonly DECR_WRAP: number;
  4485. /** Texture is not repeating outside of 0..1 UVs */
  4486. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4487. /** Texture is repeating outside of 0..1 UVs */
  4488. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4489. /** Texture is repeating and mirrored */
  4490. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4491. /** ALPHA */
  4492. static readonly TEXTUREFORMAT_ALPHA: number;
  4493. /** LUMINANCE */
  4494. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4495. /** LUMINANCE_ALPHA */
  4496. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4497. /** RGB */
  4498. static readonly TEXTUREFORMAT_RGB: number;
  4499. /** RGBA */
  4500. static readonly TEXTUREFORMAT_RGBA: number;
  4501. /** RED */
  4502. static readonly TEXTUREFORMAT_RED: number;
  4503. /** RED (2nd reference) */
  4504. static readonly TEXTUREFORMAT_R: number;
  4505. /** RG */
  4506. static readonly TEXTUREFORMAT_RG: number;
  4507. /** RED_INTEGER */
  4508. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4509. /** RED_INTEGER (2nd reference) */
  4510. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4511. /** RG_INTEGER */
  4512. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4513. /** RGB_INTEGER */
  4514. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4515. /** RGBA_INTEGER */
  4516. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4517. /** UNSIGNED_BYTE */
  4518. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4519. /** UNSIGNED_BYTE (2nd reference) */
  4520. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4521. /** FLOAT */
  4522. static readonly TEXTURETYPE_FLOAT: number;
  4523. /** HALF_FLOAT */
  4524. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4525. /** BYTE */
  4526. static readonly TEXTURETYPE_BYTE: number;
  4527. /** SHORT */
  4528. static readonly TEXTURETYPE_SHORT: number;
  4529. /** UNSIGNED_SHORT */
  4530. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4531. /** INT */
  4532. static readonly TEXTURETYPE_INT: number;
  4533. /** UNSIGNED_INT */
  4534. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4535. /** UNSIGNED_SHORT_4_4_4_4 */
  4536. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4537. /** UNSIGNED_SHORT_5_5_5_1 */
  4538. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4539. /** UNSIGNED_SHORT_5_6_5 */
  4540. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4541. /** UNSIGNED_INT_2_10_10_10_REV */
  4542. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4543. /** UNSIGNED_INT_24_8 */
  4544. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4545. /** UNSIGNED_INT_10F_11F_11F_REV */
  4546. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4547. /** UNSIGNED_INT_5_9_9_9_REV */
  4548. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4549. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4550. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4551. /** nearest is mag = nearest and min = nearest and mip = linear */
  4552. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4553. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4554. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4555. /** Trilinear is mag = linear and min = linear and mip = linear */
  4556. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4557. /** nearest is mag = nearest and min = nearest and mip = linear */
  4558. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4559. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4560. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4561. /** Trilinear is mag = linear and min = linear and mip = linear */
  4562. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4563. /** mag = nearest and min = nearest and mip = nearest */
  4564. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4565. /** mag = nearest and min = linear and mip = nearest */
  4566. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4567. /** mag = nearest and min = linear and mip = linear */
  4568. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4569. /** mag = nearest and min = linear and mip = none */
  4570. static readonly TEXTURE_NEAREST_LINEAR: number;
  4571. /** mag = nearest and min = nearest and mip = none */
  4572. static readonly TEXTURE_NEAREST_NEAREST: number;
  4573. /** mag = linear and min = nearest and mip = nearest */
  4574. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4575. /** mag = linear and min = nearest and mip = linear */
  4576. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4577. /** mag = linear and min = linear and mip = none */
  4578. static readonly TEXTURE_LINEAR_LINEAR: number;
  4579. /** mag = linear and min = nearest and mip = none */
  4580. static readonly TEXTURE_LINEAR_NEAREST: number;
  4581. /** Explicit coordinates mode */
  4582. static readonly TEXTURE_EXPLICIT_MODE: number;
  4583. /** Spherical coordinates mode */
  4584. static readonly TEXTURE_SPHERICAL_MODE: number;
  4585. /** Planar coordinates mode */
  4586. static readonly TEXTURE_PLANAR_MODE: number;
  4587. /** Cubic coordinates mode */
  4588. static readonly TEXTURE_CUBIC_MODE: number;
  4589. /** Projection coordinates mode */
  4590. static readonly TEXTURE_PROJECTION_MODE: number;
  4591. /** Skybox coordinates mode */
  4592. static readonly TEXTURE_SKYBOX_MODE: number;
  4593. /** Inverse Cubic coordinates mode */
  4594. static readonly TEXTURE_INVCUBIC_MODE: number;
  4595. /** Equirectangular coordinates mode */
  4596. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4597. /** Equirectangular Fixed coordinates mode */
  4598. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4599. /** Equirectangular Fixed Mirrored coordinates mode */
  4600. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4601. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4602. static readonly SCALEMODE_FLOOR: number;
  4603. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4604. static readonly SCALEMODE_NEAREST: number;
  4605. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4606. static readonly SCALEMODE_CEILING: number;
  4607. /**
  4608. * The dirty texture flag value
  4609. */
  4610. static readonly MATERIAL_TextureDirtyFlag: number;
  4611. /**
  4612. * The dirty light flag value
  4613. */
  4614. static readonly MATERIAL_LightDirtyFlag: number;
  4615. /**
  4616. * The dirty fresnel flag value
  4617. */
  4618. static readonly MATERIAL_FresnelDirtyFlag: number;
  4619. /**
  4620. * The dirty attribute flag value
  4621. */
  4622. static readonly MATERIAL_AttributesDirtyFlag: number;
  4623. /**
  4624. * The dirty misc flag value
  4625. */
  4626. static readonly MATERIAL_MiscDirtyFlag: number;
  4627. /**
  4628. * The all dirty flag value
  4629. */
  4630. static readonly MATERIAL_AllDirtyFlag: number;
  4631. /**
  4632. * Returns the triangle fill mode
  4633. */
  4634. static readonly MATERIAL_TriangleFillMode: number;
  4635. /**
  4636. * Returns the wireframe mode
  4637. */
  4638. static readonly MATERIAL_WireFrameFillMode: number;
  4639. /**
  4640. * Returns the point fill mode
  4641. */
  4642. static readonly MATERIAL_PointFillMode: number;
  4643. /**
  4644. * Returns the point list draw mode
  4645. */
  4646. static readonly MATERIAL_PointListDrawMode: number;
  4647. /**
  4648. * Returns the line list draw mode
  4649. */
  4650. static readonly MATERIAL_LineListDrawMode: number;
  4651. /**
  4652. * Returns the line loop draw mode
  4653. */
  4654. static readonly MATERIAL_LineLoopDrawMode: number;
  4655. /**
  4656. * Returns the line strip draw mode
  4657. */
  4658. static readonly MATERIAL_LineStripDrawMode: number;
  4659. /**
  4660. * Returns the triangle strip draw mode
  4661. */
  4662. static readonly MATERIAL_TriangleStripDrawMode: number;
  4663. /**
  4664. * Returns the triangle fan draw mode
  4665. */
  4666. static readonly MATERIAL_TriangleFanDrawMode: number;
  4667. /**
  4668. * Stores the clock-wise side orientation
  4669. */
  4670. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4671. /**
  4672. * Stores the counter clock-wise side orientation
  4673. */
  4674. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4675. /**
  4676. * Nothing
  4677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4678. */
  4679. static readonly ACTION_NothingTrigger: number;
  4680. /**
  4681. * On pick
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_OnPickTrigger: number;
  4685. /**
  4686. * On left pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnLeftPickTrigger: number;
  4690. /**
  4691. * On right pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnRightPickTrigger: number;
  4695. /**
  4696. * On center pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnCenterPickTrigger: number;
  4700. /**
  4701. * On pick down
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnPickDownTrigger: number;
  4705. /**
  4706. * On double pick
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnDoublePickTrigger: number;
  4710. /**
  4711. * On pick up
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnPickUpTrigger: number;
  4715. /**
  4716. * On pick out.
  4717. * This trigger will only be raised if you also declared a OnPickDown
  4718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4719. */
  4720. static readonly ACTION_OnPickOutTrigger: number;
  4721. /**
  4722. * On long press
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnLongPressTrigger: number;
  4726. /**
  4727. * On pointer over
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnPointerOverTrigger: number;
  4731. /**
  4732. * On pointer out
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOutTrigger: number;
  4736. /**
  4737. * On every frame
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnEveryFrameTrigger: number;
  4741. /**
  4742. * On intersection enter
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4746. /**
  4747. * On intersection exit
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionExitTrigger: number;
  4751. /**
  4752. * On key down
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnKeyDownTrigger: number;
  4756. /**
  4757. * On key up
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyUpTrigger: number;
  4761. /**
  4762. * Billboard mode will only apply to Y axis
  4763. */
  4764. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4765. /**
  4766. * Billboard mode will apply to all axes
  4767. */
  4768. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4769. /**
  4770. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4771. */
  4772. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4773. /**
  4774. * Gets or sets base Assets URL
  4775. */
  4776. static readonly PARTICLES_BaseAssetsUrl: string;
  4777. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4778. * Test order :
  4779. * Is the bounding sphere outside the frustum ?
  4780. * If not, are the bounding box vertices outside the frustum ?
  4781. * It not, then the cullable object is in the frustum.
  4782. */
  4783. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4784. /** Culling strategy : Bounding Sphere Only.
  4785. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4786. * It's also less accurate than the standard because some not visible objects can still be selected.
  4787. * Test : is the bounding sphere outside the frustum ?
  4788. * If not, then the cullable object is in the frustum.
  4789. */
  4790. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4791. /** Culling strategy : Optimistic Inclusion.
  4792. * This in an inclusion test first, then the standard exclusion test.
  4793. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4794. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4795. * Anyway, it's as accurate as the standard strategy.
  4796. * Test :
  4797. * Is the cullable object bounding sphere center in the frustum ?
  4798. * If not, apply the default culling strategy.
  4799. */
  4800. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4801. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4802. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4803. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4804. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4805. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4806. * Test :
  4807. * Is the cullable object bounding sphere center in the frustum ?
  4808. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4809. */
  4810. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4811. /**
  4812. * No logging while loading
  4813. */
  4814. static readonly SCENELOADER_NO_LOGGING: number;
  4815. /**
  4816. * Minimal logging while loading
  4817. */
  4818. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4819. /**
  4820. * Summary logging while loading
  4821. */
  4822. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4823. /**
  4824. * Detailled logging while loading
  4825. */
  4826. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4827. }
  4828. }
  4829. declare module BABYLON {
  4830. /**
  4831. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4832. * Babylon.js
  4833. */
  4834. export class DomManagement {
  4835. /**
  4836. * Checks if the window object exists
  4837. * @returns true if the window object exists
  4838. */
  4839. static IsWindowObjectExist(): boolean;
  4840. /**
  4841. * Extracts text content from a DOM element hierarchy
  4842. * @param element defines the root element
  4843. * @returns a string
  4844. */
  4845. static GetDOMTextContent(element: HTMLElement): string;
  4846. }
  4847. }
  4848. declare module BABYLON {
  4849. /**
  4850. * Logger used througouht the application to allow configuration of
  4851. * the log level required for the messages.
  4852. */
  4853. export class Logger {
  4854. /**
  4855. * No log
  4856. */
  4857. static readonly NoneLogLevel: number;
  4858. /**
  4859. * Only message logs
  4860. */
  4861. static readonly MessageLogLevel: number;
  4862. /**
  4863. * Only warning logs
  4864. */
  4865. static readonly WarningLogLevel: number;
  4866. /**
  4867. * Only error logs
  4868. */
  4869. static readonly ErrorLogLevel: number;
  4870. /**
  4871. * All logs
  4872. */
  4873. static readonly AllLogLevel: number;
  4874. private static _LogCache;
  4875. /**
  4876. * Gets a value indicating the number of loading errors
  4877. * @ignorenaming
  4878. */
  4879. static errorsCount: number;
  4880. /**
  4881. * Callback called when a new log is added
  4882. */
  4883. static OnNewCacheEntry: (entry: string) => void;
  4884. private static _AddLogEntry;
  4885. private static _FormatMessage;
  4886. private static _LogDisabled;
  4887. private static _LogEnabled;
  4888. private static _WarnDisabled;
  4889. private static _WarnEnabled;
  4890. private static _ErrorDisabled;
  4891. private static _ErrorEnabled;
  4892. /**
  4893. * Log a message to the console
  4894. */
  4895. static Log: (message: string) => void;
  4896. /**
  4897. * Write a warning message to the console
  4898. */
  4899. static Warn: (message: string) => void;
  4900. /**
  4901. * Write an error message to the console
  4902. */
  4903. static Error: (message: string) => void;
  4904. /**
  4905. * Gets current log cache (list of logs)
  4906. */
  4907. static readonly LogCache: string;
  4908. /**
  4909. * Clears the log cache
  4910. */
  4911. static ClearLogCache(): void;
  4912. /**
  4913. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4914. */
  4915. static LogLevels: number;
  4916. }
  4917. }
  4918. declare module BABYLON {
  4919. /** @hidden */
  4920. export class _TypeStore {
  4921. /** @hidden */
  4922. static RegisteredTypes: {
  4923. [key: string]: Object;
  4924. };
  4925. /** @hidden */
  4926. static GetClass(fqdn: string): any;
  4927. }
  4928. }
  4929. declare module BABYLON {
  4930. /**
  4931. * Class containing a set of static utilities functions for deep copy.
  4932. */
  4933. export class DeepCopier {
  4934. /**
  4935. * Tries to copy an object by duplicating every property
  4936. * @param source defines the source object
  4937. * @param destination defines the target object
  4938. * @param doNotCopyList defines a list of properties to avoid
  4939. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4940. */
  4941. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4942. }
  4943. }
  4944. declare module BABYLON {
  4945. /**
  4946. * Class containing a set of static utilities functions for precision date
  4947. */
  4948. export class PrecisionDate {
  4949. /**
  4950. * Gets either window.performance.now() if supported or Date.now() else
  4951. */
  4952. static readonly Now: number;
  4953. }
  4954. }
  4955. declare module BABYLON {
  4956. /**
  4957. * Class used to evalaute queries containing `and` and `or` operators
  4958. */
  4959. export class AndOrNotEvaluator {
  4960. /**
  4961. * Evaluate a query
  4962. * @param query defines the query to evaluate
  4963. * @param evaluateCallback defines the callback used to filter result
  4964. * @returns true if the query matches
  4965. */
  4966. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4967. private static _HandleParenthesisContent;
  4968. private static _SimplifyNegation;
  4969. }
  4970. }
  4971. declare module BABYLON {
  4972. /**
  4973. * Class used to store custom tags
  4974. */
  4975. export class Tags {
  4976. /**
  4977. * Adds support for tags on the given object
  4978. * @param obj defines the object to use
  4979. */
  4980. static EnableFor(obj: any): void;
  4981. /**
  4982. * Removes tags support
  4983. * @param obj defines the object to use
  4984. */
  4985. static DisableFor(obj: any): void;
  4986. /**
  4987. * Gets a boolean indicating if the given object has tags
  4988. * @param obj defines the object to use
  4989. * @returns a boolean
  4990. */
  4991. static HasTags(obj: any): boolean;
  4992. /**
  4993. * Gets the tags available on a given object
  4994. * @param obj defines the object to use
  4995. * @param asString defines if the tags must be returned as a string instead of an array of strings
  4996. * @returns the tags
  4997. */
  4998. static GetTags(obj: any, asString?: boolean): any;
  4999. /**
  5000. * Adds tags to an object
  5001. * @param obj defines the object to use
  5002. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5003. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5004. */
  5005. static AddTagsTo(obj: any, tagsString: string): void;
  5006. /**
  5007. * @hidden
  5008. */ private static _AddTagTo(obj: any, tag: string): void;
  5009. /**
  5010. * Removes specific tags from a specific object
  5011. * @param obj defines the object to use
  5012. * @param tagsString defines the tags to remove
  5013. */
  5014. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5015. /**
  5016. * @hidden
  5017. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5018. /**
  5019. * Defines if tags hosted on an object match a given query
  5020. * @param obj defines the object to use
  5021. * @param tagsQuery defines the tag query
  5022. * @returns a boolean
  5023. */
  5024. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5025. }
  5026. }
  5027. declare module BABYLON {
  5028. /**
  5029. * Manages the defines for the Material
  5030. */
  5031. export class MaterialDefines {
  5032. private _keys;
  5033. private _isDirty;
  5034. /** @hidden */ renderId: number;
  5035. /** @hidden */ areLightsDirty: boolean;
  5036. /** @hidden */ areAttributesDirty: boolean;
  5037. /** @hidden */ areTexturesDirty: boolean;
  5038. /** @hidden */ areFresnelDirty: boolean;
  5039. /** @hidden */ areMiscDirty: boolean;
  5040. /** @hidden */ areImageProcessingDirty: boolean;
  5041. /** @hidden */ normals: boolean;
  5042. /** @hidden */ uvs: boolean;
  5043. /** @hidden */ needNormals: boolean;
  5044. /** @hidden */ needUVs: boolean;
  5045. /**
  5046. * Specifies if the material needs to be re-calculated
  5047. */
  5048. readonly isDirty: boolean;
  5049. /**
  5050. * Marks the material to indicate that it has been re-calculated
  5051. */
  5052. markAsProcessed(): void;
  5053. /**
  5054. * Marks the material to indicate that it needs to be re-calculated
  5055. */
  5056. markAsUnprocessed(): void;
  5057. /**
  5058. * Marks the material to indicate all of its defines need to be re-calculated
  5059. */
  5060. markAllAsDirty(): void;
  5061. /**
  5062. * Marks the material to indicate that image processing needs to be re-calculated
  5063. */
  5064. markAsImageProcessingDirty(): void;
  5065. /**
  5066. * Marks the material to indicate the lights need to be re-calculated
  5067. */
  5068. markAsLightDirty(): void;
  5069. /**
  5070. * Marks the attribute state as changed
  5071. */
  5072. markAsAttributesDirty(): void;
  5073. /**
  5074. * Marks the texture state as changed
  5075. */
  5076. markAsTexturesDirty(): void;
  5077. /**
  5078. * Marks the fresnel state as changed
  5079. */
  5080. markAsFresnelDirty(): void;
  5081. /**
  5082. * Marks the misc state as changed
  5083. */
  5084. markAsMiscDirty(): void;
  5085. /**
  5086. * Rebuilds the material defines
  5087. */
  5088. rebuild(): void;
  5089. /**
  5090. * Specifies if two material defines are equal
  5091. * @param other - A material define instance to compare to
  5092. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5093. */
  5094. isEqual(other: MaterialDefines): boolean;
  5095. /**
  5096. * Clones this instance's defines to another instance
  5097. * @param other - material defines to clone values to
  5098. */
  5099. cloneTo(other: MaterialDefines): void;
  5100. /**
  5101. * Resets the material define values
  5102. */
  5103. reset(): void;
  5104. /**
  5105. * Converts the material define values to a string
  5106. * @returns - String of material define information
  5107. */
  5108. toString(): string;
  5109. }
  5110. }
  5111. declare module BABYLON {
  5112. /**
  5113. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5114. */
  5115. export class PerformanceMonitor {
  5116. private _enabled;
  5117. private _rollingFrameTime;
  5118. private _lastFrameTimeMs;
  5119. /**
  5120. * constructor
  5121. * @param frameSampleSize The number of samples required to saturate the sliding window
  5122. */
  5123. constructor(frameSampleSize?: number);
  5124. /**
  5125. * Samples current frame
  5126. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5127. */
  5128. sampleFrame(timeMs?: number): void;
  5129. /**
  5130. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5131. */
  5132. readonly averageFrameTime: number;
  5133. /**
  5134. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5135. */
  5136. readonly averageFrameTimeVariance: number;
  5137. /**
  5138. * Returns the frame time of the most recent frame
  5139. */
  5140. readonly instantaneousFrameTime: number;
  5141. /**
  5142. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5143. */
  5144. readonly averageFPS: number;
  5145. /**
  5146. * Returns the average framerate in frames per second using the most recent frame time
  5147. */
  5148. readonly instantaneousFPS: number;
  5149. /**
  5150. * Returns true if enough samples have been taken to completely fill the sliding window
  5151. */
  5152. readonly isSaturated: boolean;
  5153. /**
  5154. * Enables contributions to the sliding window sample set
  5155. */
  5156. enable(): void;
  5157. /**
  5158. * Disables contributions to the sliding window sample set
  5159. * Samples will not be interpolated over the disabled period
  5160. */
  5161. disable(): void;
  5162. /**
  5163. * Returns true if sampling is enabled
  5164. */
  5165. readonly isEnabled: boolean;
  5166. /**
  5167. * Resets performance monitor
  5168. */
  5169. reset(): void;
  5170. }
  5171. /**
  5172. * RollingAverage
  5173. *
  5174. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5175. */
  5176. export class RollingAverage {
  5177. /**
  5178. * Current average
  5179. */
  5180. average: number;
  5181. /**
  5182. * Current variance
  5183. */
  5184. variance: number;
  5185. protected _samples: Array<number>;
  5186. protected _sampleCount: number;
  5187. protected _pos: number;
  5188. protected _m2: number;
  5189. /**
  5190. * constructor
  5191. * @param length The number of samples required to saturate the sliding window
  5192. */
  5193. constructor(length: number);
  5194. /**
  5195. * Adds a sample to the sample set
  5196. * @param v The sample value
  5197. */
  5198. add(v: number): void;
  5199. /**
  5200. * Returns previously added values or null if outside of history or outside the sliding window domain
  5201. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5202. * @return Value previously recorded with add() or null if outside of range
  5203. */
  5204. history(i: number): number;
  5205. /**
  5206. * Returns true if enough samples have been taken to completely fill the sliding window
  5207. * @return true if sample-set saturated
  5208. */
  5209. isSaturated(): boolean;
  5210. /**
  5211. * Resets the rolling average (equivalent to 0 samples taken so far)
  5212. */
  5213. reset(): void;
  5214. /**
  5215. * Wraps a value around the sample range boundaries
  5216. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5217. * @return Wrapped position in sample range
  5218. */
  5219. protected _wrapPosition(i: number): number;
  5220. }
  5221. }
  5222. declare module BABYLON {
  5223. /**
  5224. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5225. * The underlying implementation relies on an associative array to ensure the best performances.
  5226. * The value can be anything including 'null' but except 'undefined'
  5227. */
  5228. export class StringDictionary<T> {
  5229. /**
  5230. * This will clear this dictionary and copy the content from the 'source' one.
  5231. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5232. * @param source the dictionary to take the content from and copy to this dictionary
  5233. */
  5234. copyFrom(source: StringDictionary<T>): void;
  5235. /**
  5236. * Get a value based from its key
  5237. * @param key the given key to get the matching value from
  5238. * @return the value if found, otherwise undefined is returned
  5239. */
  5240. get(key: string): T | undefined;
  5241. /**
  5242. * Get a value from its key or add it if it doesn't exist.
  5243. * This method will ensure you that a given key/data will be present in the dictionary.
  5244. * @param key the given key to get the matching value from
  5245. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5246. * The factory will only be invoked if there's no data for the given key.
  5247. * @return the value corresponding to the key.
  5248. */
  5249. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5250. /**
  5251. * Get a value from its key if present in the dictionary otherwise add it
  5252. * @param key the key to get the value from
  5253. * @param val if there's no such key/value pair in the dictionary add it with this value
  5254. * @return the value corresponding to the key
  5255. */
  5256. getOrAdd(key: string, val: T): T;
  5257. /**
  5258. * Check if there's a given key in the dictionary
  5259. * @param key the key to check for
  5260. * @return true if the key is present, false otherwise
  5261. */
  5262. contains(key: string): boolean;
  5263. /**
  5264. * Add a new key and its corresponding value
  5265. * @param key the key to add
  5266. * @param value the value corresponding to the key
  5267. * @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
  5268. */
  5269. add(key: string, value: T): boolean;
  5270. /**
  5271. * Update a specific value associated to a key
  5272. * @param key defines the key to use
  5273. * @param value defines the value to store
  5274. * @returns true if the value was updated (or false if the key was not found)
  5275. */
  5276. set(key: string, value: T): boolean;
  5277. /**
  5278. * Get the element of the given key and remove it from the dictionary
  5279. * @param key defines the key to search
  5280. * @returns the value associated with the key or null if not found
  5281. */
  5282. getAndRemove(key: string): Nullable<T>;
  5283. /**
  5284. * Remove a key/value from the dictionary.
  5285. * @param key the key to remove
  5286. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5287. */
  5288. remove(key: string): boolean;
  5289. /**
  5290. * Clear the whole content of the dictionary
  5291. */
  5292. clear(): void;
  5293. /**
  5294. * Gets the current count
  5295. */
  5296. readonly count: number;
  5297. /**
  5298. * Execute a callback on each key/val of the dictionary.
  5299. * Note that you can remove any element in this dictionary in the callback implementation
  5300. * @param callback the callback to execute on a given key/value pair
  5301. */
  5302. forEach(callback: (key: string, val: T) => void): void;
  5303. /**
  5304. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5305. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5306. * Note that you can remove any element in this dictionary in the callback implementation
  5307. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5308. * @returns the first item
  5309. */
  5310. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5311. private _count;
  5312. private _data;
  5313. }
  5314. }
  5315. declare module BABYLON {
  5316. /**
  5317. * Helper class that provides a small promise polyfill
  5318. */
  5319. export class PromisePolyfill {
  5320. /**
  5321. * Static function used to check if the polyfill is required
  5322. * If this is the case then the function will inject the polyfill to window.Promise
  5323. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5324. */
  5325. static Apply(force?: boolean): void;
  5326. }
  5327. }
  5328. declare module BABYLON {
  5329. /**
  5330. * Class used to store data that will be store in GPU memory
  5331. */
  5332. export class Buffer {
  5333. private _engine;
  5334. private _buffer;
  5335. /** @hidden */ data: Nullable<DataArray>;
  5336. private _updatable;
  5337. private _instanced;
  5338. /**
  5339. * Gets the byte stride.
  5340. */
  5341. readonly byteStride: number;
  5342. /**
  5343. * Constructor
  5344. * @param engine the engine
  5345. * @param data the data to use for this buffer
  5346. * @param updatable whether the data is updatable
  5347. * @param stride the stride (optional)
  5348. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5349. * @param instanced whether the buffer is instanced (optional)
  5350. * @param useBytes set to true if the stride in in bytes (optional)
  5351. */
  5352. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5353. /**
  5354. * Create a new VertexBuffer based on the current buffer
  5355. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5356. * @param offset defines offset in the buffer (0 by default)
  5357. * @param size defines the size in floats of attributes (position is 3 for instance)
  5358. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5359. * @param instanced defines if the vertex buffer contains indexed data
  5360. * @param useBytes defines if the offset and stride are in bytes
  5361. * @returns the new vertex buffer
  5362. */
  5363. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5364. /**
  5365. * Gets a boolean indicating if the Buffer is updatable?
  5366. * @returns true if the buffer is updatable
  5367. */
  5368. isUpdatable(): boolean;
  5369. /**
  5370. * Gets current buffer's data
  5371. * @returns a DataArray or null
  5372. */
  5373. getData(): Nullable<DataArray>;
  5374. /**
  5375. * Gets underlying native buffer
  5376. * @returns underlying native buffer
  5377. */
  5378. getBuffer(): Nullable<WebGLBuffer>;
  5379. /**
  5380. * Gets the stride in float32 units (i.e. byte stride / 4).
  5381. * May not be an integer if the byte stride is not divisible by 4.
  5382. * DEPRECATED. Use byteStride instead.
  5383. * @returns the stride in float32 units
  5384. */
  5385. getStrideSize(): number;
  5386. /**
  5387. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5388. * @param data defines the data to store
  5389. */
  5390. create(data?: Nullable<DataArray>): void;
  5391. /** @hidden */ rebuild(): void;
  5392. /**
  5393. * Update current buffer data
  5394. * @param data defines the data to store
  5395. */
  5396. update(data: DataArray): void;
  5397. /**
  5398. * Updates the data directly.
  5399. * @param data the new data
  5400. * @param offset the new offset
  5401. * @param vertexCount the vertex count (optional)
  5402. * @param useBytes set to true if the offset is in bytes
  5403. */
  5404. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5405. /**
  5406. * Release all resources
  5407. */
  5408. dispose(): void;
  5409. }
  5410. /**
  5411. * Specialized buffer used to store vertex data
  5412. */
  5413. export class VertexBuffer {
  5414. /** @hidden */ buffer: Buffer;
  5415. private _kind;
  5416. private _size;
  5417. private _ownsBuffer;
  5418. private _instanced;
  5419. private _instanceDivisor;
  5420. /**
  5421. * The byte type.
  5422. */
  5423. static readonly BYTE: number;
  5424. /**
  5425. * The unsigned byte type.
  5426. */
  5427. static readonly UNSIGNED_BYTE: number;
  5428. /**
  5429. * The short type.
  5430. */
  5431. static readonly SHORT: number;
  5432. /**
  5433. * The unsigned short type.
  5434. */
  5435. static readonly UNSIGNED_SHORT: number;
  5436. /**
  5437. * The integer type.
  5438. */
  5439. static readonly INT: number;
  5440. /**
  5441. * The unsigned integer type.
  5442. */
  5443. static readonly UNSIGNED_INT: number;
  5444. /**
  5445. * The float type.
  5446. */
  5447. static readonly FLOAT: number;
  5448. /**
  5449. * Gets or sets the instance divisor when in instanced mode
  5450. */
  5451. instanceDivisor: number;
  5452. /**
  5453. * Gets the byte stride.
  5454. */
  5455. readonly byteStride: number;
  5456. /**
  5457. * Gets the byte offset.
  5458. */
  5459. readonly byteOffset: number;
  5460. /**
  5461. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5462. */
  5463. readonly normalized: boolean;
  5464. /**
  5465. * Gets the data type of each component in the array.
  5466. */
  5467. readonly type: number;
  5468. /**
  5469. * Constructor
  5470. * @param engine the engine
  5471. * @param data the data to use for this vertex buffer
  5472. * @param kind the vertex buffer kind
  5473. * @param updatable whether the data is updatable
  5474. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5475. * @param stride the stride (optional)
  5476. * @param instanced whether the buffer is instanced (optional)
  5477. * @param offset the offset of the data (optional)
  5478. * @param size the number of components (optional)
  5479. * @param type the type of the component (optional)
  5480. * @param normalized whether the data contains normalized data (optional)
  5481. * @param useBytes set to true if stride and offset are in bytes (optional)
  5482. */
  5483. 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);
  5484. /** @hidden */ rebuild(): void;
  5485. /**
  5486. * Returns the kind of the VertexBuffer (string)
  5487. * @returns a string
  5488. */
  5489. getKind(): string;
  5490. /**
  5491. * Gets a boolean indicating if the VertexBuffer is updatable?
  5492. * @returns true if the buffer is updatable
  5493. */
  5494. isUpdatable(): boolean;
  5495. /**
  5496. * Gets current buffer's data
  5497. * @returns a DataArray or null
  5498. */
  5499. getData(): Nullable<DataArray>;
  5500. /**
  5501. * Gets underlying native buffer
  5502. * @returns underlying native buffer
  5503. */
  5504. getBuffer(): Nullable<WebGLBuffer>;
  5505. /**
  5506. * Gets the stride in float32 units (i.e. byte stride / 4).
  5507. * May not be an integer if the byte stride is not divisible by 4.
  5508. * DEPRECATED. Use byteStride instead.
  5509. * @returns the stride in float32 units
  5510. */
  5511. getStrideSize(): number;
  5512. /**
  5513. * Returns the offset as a multiple of the type byte length.
  5514. * DEPRECATED. Use byteOffset instead.
  5515. * @returns the offset in bytes
  5516. */
  5517. getOffset(): number;
  5518. /**
  5519. * Returns the number of components per vertex attribute (integer)
  5520. * @returns the size in float
  5521. */
  5522. getSize(): number;
  5523. /**
  5524. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5525. * @returns true if this buffer is instanced
  5526. */
  5527. getIsInstanced(): boolean;
  5528. /**
  5529. * Returns the instancing divisor, zero for non-instanced (integer).
  5530. * @returns a number
  5531. */
  5532. getInstanceDivisor(): number;
  5533. /**
  5534. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5535. * @param data defines the data to store
  5536. */
  5537. create(data?: DataArray): void;
  5538. /**
  5539. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5540. * This function will create a new buffer if the current one is not updatable
  5541. * @param data defines the data to store
  5542. */
  5543. update(data: DataArray): void;
  5544. /**
  5545. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5546. * Returns the directly updated WebGLBuffer.
  5547. * @param data the new data
  5548. * @param offset the new offset
  5549. * @param useBytes set to true if the offset is in bytes
  5550. */
  5551. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5552. /**
  5553. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5554. */
  5555. dispose(): void;
  5556. /**
  5557. * Enumerates each value of this vertex buffer as numbers.
  5558. * @param count the number of values to enumerate
  5559. * @param callback the callback function called for each value
  5560. */
  5561. forEach(count: number, callback: (value: number, index: number) => void): void;
  5562. /**
  5563. * Positions
  5564. */
  5565. static readonly PositionKind: string;
  5566. /**
  5567. * Normals
  5568. */
  5569. static readonly NormalKind: string;
  5570. /**
  5571. * Tangents
  5572. */
  5573. static readonly TangentKind: string;
  5574. /**
  5575. * Texture coordinates
  5576. */
  5577. static readonly UVKind: string;
  5578. /**
  5579. * Texture coordinates 2
  5580. */
  5581. static readonly UV2Kind: string;
  5582. /**
  5583. * Texture coordinates 3
  5584. */
  5585. static readonly UV3Kind: string;
  5586. /**
  5587. * Texture coordinates 4
  5588. */
  5589. static readonly UV4Kind: string;
  5590. /**
  5591. * Texture coordinates 5
  5592. */
  5593. static readonly UV5Kind: string;
  5594. /**
  5595. * Texture coordinates 6
  5596. */
  5597. static readonly UV6Kind: string;
  5598. /**
  5599. * Colors
  5600. */
  5601. static readonly ColorKind: string;
  5602. /**
  5603. * Matrix indices (for bones)
  5604. */
  5605. static readonly MatricesIndicesKind: string;
  5606. /**
  5607. * Matrix weights (for bones)
  5608. */
  5609. static readonly MatricesWeightsKind: string;
  5610. /**
  5611. * Additional matrix indices (for bones)
  5612. */
  5613. static readonly MatricesIndicesExtraKind: string;
  5614. /**
  5615. * Additional matrix weights (for bones)
  5616. */
  5617. static readonly MatricesWeightsExtraKind: string;
  5618. /**
  5619. * Deduces the stride given a kind.
  5620. * @param kind The kind string to deduce
  5621. * @returns The deduced stride
  5622. */
  5623. static DeduceStride(kind: string): number;
  5624. /**
  5625. * Gets the byte length of the given type.
  5626. * @param type the type
  5627. * @returns the number of bytes
  5628. */
  5629. static GetTypeByteLength(type: number): number;
  5630. /**
  5631. * Enumerates each value of the given parameters as numbers.
  5632. * @param data the data to enumerate
  5633. * @param byteOffset the byte offset of the data
  5634. * @param byteStride the byte stride of the data
  5635. * @param componentCount the number of components per element
  5636. * @param componentType the type of the component
  5637. * @param count the total number of components
  5638. * @param normalized whether the data is normalized
  5639. * @param callback the callback function called for each value
  5640. */
  5641. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5642. private static _GetFloatValue;
  5643. }
  5644. }
  5645. declare module BABYLON {
  5646. /**
  5647. * Class representing spherical polynomial coefficients to the 3rd degree
  5648. */
  5649. export class SphericalPolynomial {
  5650. /**
  5651. * The x coefficients of the spherical polynomial
  5652. */
  5653. x: Vector3;
  5654. /**
  5655. * The y coefficients of the spherical polynomial
  5656. */
  5657. y: Vector3;
  5658. /**
  5659. * The z coefficients of the spherical polynomial
  5660. */
  5661. z: Vector3;
  5662. /**
  5663. * The xx coefficients of the spherical polynomial
  5664. */
  5665. xx: Vector3;
  5666. /**
  5667. * The yy coefficients of the spherical polynomial
  5668. */
  5669. yy: Vector3;
  5670. /**
  5671. * The zz coefficients of the spherical polynomial
  5672. */
  5673. zz: Vector3;
  5674. /**
  5675. * The xy coefficients of the spherical polynomial
  5676. */
  5677. xy: Vector3;
  5678. /**
  5679. * The yz coefficients of the spherical polynomial
  5680. */
  5681. yz: Vector3;
  5682. /**
  5683. * The zx coefficients of the spherical polynomial
  5684. */
  5685. zx: Vector3;
  5686. /**
  5687. * Adds an ambient color to the spherical polynomial
  5688. * @param color the color to add
  5689. */
  5690. addAmbient(color: Color3): void;
  5691. /**
  5692. * Scales the spherical polynomial by the given amount
  5693. * @param scale the amount to scale
  5694. */
  5695. scale(scale: number): void;
  5696. /**
  5697. * Gets the spherical polynomial from harmonics
  5698. * @param harmonics the spherical harmonics
  5699. * @returns the spherical polynomial
  5700. */
  5701. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5702. /**
  5703. * Constructs a spherical polynomial from an array.
  5704. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5705. * @returns the spherical polynomial
  5706. */
  5707. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5708. }
  5709. /**
  5710. * Class representing spherical harmonics coefficients to the 3rd degree
  5711. */
  5712. export class SphericalHarmonics {
  5713. /**
  5714. * The l0,0 coefficients of the spherical harmonics
  5715. */
  5716. l00: Vector3;
  5717. /**
  5718. * The l1,-1 coefficients of the spherical harmonics
  5719. */
  5720. l1_1: Vector3;
  5721. /**
  5722. * The l1,0 coefficients of the spherical harmonics
  5723. */
  5724. l10: Vector3;
  5725. /**
  5726. * The l1,1 coefficients of the spherical harmonics
  5727. */
  5728. l11: Vector3;
  5729. /**
  5730. * The l2,-2 coefficients of the spherical harmonics
  5731. */
  5732. l2_2: Vector3;
  5733. /**
  5734. * The l2,-1 coefficients of the spherical harmonics
  5735. */
  5736. l2_1: Vector3;
  5737. /**
  5738. * The l2,0 coefficients of the spherical harmonics
  5739. */
  5740. l20: Vector3;
  5741. /**
  5742. * The l2,1 coefficients of the spherical harmonics
  5743. */
  5744. l21: Vector3;
  5745. /**
  5746. * The l2,2 coefficients of the spherical harmonics
  5747. */
  5748. lL22: Vector3;
  5749. /**
  5750. * Adds a light to the spherical harmonics
  5751. * @param direction the direction of the light
  5752. * @param color the color of the light
  5753. * @param deltaSolidAngle the delta solid angle of the light
  5754. */
  5755. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5756. /**
  5757. * Scales the spherical harmonics by the given amount
  5758. * @param scale the amount to scale
  5759. */
  5760. scale(scale: number): void;
  5761. /**
  5762. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5763. *
  5764. * ```
  5765. * E_lm = A_l * L_lm
  5766. * ```
  5767. *
  5768. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5769. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5770. * the scaling factors are given in equation 9.
  5771. */
  5772. convertIncidentRadianceToIrradiance(): void;
  5773. /**
  5774. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5775. *
  5776. * ```
  5777. * L = (1/pi) * E * rho
  5778. * ```
  5779. *
  5780. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5781. */
  5782. convertIrradianceToLambertianRadiance(): void;
  5783. /**
  5784. * Gets the spherical harmonics from polynomial
  5785. * @param polynomial the spherical polynomial
  5786. * @returns the spherical harmonics
  5787. */
  5788. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5789. /**
  5790. * Constructs a spherical harmonics from an array.
  5791. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5792. * @returns the spherical harmonics
  5793. */
  5794. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5795. }
  5796. }
  5797. declare module BABYLON {
  5798. /**
  5799. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5800. */
  5801. export interface CubeMapInfo {
  5802. /**
  5803. * The pixel array for the front face.
  5804. * This is stored in format, left to right, up to down format.
  5805. */
  5806. front: Nullable<ArrayBufferView>;
  5807. /**
  5808. * The pixel array for the back face.
  5809. * This is stored in format, left to right, up to down format.
  5810. */
  5811. back: Nullable<ArrayBufferView>;
  5812. /**
  5813. * The pixel array for the left face.
  5814. * This is stored in format, left to right, up to down format.
  5815. */
  5816. left: Nullable<ArrayBufferView>;
  5817. /**
  5818. * The pixel array for the right face.
  5819. * This is stored in format, left to right, up to down format.
  5820. */
  5821. right: Nullable<ArrayBufferView>;
  5822. /**
  5823. * The pixel array for the up face.
  5824. * This is stored in format, left to right, up to down format.
  5825. */
  5826. up: Nullable<ArrayBufferView>;
  5827. /**
  5828. * The pixel array for the down face.
  5829. * This is stored in format, left to right, up to down format.
  5830. */
  5831. down: Nullable<ArrayBufferView>;
  5832. /**
  5833. * The size of the cubemap stored.
  5834. *
  5835. * Each faces will be size * size pixels.
  5836. */
  5837. size: number;
  5838. /**
  5839. * The format of the texture.
  5840. *
  5841. * RGBA, RGB.
  5842. */
  5843. format: number;
  5844. /**
  5845. * The type of the texture data.
  5846. *
  5847. * UNSIGNED_INT, FLOAT.
  5848. */
  5849. type: number;
  5850. /**
  5851. * Specifies whether the texture is in gamma space.
  5852. */
  5853. gammaSpace: boolean;
  5854. }
  5855. /**
  5856. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5857. */
  5858. export class PanoramaToCubeMapTools {
  5859. private static FACE_FRONT;
  5860. private static FACE_BACK;
  5861. private static FACE_RIGHT;
  5862. private static FACE_LEFT;
  5863. private static FACE_DOWN;
  5864. private static FACE_UP;
  5865. /**
  5866. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5867. *
  5868. * @param float32Array The source data.
  5869. * @param inputWidth The width of the input panorama.
  5870. * @param inputHeight The height of the input panorama.
  5871. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5872. * @return The cubemap data
  5873. */
  5874. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5875. private static CreateCubemapTexture;
  5876. private static CalcProjectionSpherical;
  5877. }
  5878. }
  5879. declare module BABYLON {
  5880. /**
  5881. * Helper class dealing with the extraction of spherical polynomial dataArray
  5882. * from a cube map.
  5883. */
  5884. export class CubeMapToSphericalPolynomialTools {
  5885. private static FileFaces;
  5886. /**
  5887. * Converts a texture to the according Spherical Polynomial data.
  5888. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5889. *
  5890. * @param texture The texture to extract the information from.
  5891. * @return The Spherical Polynomial data.
  5892. */
  5893. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5894. /**
  5895. * Converts a cubemap to the according Spherical Polynomial data.
  5896. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5897. *
  5898. * @param cubeInfo The Cube map to extract the information from.
  5899. * @return The Spherical Polynomial data.
  5900. */
  5901. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5902. }
  5903. }
  5904. declare module BABYLON {
  5905. /**
  5906. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5907. * during the life time of the application.
  5908. */
  5909. export class EngineStore {
  5910. /** Gets the list of created engines */
  5911. static Instances: Engine[];
  5912. /**
  5913. * Gets the latest created engine
  5914. */
  5915. static readonly LastCreatedEngine: Nullable<Engine>;
  5916. /**
  5917. * Gets the latest created scene
  5918. */
  5919. static readonly LastCreatedScene: Nullable<Scene>;
  5920. }
  5921. }
  5922. declare module BABYLON {
  5923. /**
  5924. * Define options used to create a render target texture
  5925. */
  5926. export class RenderTargetCreationOptions {
  5927. /**
  5928. * Specifies is mipmaps must be generated
  5929. */
  5930. generateMipMaps?: boolean;
  5931. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5932. generateDepthBuffer?: boolean;
  5933. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5934. generateStencilBuffer?: boolean;
  5935. /** Defines texture type (int by default) */
  5936. type?: number;
  5937. /** Defines sampling mode (trilinear by default) */
  5938. samplingMode?: number;
  5939. /** Defines format (RGBA by default) */
  5940. format?: number;
  5941. }
  5942. }
  5943. declare module BABYLON {
  5944. /**
  5945. * @hidden
  5946. **/
  5947. export class _AlphaState {
  5948. private _isAlphaBlendDirty;
  5949. private _isBlendFunctionParametersDirty;
  5950. private _isBlendEquationParametersDirty;
  5951. private _isBlendConstantsDirty;
  5952. private _alphaBlend;
  5953. private _blendFunctionParameters;
  5954. private _blendEquationParameters;
  5955. private _blendConstants;
  5956. /**
  5957. * Initializes the state.
  5958. */
  5959. constructor();
  5960. readonly isDirty: boolean;
  5961. alphaBlend: boolean;
  5962. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5963. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5964. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5965. reset(): void;
  5966. apply(gl: WebGLRenderingContext): void;
  5967. }
  5968. }
  5969. declare module BABYLON {
  5970. /**
  5971. * @hidden
  5972. **/
  5973. export class _DepthCullingState {
  5974. private _isDepthTestDirty;
  5975. private _isDepthMaskDirty;
  5976. private _isDepthFuncDirty;
  5977. private _isCullFaceDirty;
  5978. private _isCullDirty;
  5979. private _isZOffsetDirty;
  5980. private _isFrontFaceDirty;
  5981. private _depthTest;
  5982. private _depthMask;
  5983. private _depthFunc;
  5984. private _cull;
  5985. private _cullFace;
  5986. private _zOffset;
  5987. private _frontFace;
  5988. /**
  5989. * Initializes the state.
  5990. */
  5991. constructor();
  5992. readonly isDirty: boolean;
  5993. zOffset: number;
  5994. cullFace: Nullable<number>;
  5995. cull: Nullable<boolean>;
  5996. depthFunc: Nullable<number>;
  5997. depthMask: boolean;
  5998. depthTest: boolean;
  5999. frontFace: Nullable<number>;
  6000. reset(): void;
  6001. apply(gl: WebGLRenderingContext): void;
  6002. }
  6003. }
  6004. declare module BABYLON {
  6005. /**
  6006. * @hidden
  6007. **/
  6008. export class _StencilState {
  6009. /** 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 */
  6010. static readonly ALWAYS: number;
  6011. /** Passed to stencilOperation to specify that stencil value must be kept */
  6012. static readonly KEEP: number;
  6013. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6014. static readonly REPLACE: number;
  6015. private _isStencilTestDirty;
  6016. private _isStencilMaskDirty;
  6017. private _isStencilFuncDirty;
  6018. private _isStencilOpDirty;
  6019. private _stencilTest;
  6020. private _stencilMask;
  6021. private _stencilFunc;
  6022. private _stencilFuncRef;
  6023. private _stencilFuncMask;
  6024. private _stencilOpStencilFail;
  6025. private _stencilOpDepthFail;
  6026. private _stencilOpStencilDepthPass;
  6027. readonly isDirty: boolean;
  6028. stencilFunc: number;
  6029. stencilFuncRef: number;
  6030. stencilFuncMask: number;
  6031. stencilOpStencilFail: number;
  6032. stencilOpDepthFail: number;
  6033. stencilOpStencilDepthPass: number;
  6034. stencilMask: number;
  6035. stencilTest: boolean;
  6036. constructor();
  6037. reset(): void;
  6038. apply(gl: WebGLRenderingContext): void;
  6039. }
  6040. }
  6041. declare module BABYLON {
  6042. /**
  6043. * @hidden
  6044. **/
  6045. export class _TimeToken { startTimeQuery: Nullable<WebGLQuery>; endTimeQuery: Nullable<WebGLQuery>; timeElapsedQuery: Nullable<WebGLQuery>; timeElapsedQueryEnded: boolean;
  6046. }
  6047. }
  6048. declare module BABYLON {
  6049. /**
  6050. * Internal interface used to track InternalTexture already bound to the GL context
  6051. */
  6052. export interface IInternalTextureTracker {
  6053. /**
  6054. * Gets or set the previous tracker in the list
  6055. */
  6056. previous: Nullable<IInternalTextureTracker>;
  6057. /**
  6058. * Gets or set the next tracker in the list
  6059. */
  6060. next: Nullable<IInternalTextureTracker>;
  6061. }
  6062. /**
  6063. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6064. */
  6065. export class DummyInternalTextureTracker {
  6066. /**
  6067. * Gets or set the previous tracker in the list
  6068. */
  6069. previous: Nullable<IInternalTextureTracker>;
  6070. /**
  6071. * Gets or set the next tracker in the list
  6072. */
  6073. next: Nullable<IInternalTextureTracker>;
  6074. }
  6075. }
  6076. declare module BABYLON {
  6077. /**
  6078. * Class used to store data associated with WebGL texture data for the engine
  6079. * This class should not be used directly
  6080. */
  6081. export class InternalTexture implements IInternalTextureTracker {
  6082. /** hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6083. /**
  6084. * The source of the texture data is unknown
  6085. */
  6086. static DATASOURCE_UNKNOWN: number;
  6087. /**
  6088. * Texture data comes from an URL
  6089. */
  6090. static DATASOURCE_URL: number;
  6091. /**
  6092. * Texture data is only used for temporary storage
  6093. */
  6094. static DATASOURCE_TEMP: number;
  6095. /**
  6096. * Texture data comes from raw data (ArrayBuffer)
  6097. */
  6098. static DATASOURCE_RAW: number;
  6099. /**
  6100. * Texture content is dynamic (video or dynamic texture)
  6101. */
  6102. static DATASOURCE_DYNAMIC: number;
  6103. /**
  6104. * Texture content is generated by rendering to it
  6105. */
  6106. static DATASOURCE_RENDERTARGET: number;
  6107. /**
  6108. * Texture content is part of a multi render target process
  6109. */
  6110. static DATASOURCE_MULTIRENDERTARGET: number;
  6111. /**
  6112. * Texture data comes from a cube data file
  6113. */
  6114. static DATASOURCE_CUBE: number;
  6115. /**
  6116. * Texture data comes from a raw cube data
  6117. */
  6118. static DATASOURCE_CUBERAW: number;
  6119. /**
  6120. * Texture data come from a prefiltered cube data file
  6121. */
  6122. static DATASOURCE_CUBEPREFILTERED: number;
  6123. /**
  6124. * Texture content is raw 3D data
  6125. */
  6126. static DATASOURCE_RAW3D: number;
  6127. /**
  6128. * Texture content is a depth texture
  6129. */
  6130. static DATASOURCE_DEPTHTEXTURE: number;
  6131. /**
  6132. * Texture data comes from a raw cube data encoded with RGBD
  6133. */
  6134. static DATASOURCE_CUBERAW_RGBD: number;
  6135. /**
  6136. * Defines if the texture is ready
  6137. */
  6138. isReady: boolean;
  6139. /**
  6140. * Defines if the texture is a cube texture
  6141. */
  6142. isCube: boolean;
  6143. /**
  6144. * Defines if the texture contains 3D data
  6145. */
  6146. is3D: boolean;
  6147. /**
  6148. * Gets the URL used to load this texture
  6149. */
  6150. url: string;
  6151. /**
  6152. * Gets the sampling mode of the texture
  6153. */
  6154. samplingMode: number;
  6155. /**
  6156. * Gets a boolean indicating if the texture needs mipmaps generation
  6157. */
  6158. generateMipMaps: boolean;
  6159. /**
  6160. * Gets the number of samples used by the texture (WebGL2+ only)
  6161. */
  6162. samples: number;
  6163. /**
  6164. * Gets the type of the texture (int, float...)
  6165. */
  6166. type: number;
  6167. /**
  6168. * Gets the format of the texture (RGB, RGBA...)
  6169. */
  6170. format: number;
  6171. /**
  6172. * Observable called when the texture is loaded
  6173. */
  6174. onLoadedObservable: Observable<InternalTexture>;
  6175. /**
  6176. * Gets the width of the texture
  6177. */
  6178. width: number;
  6179. /**
  6180. * Gets the height of the texture
  6181. */
  6182. height: number;
  6183. /**
  6184. * Gets the depth of the texture
  6185. */
  6186. depth: number;
  6187. /**
  6188. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6189. */
  6190. baseWidth: number;
  6191. /**
  6192. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6193. */
  6194. baseHeight: number;
  6195. /**
  6196. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6197. */
  6198. baseDepth: number;
  6199. /**
  6200. * Gets a boolean indicating if the texture is inverted on Y axis
  6201. */
  6202. invertY: boolean;
  6203. /**
  6204. * Gets or set the previous tracker in the list
  6205. */
  6206. previous: Nullable<IInternalTextureTracker>;
  6207. /**
  6208. * Gets or set the next tracker in the list
  6209. */
  6210. next: Nullable<IInternalTextureTracker>;
  6211. /** @hidden */ invertVScale: boolean;
  6212. /** @hidden */ initialSlot: number;
  6213. /** @hidden */ designatedSlot: number;
  6214. /** @hidden */ dataSource: number;
  6215. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6216. /** @hidden */ bufferView: Nullable<ArrayBufferView>;
  6217. /** @hidden */ bufferViewArray: Nullable<ArrayBufferView[]>;
  6218. /** @hidden */ bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6219. /** @hidden */ size: number;
  6220. /** @hidden */ extension: string;
  6221. /** @hidden */ files: Nullable<string[]>;
  6222. /** @hidden */ workingCanvas: HTMLCanvasElement;
  6223. /** @hidden */ workingContext: CanvasRenderingContext2D;
  6224. /** @hidden */ framebuffer: Nullable<WebGLFramebuffer>;
  6225. /** @hidden */ depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6226. /** @hidden */ MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6227. /** @hidden */ MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6228. /** @hidden */ attachments: Nullable<number[]>;
  6229. /** @hidden */ cachedCoordinatesMode: Nullable<number>;
  6230. /** @hidden */ cachedWrapU: Nullable<number>;
  6231. /** @hidden */ cachedWrapV: Nullable<number>;
  6232. /** @hidden */ cachedWrapR: Nullable<number>;
  6233. /** @hidden */ cachedAnisotropicFilteringLevel: Nullable<number>;
  6234. /** @hidden */ isDisabled: boolean;
  6235. /** @hidden */ compression: Nullable<string>;
  6236. /** @hidden */ generateStencilBuffer: boolean;
  6237. /** @hidden */ generateDepthBuffer: boolean;
  6238. /** @hidden */ comparisonFunction: number;
  6239. /** @hidden */ sphericalPolynomial: Nullable<SphericalPolynomial>;
  6240. /** @hidden */ lodGenerationScale: number;
  6241. /** @hidden */ lodGenerationOffset: number;
  6242. /** @hidden */ lodTextureHigh: BaseTexture;
  6243. /** @hidden */ lodTextureMid: BaseTexture;
  6244. /** @hidden */ lodTextureLow: BaseTexture;
  6245. /** @hidden */ isRGBD: boolean;
  6246. /** @hidden */ webGLTexture: Nullable<WebGLTexture>;
  6247. /** @hidden */ references: number;
  6248. private _engine;
  6249. /**
  6250. * Gets the Engine the texture belongs to.
  6251. * @returns The babylon engine
  6252. */
  6253. getEngine(): Engine;
  6254. /**
  6255. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6256. */
  6257. readonly dataSource: number;
  6258. /**
  6259. * Creates a new InternalTexture
  6260. * @param engine defines the engine to use
  6261. * @param dataSource defines the type of data that will be used
  6262. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6263. */
  6264. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6265. /**
  6266. * Increments the number of references (ie. the number of Texture that point to it)
  6267. */
  6268. incrementReferences(): void;
  6269. /**
  6270. * Change the size of the texture (not the size of the content)
  6271. * @param width defines the new width
  6272. * @param height defines the new height
  6273. * @param depth defines the new depth (1 by default)
  6274. */
  6275. updateSize(width: int, height: int, depth?: int): void;
  6276. /** @hidden */ rebuild(): void;
  6277. /** @hidden */ swapAndDie(target: InternalTexture): void;
  6278. /**
  6279. * Dispose the current allocated resources
  6280. */
  6281. dispose(): void;
  6282. }
  6283. }
  6284. declare module BABYLON {
  6285. /**
  6286. * This represents the main contract an easing function should follow.
  6287. * Easing functions are used throughout the animation system.
  6288. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6289. */
  6290. export interface IEasingFunction {
  6291. /**
  6292. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6293. * of the easing function.
  6294. * The link below provides some of the most common examples of easing functions.
  6295. * @see https://easings.net/
  6296. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6297. * @returns the corresponding value on the curve defined by the easing function
  6298. */
  6299. ease(gradient: number): number;
  6300. }
  6301. /**
  6302. * Base class used for every default easing function.
  6303. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6304. */
  6305. export class EasingFunction implements IEasingFunction {
  6306. /**
  6307. * Interpolation follows the mathematical formula associated with the easing function.
  6308. */
  6309. static readonly EASINGMODE_EASEIN: number;
  6310. /**
  6311. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6312. */
  6313. static readonly EASINGMODE_EASEOUT: number;
  6314. /**
  6315. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6316. */
  6317. static readonly EASINGMODE_EASEINOUT: number;
  6318. private _easingMode;
  6319. /**
  6320. * Sets the easing mode of the current function.
  6321. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6322. */
  6323. setEasingMode(easingMode: number): void;
  6324. /**
  6325. * Gets the current easing mode.
  6326. * @returns the easing mode
  6327. */
  6328. getEasingMode(): number;
  6329. /**
  6330. * @hidden
  6331. */
  6332. easeInCore(gradient: number): number;
  6333. /**
  6334. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6335. * of the easing function.
  6336. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6337. * @returns the corresponding value on the curve defined by the easing function
  6338. */
  6339. ease(gradient: number): number;
  6340. }
  6341. /**
  6342. * Easing function with a circle shape (see link below).
  6343. * @see https://easings.net/#easeInCirc
  6344. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6345. */
  6346. export class CircleEase extends EasingFunction implements IEasingFunction {
  6347. /** @hidden */
  6348. easeInCore(gradient: number): number;
  6349. }
  6350. /**
  6351. * Easing function with a ease back shape (see link below).
  6352. * @see https://easings.net/#easeInBack
  6353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6354. */
  6355. export class BackEase extends EasingFunction implements IEasingFunction {
  6356. /** Defines the amplitude of the function */
  6357. amplitude: number;
  6358. /**
  6359. * Instantiates a back ease easing
  6360. * @see https://easings.net/#easeInBack
  6361. * @param amplitude Defines the amplitude of the function
  6362. */
  6363. constructor(
  6364. /** Defines the amplitude of the function */
  6365. amplitude?: number);
  6366. /** @hidden */
  6367. easeInCore(gradient: number): number;
  6368. }
  6369. /**
  6370. * Easing function with a bouncing shape (see link below).
  6371. * @see https://easings.net/#easeInBounce
  6372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6373. */
  6374. export class BounceEase extends EasingFunction implements IEasingFunction {
  6375. /** Defines the number of bounces */
  6376. bounces: number;
  6377. /** Defines the amplitude of the bounce */
  6378. bounciness: number;
  6379. /**
  6380. * Instantiates a bounce easing
  6381. * @see https://easings.net/#easeInBounce
  6382. * @param bounces Defines the number of bounces
  6383. * @param bounciness Defines the amplitude of the bounce
  6384. */
  6385. constructor(
  6386. /** Defines the number of bounces */
  6387. bounces?: number,
  6388. /** Defines the amplitude of the bounce */
  6389. bounciness?: number);
  6390. /** @hidden */
  6391. easeInCore(gradient: number): number;
  6392. }
  6393. /**
  6394. * Easing function with a power of 3 shape (see link below).
  6395. * @see https://easings.net/#easeInCubic
  6396. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6397. */
  6398. export class CubicEase extends EasingFunction implements IEasingFunction {
  6399. /** @hidden */
  6400. easeInCore(gradient: number): number;
  6401. }
  6402. /**
  6403. * Easing function with an elastic shape (see link below).
  6404. * @see https://easings.net/#easeInElastic
  6405. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6406. */
  6407. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6408. /** Defines the number of oscillations*/
  6409. oscillations: number;
  6410. /** Defines the amplitude of the oscillations*/
  6411. springiness: number;
  6412. /**
  6413. * Instantiates an elastic easing function
  6414. * @see https://easings.net/#easeInElastic
  6415. * @param oscillations Defines the number of oscillations
  6416. * @param springiness Defines the amplitude of the oscillations
  6417. */
  6418. constructor(
  6419. /** Defines the number of oscillations*/
  6420. oscillations?: number,
  6421. /** Defines the amplitude of the oscillations*/
  6422. springiness?: number);
  6423. /** @hidden */
  6424. easeInCore(gradient: number): number;
  6425. }
  6426. /**
  6427. * Easing function with an exponential shape (see link below).
  6428. * @see https://easings.net/#easeInExpo
  6429. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6430. */
  6431. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6432. /** Defines the exponent of the function */
  6433. exponent: number;
  6434. /**
  6435. * Instantiates an exponential easing function
  6436. * @see https://easings.net/#easeInExpo
  6437. * @param exponent Defines the exponent of the function
  6438. */
  6439. constructor(
  6440. /** Defines the exponent of the function */
  6441. exponent?: number);
  6442. /** @hidden */
  6443. easeInCore(gradient: number): number;
  6444. }
  6445. /**
  6446. * Easing function with a power shape (see link below).
  6447. * @see https://easings.net/#easeInQuad
  6448. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6449. */
  6450. export class PowerEase extends EasingFunction implements IEasingFunction {
  6451. /** Defines the power of the function */
  6452. power: number;
  6453. /**
  6454. * Instantiates an power base easing function
  6455. * @see https://easings.net/#easeInQuad
  6456. * @param power Defines the power of the function
  6457. */
  6458. constructor(
  6459. /** Defines the power of the function */
  6460. power?: number);
  6461. /** @hidden */
  6462. easeInCore(gradient: number): number;
  6463. }
  6464. /**
  6465. * Easing function with a power of 2 shape (see link below).
  6466. * @see https://easings.net/#easeInQuad
  6467. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6468. */
  6469. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6470. /** @hidden */
  6471. easeInCore(gradient: number): number;
  6472. }
  6473. /**
  6474. * Easing function with a power of 4 shape (see link below).
  6475. * @see https://easings.net/#easeInQuart
  6476. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6477. */
  6478. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6479. /** @hidden */
  6480. easeInCore(gradient: number): number;
  6481. }
  6482. /**
  6483. * Easing function with a power of 5 shape (see link below).
  6484. * @see https://easings.net/#easeInQuint
  6485. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6486. */
  6487. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6488. /** @hidden */
  6489. easeInCore(gradient: number): number;
  6490. }
  6491. /**
  6492. * Easing function with a sin shape (see link below).
  6493. * @see https://easings.net/#easeInSine
  6494. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6495. */
  6496. export class SineEase extends EasingFunction implements IEasingFunction {
  6497. /** @hidden */
  6498. easeInCore(gradient: number): number;
  6499. }
  6500. /**
  6501. * Easing function with a bezier shape (see link below).
  6502. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6503. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6504. */
  6505. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6506. /** Defines the x component of the start tangent in the bezier curve */
  6507. x1: number;
  6508. /** Defines the y component of the start tangent in the bezier curve */
  6509. y1: number;
  6510. /** Defines the x component of the end tangent in the bezier curve */
  6511. x2: number;
  6512. /** Defines the y component of the end tangent in the bezier curve */
  6513. y2: number;
  6514. /**
  6515. * Instantiates a bezier function
  6516. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6517. * @param x1 Defines the x component of the start tangent in the bezier curve
  6518. * @param y1 Defines the y component of the start tangent in the bezier curve
  6519. * @param x2 Defines the x component of the end tangent in the bezier curve
  6520. * @param y2 Defines the y component of the end tangent in the bezier curve
  6521. */
  6522. constructor(
  6523. /** Defines the x component of the start tangent in the bezier curve */
  6524. x1?: number,
  6525. /** Defines the y component of the start tangent in the bezier curve */
  6526. y1?: number,
  6527. /** Defines the x component of the end tangent in the bezier curve */
  6528. x2?: number,
  6529. /** Defines the y component of the end tangent in the bezier curve */
  6530. y2?: number);
  6531. /** @hidden */
  6532. easeInCore(gradient: number): number;
  6533. }
  6534. }
  6535. declare module BABYLON {
  6536. /**
  6537. * Interface used to define a behavior
  6538. */
  6539. export interface Behavior<T> {
  6540. /** gets or sets behavior's name */
  6541. name: string;
  6542. /**
  6543. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6544. */
  6545. init(): void;
  6546. /**
  6547. * Called when the behavior is attached to a target
  6548. * @param target defines the target where the behavior is attached to
  6549. */
  6550. attach(target: T): void;
  6551. /**
  6552. * Called when the behavior is detached from its target
  6553. */
  6554. detach(): void;
  6555. }
  6556. /**
  6557. * Interface implemented by classes supporting behaviors
  6558. */
  6559. export interface IBehaviorAware<T> {
  6560. /**
  6561. * Attach a behavior
  6562. * @param behavior defines the behavior to attach
  6563. * @returns the current host
  6564. */
  6565. addBehavior(behavior: Behavior<T>): T;
  6566. /**
  6567. * Remove a behavior from the current object
  6568. * @param behavior defines the behavior to detach
  6569. * @returns the current host
  6570. */
  6571. removeBehavior(behavior: Behavior<T>): T;
  6572. /**
  6573. * Gets a behavior using its name to search
  6574. * @param name defines the name to search
  6575. * @returns the behavior or null if not found
  6576. */
  6577. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6578. }
  6579. }
  6580. declare module BABYLON {
  6581. /**
  6582. * Defines a runtime animation
  6583. */
  6584. export class RuntimeAnimation {
  6585. private _events;
  6586. /**
  6587. * The current frame of the runtime animation
  6588. */
  6589. private _currentFrame;
  6590. /**
  6591. * The animation used by the runtime animation
  6592. */
  6593. private _animation;
  6594. /**
  6595. * The target of the runtime animation
  6596. */
  6597. private _target;
  6598. /**
  6599. * The initiating animatable
  6600. */
  6601. private _host;
  6602. /**
  6603. * The original value of the runtime animation
  6604. */
  6605. private _originalValue;
  6606. /**
  6607. * The original blend value of the runtime animation
  6608. */
  6609. private _originalBlendValue;
  6610. /**
  6611. * The offsets cache of the runtime animation
  6612. */
  6613. private _offsetsCache;
  6614. /**
  6615. * The high limits cache of the runtime animation
  6616. */
  6617. private _highLimitsCache;
  6618. /**
  6619. * Specifies if the runtime animation has been stopped
  6620. */
  6621. private _stopped;
  6622. /**
  6623. * The blending factor of the runtime animation
  6624. */
  6625. private _blendingFactor;
  6626. /**
  6627. * The BabylonJS scene
  6628. */
  6629. private _scene;
  6630. /**
  6631. * The current value of the runtime animation
  6632. */
  6633. private _currentValue;
  6634. /** @hidden */ workValue: any;
  6635. /**
  6636. * The active target of the runtime animation
  6637. */
  6638. private _activeTarget;
  6639. /**
  6640. * The target path of the runtime animation
  6641. */
  6642. private _targetPath;
  6643. /**
  6644. * The weight of the runtime animation
  6645. */
  6646. private _weight;
  6647. /**
  6648. * The ratio offset of the runtime animation
  6649. */
  6650. private _ratioOffset;
  6651. /**
  6652. * The previous delay of the runtime animation
  6653. */
  6654. private _previousDelay;
  6655. /**
  6656. * The previous ratio of the runtime animation
  6657. */
  6658. private _previousRatio;
  6659. /**
  6660. * Gets the current frame of the runtime animation
  6661. */
  6662. readonly currentFrame: number;
  6663. /**
  6664. * Gets the weight of the runtime animation
  6665. */
  6666. readonly weight: number;
  6667. /**
  6668. * Gets the current value of the runtime animation
  6669. */
  6670. readonly currentValue: any;
  6671. /**
  6672. * Gets the target path of the runtime animation
  6673. */
  6674. readonly targetPath: string;
  6675. /**
  6676. * Gets the actual target of the runtime animation
  6677. */
  6678. readonly target: any;
  6679. /**
  6680. * Create a new RuntimeAnimation object
  6681. * @param target defines the target of the animation
  6682. * @param animation defines the source animation object
  6683. * @param scene defines the hosting scene
  6684. * @param host defines the initiating Animatable
  6685. */
  6686. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6687. /**
  6688. * Gets the animation from the runtime animation
  6689. */
  6690. readonly animation: Animation;
  6691. /**
  6692. * Resets the runtime animation to the beginning
  6693. * @param restoreOriginal defines whether to restore the target property to the original value
  6694. */
  6695. reset(restoreOriginal?: boolean): void;
  6696. /**
  6697. * Specifies if the runtime animation is stopped
  6698. * @returns Boolean specifying if the runtime animation is stopped
  6699. */
  6700. isStopped(): boolean;
  6701. /**
  6702. * Disposes of the runtime animation
  6703. */
  6704. dispose(): void;
  6705. /**
  6706. * Interpolates the animation from the current frame
  6707. * @param currentFrame The frame to interpolate the animation to
  6708. * @param repeatCount The number of times that the animation should loop
  6709. * @param loopMode The type of looping mode to use
  6710. * @param offsetValue Animation offset value
  6711. * @param highLimitValue The high limit value
  6712. * @returns The interpolated value
  6713. */
  6714. private _interpolate;
  6715. /**
  6716. * Apply the interpolated value to the target
  6717. * @param currentValue defines the value computed by the animation
  6718. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6719. */
  6720. setValue(currentValue: any, weight?: number): void;
  6721. private _setValue;
  6722. /**
  6723. * Gets the loop pmode of the runtime animation
  6724. * @returns Loop Mode
  6725. */
  6726. private _getCorrectLoopMode;
  6727. /**
  6728. * Move the current animation to a given frame
  6729. * @param frame defines the frame to move to
  6730. */
  6731. goToFrame(frame: number): void;
  6732. /**
  6733. * @hidden Internal use only
  6734. */ prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6735. /**
  6736. * Execute the current animation
  6737. * @param delay defines the delay to add to the current frame
  6738. * @param from defines the lower bound of the animation range
  6739. * @param to defines the upper bound of the animation range
  6740. * @param loop defines if the current animation must loop
  6741. * @param speedRatio defines the current speed ratio
  6742. * @param weight defines the weight of the animation (default is -1 so no weight)
  6743. * @param onLoop optional callback called when animation loops
  6744. * @returns a boolean indicating if the animation is running
  6745. */
  6746. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6747. }
  6748. }
  6749. declare module BABYLON {
  6750. /**
  6751. * Class used to store an actual running animation
  6752. */
  6753. export class Animatable {
  6754. /** defines the target object */
  6755. target: any;
  6756. /** defines the starting frame number (default is 0) */
  6757. fromFrame: number;
  6758. /** defines the ending frame number (default is 100) */
  6759. toFrame: number;
  6760. /** defines if the animation must loop (default is false) */
  6761. loopAnimation: boolean;
  6762. /** defines a callback to call when animation ends if it is not looping */
  6763. onAnimationEnd?: (() => void) | null | undefined;
  6764. /** defines a callback to call when animation loops */
  6765. onAnimationLoop?: (() => void) | null | undefined;
  6766. private _localDelayOffset;
  6767. private _pausedDelay;
  6768. private _runtimeAnimations;
  6769. private _paused;
  6770. private _scene;
  6771. private _speedRatio;
  6772. private _weight;
  6773. private _syncRoot;
  6774. /**
  6775. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  6776. * This will only apply for non looping animation (default is true)
  6777. */
  6778. disposeOnEnd: boolean;
  6779. /**
  6780. * Gets a boolean indicating if the animation has started
  6781. */
  6782. animationStarted: boolean;
  6783. /**
  6784. * Observer raised when the animation ends
  6785. */
  6786. onAnimationEndObservable: Observable<Animatable>;
  6787. /**
  6788. * Observer raised when the animation loops
  6789. */
  6790. onAnimationLoopObservable: Observable<Animatable>;
  6791. /**
  6792. * Gets the root Animatable used to synchronize and normalize animations
  6793. */
  6794. readonly syncRoot: Animatable;
  6795. /**
  6796. * Gets the current frame of the first RuntimeAnimation
  6797. * Used to synchronize Animatables
  6798. */
  6799. readonly masterFrame: number;
  6800. /**
  6801. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  6802. */
  6803. weight: number;
  6804. /**
  6805. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  6806. */
  6807. speedRatio: number;
  6808. /**
  6809. * Creates a new Animatable
  6810. * @param scene defines the hosting scene
  6811. * @param target defines the target object
  6812. * @param fromFrame defines the starting frame number (default is 0)
  6813. * @param toFrame defines the ending frame number (default is 100)
  6814. * @param loopAnimation defines if the animation must loop (default is false)
  6815. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  6816. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  6817. * @param animations defines a group of animation to add to the new Animatable
  6818. * @param onAnimationLoop defines a callback to call when animation loops
  6819. */
  6820. constructor(scene: Scene,
  6821. /** defines the target object */
  6822. target: any,
  6823. /** defines the starting frame number (default is 0) */
  6824. fromFrame?: number,
  6825. /** defines the ending frame number (default is 100) */
  6826. toFrame?: number,
  6827. /** defines if the animation must loop (default is false) */
  6828. loopAnimation?: boolean, speedRatio?: number,
  6829. /** defines a callback to call when animation ends if it is not looping */
  6830. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  6831. /** defines a callback to call when animation loops */
  6832. onAnimationLoop?: (() => void) | null | undefined);
  6833. /**
  6834. * Synchronize and normalize current Animatable with a source Animatable
  6835. * This is useful when using animation weights and when animations are not of the same length
  6836. * @param root defines the root Animatable to synchronize with
  6837. * @returns the current Animatable
  6838. */
  6839. syncWith(root: Animatable): Animatable;
  6840. /**
  6841. * Gets the list of runtime animations
  6842. * @returns an array of RuntimeAnimation
  6843. */
  6844. getAnimations(): RuntimeAnimation[];
  6845. /**
  6846. * Adds more animations to the current animatable
  6847. * @param target defines the target of the animations
  6848. * @param animations defines the new animations to add
  6849. */
  6850. appendAnimations(target: any, animations: Animation[]): void;
  6851. /**
  6852. * Gets the source animation for a specific property
  6853. * @param property defines the propertyu to look for
  6854. * @returns null or the source animation for the given property
  6855. */
  6856. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  6857. /**
  6858. * Gets the runtime animation for a specific property
  6859. * @param property defines the propertyu to look for
  6860. * @returns null or the runtime animation for the given property
  6861. */
  6862. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  6863. /**
  6864. * Resets the animatable to its original state
  6865. */
  6866. reset(): void;
  6867. /**
  6868. * Allows the animatable to blend with current running animations
  6869. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6870. * @param blendingSpeed defines the blending speed to use
  6871. */
  6872. enableBlending(blendingSpeed: number): void;
  6873. /**
  6874. * Disable animation blending
  6875. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6876. */
  6877. disableBlending(): void;
  6878. /**
  6879. * Jump directly to a given frame
  6880. * @param frame defines the frame to jump to
  6881. */
  6882. goToFrame(frame: number): void;
  6883. /**
  6884. * Pause the animation
  6885. */
  6886. pause(): void;
  6887. /**
  6888. * Restart the animation
  6889. */
  6890. restart(): void;
  6891. private _raiseOnAnimationEnd;
  6892. /**
  6893. * Stop and delete the current animation
  6894. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  6895. * @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)
  6896. */
  6897. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  6898. /**
  6899. * Wait asynchronously for the animation to end
  6900. * @returns a promise which will be fullfilled when the animation ends
  6901. */
  6902. waitAsync(): Promise<Animatable>;
  6903. /** @hidden */ animate(delay: number): boolean;
  6904. }
  6905. }
  6906. declare module BABYLON {
  6907. /**
  6908. * Class used to override all child animations of a given target
  6909. */
  6910. export class AnimationPropertiesOverride {
  6911. /**
  6912. * Gets or sets a value indicating if animation blending must be used
  6913. */
  6914. enableBlending: boolean;
  6915. /**
  6916. * Gets or sets the blending speed to use when enableBlending is true
  6917. */
  6918. blendingSpeed: number;
  6919. /**
  6920. * Gets or sets the default loop mode to use
  6921. */
  6922. loopMode: number;
  6923. }
  6924. }
  6925. declare module BABYLON {
  6926. /**
  6927. * @hidden
  6928. */
  6929. export class IntersectionInfo {
  6930. bu: Nullable<number>;
  6931. bv: Nullable<number>;
  6932. distance: number;
  6933. faceId: number;
  6934. subMeshId: number;
  6935. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6936. }
  6937. }
  6938. declare module BABYLON {
  6939. /**
  6940. * Interface used to define ActionEvent
  6941. */
  6942. export interface IActionEvent {
  6943. /** The mesh or sprite that triggered the action */
  6944. source: any;
  6945. /** The X mouse cursor position at the time of the event */
  6946. pointerX: number;
  6947. /** The Y mouse cursor position at the time of the event */
  6948. pointerY: number;
  6949. /** The mesh that is currently pointed at (can be null) */
  6950. meshUnderPointer: Nullable<AbstractMesh>;
  6951. /** the original (browser) event that triggered the ActionEvent */
  6952. sourceEvent?: any;
  6953. /** additional data for the event */
  6954. additionalData?: any;
  6955. }
  6956. /**
  6957. * ActionEvent is the event being sent when an action is triggered.
  6958. */
  6959. export class ActionEvent implements IActionEvent {
  6960. /** The mesh or sprite that triggered the action */
  6961. source: any;
  6962. /** The X mouse cursor position at the time of the event */
  6963. pointerX: number;
  6964. /** The Y mouse cursor position at the time of the event */
  6965. pointerY: number;
  6966. /** The mesh that is currently pointed at (can be null) */
  6967. meshUnderPointer: Nullable<AbstractMesh>;
  6968. /** the original (browser) event that triggered the ActionEvent */
  6969. sourceEvent?: any;
  6970. /** additional data for the event */
  6971. additionalData?: any;
  6972. /**
  6973. * Creates a new ActionEvent
  6974. * @param source The mesh or sprite that triggered the action
  6975. * @param pointerX The X mouse cursor position at the time of the event
  6976. * @param pointerY The Y mouse cursor position at the time of the event
  6977. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  6978. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  6979. * @param additionalData additional data for the event
  6980. */
  6981. constructor(
  6982. /** The mesh or sprite that triggered the action */
  6983. source: any,
  6984. /** The X mouse cursor position at the time of the event */
  6985. pointerX: number,
  6986. /** The Y mouse cursor position at the time of the event */
  6987. pointerY: number,
  6988. /** The mesh that is currently pointed at (can be null) */
  6989. meshUnderPointer: Nullable<AbstractMesh>,
  6990. /** the original (browser) event that triggered the ActionEvent */
  6991. sourceEvent?: any,
  6992. /** additional data for the event */
  6993. additionalData?: any);
  6994. /**
  6995. * Helper function to auto-create an ActionEvent from a source mesh.
  6996. * @param source The source mesh that triggered the event
  6997. * @param evt The original (browser) event
  6998. * @param additionalData additional data for the event
  6999. * @returns the new ActionEvent
  7000. */
  7001. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  7002. /**
  7003. * Helper function to auto-create an ActionEvent from a source sprite
  7004. * @param source The source sprite that triggered the event
  7005. * @param scene Scene associated with the sprite
  7006. * @param evt The original (browser) event
  7007. * @param additionalData additional data for the event
  7008. * @returns the new ActionEvent
  7009. */
  7010. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  7011. /**
  7012. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  7013. * @param scene the scene where the event occurred
  7014. * @param evt The original (browser) event
  7015. * @returns the new ActionEvent
  7016. */
  7017. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  7018. /**
  7019. * Helper function to auto-create an ActionEvent from a primitive
  7020. * @param prim defines the target primitive
  7021. * @param pointerPos defines the pointer position
  7022. * @param evt The original (browser) event
  7023. * @param additionalData additional data for the event
  7024. * @returns the new ActionEvent
  7025. */
  7026. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  7027. }
  7028. }
  7029. declare module BABYLON {
  7030. /**
  7031. * Class used to store bounding sphere information
  7032. */
  7033. export class BoundingSphere {
  7034. /**
  7035. * Gets the center of the bounding sphere in local space
  7036. */
  7037. readonly center: Vector3;
  7038. /**
  7039. * Radius of the bounding sphere in local space
  7040. */
  7041. radius: number;
  7042. /**
  7043. * Gets the center of the bounding sphere in world space
  7044. */
  7045. readonly centerWorld: Vector3;
  7046. /**
  7047. * Radius of the bounding sphere in world space
  7048. */
  7049. radiusWorld: number;
  7050. /**
  7051. * Gets the minimum vector in local space
  7052. */
  7053. readonly minimum: Vector3;
  7054. /**
  7055. * Gets the maximum vector in local space
  7056. */
  7057. readonly maximum: Vector3;
  7058. private _worldMatrix;
  7059. private static readonly TmpVector3;
  7060. /**
  7061. * Creates a new bounding sphere
  7062. * @param min defines the minimum vector (in local space)
  7063. * @param max defines the maximum vector (in local space)
  7064. * @param worldMatrix defines the new world matrix
  7065. */
  7066. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7067. /**
  7068. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7069. * @param min defines the new minimum vector (in local space)
  7070. * @param max defines the new maximum vector (in local space)
  7071. * @param worldMatrix defines the new world matrix
  7072. */
  7073. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7074. /**
  7075. * Scale the current bounding sphere by applying a scale factor
  7076. * @param factor defines the scale factor to apply
  7077. * @returns the current bounding box
  7078. */
  7079. scale(factor: number): BoundingSphere;
  7080. /**
  7081. * Gets the world matrix of the bounding box
  7082. * @returns a matrix
  7083. */
  7084. getWorldMatrix(): DeepImmutable<Matrix>;
  7085. /** @hidden */ update(worldMatrix: DeepImmutable<Matrix>): void;
  7086. /**
  7087. * Tests if the bounding sphere is intersecting the frustum planes
  7088. * @param frustumPlanes defines the frustum planes to test
  7089. * @returns true if there is an intersection
  7090. */
  7091. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7092. /**
  7093. * Tests if the bounding sphere center is in between the frustum planes.
  7094. * Used for optimistic fast inclusion.
  7095. * @param frustumPlanes defines the frustum planes to test
  7096. * @returns true if the sphere center is in between the frustum planes
  7097. */
  7098. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7099. /**
  7100. * Tests if a point is inside the bounding sphere
  7101. * @param point defines the point to test
  7102. * @returns true if the point is inside the bounding sphere
  7103. */
  7104. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7105. /**
  7106. * Checks if two sphere intersct
  7107. * @param sphere0 sphere 0
  7108. * @param sphere1 sphere 1
  7109. * @returns true if the speres intersect
  7110. */
  7111. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7112. }
  7113. }
  7114. declare module BABYLON {
  7115. /**
  7116. * Class used to store bounding box information
  7117. */
  7118. export class BoundingBox implements ICullable {
  7119. /**
  7120. * Gets the 8 vectors representing the bounding box in local space
  7121. */
  7122. readonly vectors: Vector3[];
  7123. /**
  7124. * Gets the center of the bounding box in local space
  7125. */
  7126. readonly center: Vector3;
  7127. /**
  7128. * Gets the center of the bounding box in world space
  7129. */
  7130. readonly centerWorld: Vector3;
  7131. /**
  7132. * Gets the extend size in local space
  7133. */
  7134. readonly extendSize: Vector3;
  7135. /**
  7136. * Gets the extend size in world space
  7137. */
  7138. readonly extendSizeWorld: Vector3;
  7139. /**
  7140. * Gets the OBB (object bounding box) directions
  7141. */
  7142. readonly directions: Vector3[];
  7143. /**
  7144. * Gets the 8 vectors representing the bounding box in world space
  7145. */
  7146. readonly vectorsWorld: Vector3[];
  7147. /**
  7148. * Gets the minimum vector in world space
  7149. */
  7150. readonly minimumWorld: Vector3;
  7151. /**
  7152. * Gets the maximum vector in world space
  7153. */
  7154. readonly maximumWorld: Vector3;
  7155. /**
  7156. * Gets the minimum vector in local space
  7157. */
  7158. readonly minimum: Vector3;
  7159. /**
  7160. * Gets the maximum vector in local space
  7161. */
  7162. readonly maximum: Vector3;
  7163. private _worldMatrix;
  7164. private static readonly TmpVector3;
  7165. /**
  7166. * @hidden
  7167. */ tag: number;
  7168. /**
  7169. * Creates a new bounding box
  7170. * @param min defines the minimum vector (in local space)
  7171. * @param max defines the maximum vector (in local space)
  7172. * @param worldMatrix defines the new world matrix
  7173. */
  7174. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7175. /**
  7176. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7177. * @param min defines the new minimum vector (in local space)
  7178. * @param max defines the new maximum vector (in local space)
  7179. * @param worldMatrix defines the new world matrix
  7180. */
  7181. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7182. /**
  7183. * Scale the current bounding box by applying a scale factor
  7184. * @param factor defines the scale factor to apply
  7185. * @returns the current bounding box
  7186. */
  7187. scale(factor: number): BoundingBox;
  7188. /**
  7189. * Gets the world matrix of the bounding box
  7190. * @returns a matrix
  7191. */
  7192. getWorldMatrix(): DeepImmutable<Matrix>;
  7193. /** @hidden */ update(world: DeepImmutable<Matrix>): void;
  7194. /**
  7195. * Tests if the bounding box is intersecting the frustum planes
  7196. * @param frustumPlanes defines the frustum planes to test
  7197. * @returns true if there is an intersection
  7198. */
  7199. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7200. /**
  7201. * Tests if the bounding box is entirely inside the frustum planes
  7202. * @param frustumPlanes defines the frustum planes to test
  7203. * @returns true if there is an inclusion
  7204. */
  7205. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7206. /**
  7207. * Tests if a point is inside the bounding box
  7208. * @param point defines the point to test
  7209. * @returns true if the point is inside the bounding box
  7210. */
  7211. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7212. /**
  7213. * Tests if the bounding box intersects with a bounding sphere
  7214. * @param sphere defines the sphere to test
  7215. * @returns true if there is an intersection
  7216. */
  7217. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7218. /**
  7219. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7220. * @param min defines the min vector to use
  7221. * @param max defines the max vector to use
  7222. * @returns true if there is an intersection
  7223. */
  7224. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7225. /**
  7226. * Tests if two bounding boxes are intersections
  7227. * @param box0 defines the first box to test
  7228. * @param box1 defines the second box to test
  7229. * @returns true if there is an intersection
  7230. */
  7231. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7232. /**
  7233. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7234. * @param minPoint defines the minimum vector of the bounding box
  7235. * @param maxPoint defines the maximum vector of the bounding box
  7236. * @param sphereCenter defines the sphere center
  7237. * @param sphereRadius defines the sphere radius
  7238. * @returns true if there is an intersection
  7239. */
  7240. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7241. /**
  7242. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7243. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7244. * @param frustumPlanes defines the frustum planes to test
  7245. * @return true if there is an inclusion
  7246. */
  7247. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7248. /**
  7249. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7250. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7251. * @param frustumPlanes defines the frustum planes to test
  7252. * @return true if there is an intersection
  7253. */
  7254. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7255. }
  7256. }
  7257. declare module BABYLON {
  7258. /** @hidden */
  7259. export class Collider {
  7260. /** Define if a collision was found */
  7261. collisionFound: boolean;
  7262. /**
  7263. * Define last intersection point in local space
  7264. */
  7265. intersectionPoint: Vector3;
  7266. /**
  7267. * Define last collided mesh
  7268. */
  7269. collidedMesh: Nullable<AbstractMesh>;
  7270. private _collisionPoint;
  7271. private _planeIntersectionPoint;
  7272. private _tempVector;
  7273. private _tempVector2;
  7274. private _tempVector3;
  7275. private _tempVector4;
  7276. private _edge;
  7277. private _baseToVertex;
  7278. private _destinationPoint;
  7279. private _slidePlaneNormal;
  7280. private _displacementVector;
  7281. /** @hidden */ radius: Vector3;
  7282. /** @hidden */ retry: number;
  7283. private _velocity;
  7284. private _basePoint;
  7285. private _epsilon;
  7286. /** @hidden */ velocityWorldLength: number;
  7287. /** @hidden */ basePointWorld: Vector3;
  7288. private _velocityWorld;
  7289. private _normalizedVelocity;
  7290. /** @hidden */ initialVelocity: Vector3;
  7291. /** @hidden */ initialPosition: Vector3;
  7292. private _nearestDistance;
  7293. private _collisionMask;
  7294. collisionMask: number;
  7295. /**
  7296. * Gets the plane normal used to compute the sliding response (in local space)
  7297. */
  7298. readonly slidePlaneNormal: Vector3;
  7299. /** @hidden */ initialize(source: Vector3, dir: Vector3, e: number): void;
  7300. /** @hidden */ checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7301. /** @hidden */ canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7302. /** @hidden */ testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7303. /** @hidden */ collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7304. /** @hidden */ getResponse(pos: Vector3, vel: Vector3): void;
  7305. }
  7306. }
  7307. declare module BABYLON {
  7308. /**
  7309. * Interface for cullable objects
  7310. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7311. */
  7312. export interface ICullable {
  7313. /**
  7314. * Checks if the object or part of the object is in the frustum
  7315. * @param frustumPlanes Camera near/planes
  7316. * @returns true if the object is in frustum otherwise false
  7317. */
  7318. isInFrustum(frustumPlanes: Plane[]): boolean;
  7319. /**
  7320. * Checks if a cullable object (mesh...) is in the camera frustum
  7321. * Unlike isInFrustum this cheks the full bounding box
  7322. * @param frustumPlanes Camera near/planes
  7323. * @returns true if the object is in frustum otherwise false
  7324. */
  7325. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7326. }
  7327. /**
  7328. * Info for a bounding data of a mesh
  7329. */
  7330. export class BoundingInfo implements ICullable {
  7331. /**
  7332. * Bounding box for the mesh
  7333. */
  7334. readonly boundingBox: BoundingBox;
  7335. /**
  7336. * Bounding sphere for the mesh
  7337. */
  7338. readonly boundingSphere: BoundingSphere;
  7339. private _isLocked;
  7340. private static readonly TmpVector3;
  7341. /**
  7342. * Constructs bounding info
  7343. * @param minimum min vector of the bounding box/sphere
  7344. * @param maximum max vector of the bounding box/sphere
  7345. * @param worldMatrix defines the new world matrix
  7346. */
  7347. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7348. /**
  7349. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7350. * @param min defines the new minimum vector (in local space)
  7351. * @param max defines the new maximum vector (in local space)
  7352. * @param worldMatrix defines the new world matrix
  7353. */
  7354. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7355. /**
  7356. * min vector of the bounding box/sphere
  7357. */
  7358. readonly minimum: Vector3;
  7359. /**
  7360. * max vector of the bounding box/sphere
  7361. */
  7362. readonly maximum: Vector3;
  7363. /**
  7364. * If the info is locked and won't be updated to avoid perf overhead
  7365. */
  7366. isLocked: boolean;
  7367. /**
  7368. * Updates the bounding sphere and box
  7369. * @param world world matrix to be used to update
  7370. */
  7371. update(world: DeepImmutable<Matrix>): void;
  7372. /**
  7373. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7374. * @param center New center of the bounding info
  7375. * @param extend New extend of the bounding info
  7376. * @returns the current bounding info
  7377. */
  7378. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7379. /**
  7380. * Scale the current bounding info by applying a scale factor
  7381. * @param factor defines the scale factor to apply
  7382. * @returns the current bounding info
  7383. */
  7384. scale(factor: number): BoundingInfo;
  7385. /**
  7386. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7387. * @param frustumPlanes defines the frustum to test
  7388. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7389. * @returns true if the bounding info is in the frustum planes
  7390. */
  7391. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7392. /**
  7393. * Gets the world distance between the min and max points of the bounding box
  7394. */
  7395. readonly diagonalLength: number;
  7396. /**
  7397. * Checks if a cullable object (mesh...) is in the camera frustum
  7398. * Unlike isInFrustum this cheks the full bounding box
  7399. * @param frustumPlanes Camera near/planes
  7400. * @returns true if the object is in frustum otherwise false
  7401. */
  7402. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7403. /** @hidden */ checkCollision(collider: Collider): boolean;
  7404. /**
  7405. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7406. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7407. * @param point the point to check intersection with
  7408. * @returns if the point intersects
  7409. */
  7410. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7411. /**
  7412. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7413. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7414. * @param boundingInfo the bounding info to check intersection with
  7415. * @param precise if the intersection should be done using OBB
  7416. * @returns if the bounding info intersects
  7417. */
  7418. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7419. }
  7420. }
  7421. declare module BABYLON {
  7422. /**
  7423. * Defines an array and its length.
  7424. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7425. */
  7426. export interface ISmartArrayLike<T> {
  7427. /**
  7428. * The data of the array.
  7429. */
  7430. data: Array<T>;
  7431. /**
  7432. * The active length of the array.
  7433. */
  7434. length: number;
  7435. }
  7436. /**
  7437. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7438. */
  7439. export class SmartArray<T> implements ISmartArrayLike<T> {
  7440. /**
  7441. * The full set of data from the array.
  7442. */
  7443. data: Array<T>;
  7444. /**
  7445. * The active length of the array.
  7446. */
  7447. length: number;
  7448. protected _id: number;
  7449. /**
  7450. * Instantiates a Smart Array.
  7451. * @param capacity defines the default capacity of the array.
  7452. */
  7453. constructor(capacity: number);
  7454. /**
  7455. * Pushes a value at the end of the active data.
  7456. * @param value defines the object to push in the array.
  7457. */
  7458. push(value: T): void;
  7459. /**
  7460. * Iterates over the active data and apply the lambda to them.
  7461. * @param func defines the action to apply on each value.
  7462. */
  7463. forEach(func: (content: T) => void): void;
  7464. /**
  7465. * Sorts the full sets of data.
  7466. * @param compareFn defines the comparison function to apply.
  7467. */
  7468. sort(compareFn: (a: T, b: T) => number): void;
  7469. /**
  7470. * Resets the active data to an empty array.
  7471. */
  7472. reset(): void;
  7473. /**
  7474. * Releases all the data from the array as well as the array.
  7475. */
  7476. dispose(): void;
  7477. /**
  7478. * Concats the active data with a given array.
  7479. * @param array defines the data to concatenate with.
  7480. */
  7481. concat(array: any): void;
  7482. /**
  7483. * Returns the position of a value in the active data.
  7484. * @param value defines the value to find the index for
  7485. * @returns the index if found in the active data otherwise -1
  7486. */
  7487. indexOf(value: T): number;
  7488. /**
  7489. * Returns whether an element is part of the active data.
  7490. * @param value defines the value to look for
  7491. * @returns true if found in the active data otherwise false
  7492. */
  7493. contains(value: T): boolean;
  7494. private static _GlobalId;
  7495. }
  7496. /**
  7497. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7498. * The data in this array can only be present once
  7499. */
  7500. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7501. private _duplicateId;
  7502. /**
  7503. * Pushes a value at the end of the active data.
  7504. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7505. * @param value defines the object to push in the array.
  7506. */
  7507. push(value: T): void;
  7508. /**
  7509. * Pushes a value at the end of the active data.
  7510. * If the data is already present, it won t be added again
  7511. * @param value defines the object to push in the array.
  7512. * @returns true if added false if it was already present
  7513. */
  7514. pushNoDuplicate(value: T): boolean;
  7515. /**
  7516. * Resets the active data to an empty array.
  7517. */
  7518. reset(): void;
  7519. /**
  7520. * Concats the active data with a given array.
  7521. * This ensures no dupplicate will be present in the result.
  7522. * @param array defines the data to concatenate with.
  7523. */
  7524. concatWithNoDuplicate(array: any): void;
  7525. }
  7526. }
  7527. declare module BABYLON {
  7528. /**
  7529. * Class for creating a cube texture
  7530. */
  7531. export class CubeTexture extends BaseTexture {
  7532. private _delayedOnLoad;
  7533. /**
  7534. * The url of the texture
  7535. */
  7536. url: string;
  7537. /**
  7538. * Gets or sets the center of the bounding box associated with the cube texture.
  7539. * It must define where the camera used to render the texture was set
  7540. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7541. */
  7542. boundingBoxPosition: Vector3;
  7543. private _boundingBoxSize;
  7544. /**
  7545. * Gets or sets the size of the bounding box associated with the cube texture
  7546. * When defined, the cubemap will switch to local mode
  7547. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7548. * @example https://www.babylonjs-playground.com/#RNASML
  7549. */
  7550. /**
  7551. * Returns the bounding box size
  7552. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7553. */
  7554. boundingBoxSize: Vector3;
  7555. protected _rotationY: number;
  7556. /**
  7557. * Sets texture matrix rotation angle around Y axis in radians.
  7558. */
  7559. /**
  7560. * Gets texture matrix rotation angle around Y axis radians.
  7561. */
  7562. rotationY: number;
  7563. /**
  7564. * Are mip maps generated for this texture or not.
  7565. */
  7566. readonly noMipmap: boolean;
  7567. private _noMipmap;
  7568. private _files;
  7569. private _extensions;
  7570. private _textureMatrix;
  7571. private _format;
  7572. private _createPolynomials;
  7573. /** @hidden */ prefiltered: boolean;
  7574. /**
  7575. * Creates a cube texture from an array of image urls
  7576. * @param files defines an array of image urls
  7577. * @param scene defines the hosting scene
  7578. * @param noMipmap specifies if mip maps are not used
  7579. * @returns a cube texture
  7580. */
  7581. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7582. /**
  7583. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7584. * @param url defines the url of the prefiltered texture
  7585. * @param scene defines the scene the texture is attached to
  7586. * @param forcedExtension defines the extension of the file if different from the url
  7587. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7588. * @return the prefiltered texture
  7589. */
  7590. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7591. /**
  7592. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7593. * as prefiltered data.
  7594. * @param rootUrl defines the url of the texture or the root name of the six images
  7595. * @param scene defines the scene the texture is attached to
  7596. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7597. * @param noMipmap defines if mipmaps should be created or not
  7598. * @param files defines the six files to load for the different faces
  7599. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7600. * @param onError defines a callback triggered in case of error during load
  7601. * @param format defines the internal format to use for the texture once loaded
  7602. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7603. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7604. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7605. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7606. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7607. * @return the cube texture
  7608. */
  7609. 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);
  7610. /**
  7611. * Get the current class name of the texture useful for serialization or dynamic coding.
  7612. * @returns "CubeTexture"
  7613. */
  7614. getClassName(): string;
  7615. /**
  7616. * Update the url (and optional buffer) of this texture if url was null during construction.
  7617. * @param url the url of the texture
  7618. * @param forcedExtension defines the extension to use
  7619. * @param onLoad callback called when the texture is loaded (defaults to null)
  7620. */
  7621. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7622. /**
  7623. * Delays loading of the cube texture
  7624. * @param forcedExtension defines the extension to use
  7625. */
  7626. delayLoad(forcedExtension?: string): void;
  7627. /**
  7628. * Returns the reflection texture matrix
  7629. * @returns the reflection texture matrix
  7630. */
  7631. getReflectionTextureMatrix(): Matrix;
  7632. /**
  7633. * Sets the reflection texture matrix
  7634. * @param value Reflection texture matrix
  7635. */
  7636. setReflectionTextureMatrix(value: Matrix): void;
  7637. /**
  7638. * Parses text to create a cube texture
  7639. * @param parsedTexture define the serialized text to read from
  7640. * @param scene defines the hosting scene
  7641. * @param rootUrl defines the root url of the cube texture
  7642. * @returns a cube texture
  7643. */
  7644. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7645. /**
  7646. * Makes a clone, or deep copy, of the cube texture
  7647. * @returns a new cube texture
  7648. */
  7649. clone(): CubeTexture;
  7650. }
  7651. }
  7652. declare module BABYLON {
  7653. /** @hidden */
  7654. export var postprocessVertexShader: {
  7655. name: string;
  7656. shader: string;
  7657. };
  7658. }
  7659. declare module BABYLON {
  7660. /**
  7661. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7662. * This is the base of the follow, arc rotate cameras and Free camera
  7663. * @see http://doc.babylonjs.com/features/cameras
  7664. */
  7665. export class TargetCamera extends Camera {
  7666. private static _RigCamTransformMatrix;
  7667. private static _TargetTransformMatrix;
  7668. private static _TargetFocalPoint;
  7669. /**
  7670. * Define the current direction the camera is moving to
  7671. */
  7672. cameraDirection: Vector3;
  7673. /**
  7674. * Define the current rotation the camera is rotating to
  7675. */
  7676. cameraRotation: Vector2;
  7677. /**
  7678. * When set, the up vector of the camera will be updated by the rotation of the camera
  7679. */
  7680. updateUpVectorFromRotation: boolean;
  7681. private _tmpQuaternion;
  7682. /**
  7683. * Define the current rotation of the camera
  7684. */
  7685. rotation: Vector3;
  7686. /**
  7687. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7688. */
  7689. rotationQuaternion: Quaternion;
  7690. /**
  7691. * Define the current speed of the camera
  7692. */
  7693. speed: number;
  7694. /**
  7695. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7696. * around all axis.
  7697. */
  7698. noRotationConstraint: boolean;
  7699. /**
  7700. * Define the current target of the camera as an object or a position.
  7701. */
  7702. lockedTarget: any;
  7703. /** @hidden */ currentTarget: Vector3;
  7704. /** @hidden */ initialFocalDistance: number;
  7705. /** @hidden */ viewMatrix: Matrix;
  7706. /** @hidden */ camMatrix: Matrix;
  7707. /** @hidden */ cameraTransformMatrix: Matrix;
  7708. /** @hidden */ cameraRotationMatrix: Matrix;
  7709. /** @hidden */ referencePoint: Vector3;
  7710. /** @hidden */ transformedReferencePoint: Vector3;
  7711. protected _globalCurrentTarget: Vector3;
  7712. protected _globalCurrentUpVector: Vector3;
  7713. /** @hidden */ reset: () => void;
  7714. private _defaultUp;
  7715. /**
  7716. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7717. * This is the base of the follow, arc rotate cameras and Free camera
  7718. * @see http://doc.babylonjs.com/features/cameras
  7719. * @param name Defines the name of the camera in the scene
  7720. * @param position Defines the start position of the camera in the scene
  7721. * @param scene Defines the scene the camera belongs to
  7722. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7723. */
  7724. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7725. /**
  7726. * Gets the position in front of the camera at a given distance.
  7727. * @param distance The distance from the camera we want the position to be
  7728. * @returns the position
  7729. */
  7730. getFrontPosition(distance: number): Vector3;
  7731. /** @hidden */ getLockedTargetPosition(): Nullable<Vector3>;
  7732. private _storedPosition;
  7733. private _storedRotation;
  7734. private _storedRotationQuaternion;
  7735. /**
  7736. * Store current camera state of the camera (fov, position, rotation, etc..)
  7737. * @returns the camera
  7738. */
  7739. storeState(): Camera;
  7740. /**
  7741. * Restored camera state. You must call storeState() first
  7742. * @returns whether it was successful or not
  7743. * @hidden
  7744. */ restoreStateValues(): boolean;
  7745. /** @hidden */ initCache(): void;
  7746. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  7747. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  7748. /** @hidden */ computeLocalCameraSpeed(): number;
  7749. /** @hidden */
  7750. setTarget(target: Vector3): void;
  7751. /**
  7752. * Return the current target position of the camera. This value is expressed in local space.
  7753. * @returns the target position
  7754. */
  7755. getTarget(): Vector3;
  7756. /** @hidden */ decideIfNeedsToMove(): boolean;
  7757. /** @hidden */ updatePosition(): void;
  7758. /** @hidden */ checkInputs(): void;
  7759. protected _updateCameraRotationMatrix(): void;
  7760. /**
  7761. * 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)
  7762. * @returns the current camera
  7763. */
  7764. private _rotateUpVectorWithCameraRotationMatrix;
  7765. private _cachedRotationZ;
  7766. private _cachedQuaternionRotationZ;
  7767. /** @hidden */ getViewMatrix(): Matrix;
  7768. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  7769. /**
  7770. * @hidden
  7771. */
  7772. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7773. /**
  7774. * @hidden
  7775. */ updateRigCameras(): void;
  7776. private _getRigCamPositionAndTarget;
  7777. /**
  7778. * Gets the current object class name.
  7779. * @return the class name
  7780. */
  7781. getClassName(): string;
  7782. }
  7783. }
  7784. declare module BABYLON {
  7785. /**
  7786. * @ignore
  7787. * This is a list of all the different input types that are available in the application.
  7788. * Fo instance: ArcRotateCameraGamepadInput...
  7789. */
  7790. export var CameraInputTypes: {};
  7791. /**
  7792. * This is the contract to implement in order to create a new input class.
  7793. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7794. */
  7795. export interface ICameraInput<TCamera extends Camera> {
  7796. /**
  7797. * Defines the camera the input is attached to.
  7798. */
  7799. camera: Nullable<TCamera>;
  7800. /**
  7801. * Gets the class name of the current intput.
  7802. * @returns the class name
  7803. */
  7804. getClassName(): string;
  7805. /**
  7806. * Get the friendly name associated with the input class.
  7807. * @returns the input friendly name
  7808. */
  7809. getSimpleName(): string;
  7810. /**
  7811. * Attach the input controls to a specific dom element to get the input from.
  7812. * @param element Defines the element the controls should be listened from
  7813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7814. */
  7815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7816. /**
  7817. * Detach the current controls from the specified dom element.
  7818. * @param element Defines the element to stop listening the inputs from
  7819. */
  7820. detachControl(element: Nullable<HTMLElement>): void;
  7821. /**
  7822. * Update the current camera state depending on the inputs that have been used this frame.
  7823. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7824. */
  7825. checkInputs?: () => void;
  7826. }
  7827. /**
  7828. * Represents a map of input types to input instance or input index to input instance.
  7829. */
  7830. export interface CameraInputsMap<TCamera extends Camera> {
  7831. /**
  7832. * Accessor to the input by input type.
  7833. */
  7834. [name: string]: ICameraInput<TCamera>;
  7835. /**
  7836. * Accessor to the input by input index.
  7837. */
  7838. [idx: number]: ICameraInput<TCamera>;
  7839. }
  7840. /**
  7841. * This represents the input manager used within a camera.
  7842. * It helps dealing with all the different kind of input attached to a camera.
  7843. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7844. */
  7845. export class CameraInputsManager<TCamera extends Camera> {
  7846. /**
  7847. * Defines the list of inputs attahed to the camera.
  7848. */
  7849. attached: CameraInputsMap<TCamera>;
  7850. /**
  7851. * Defines the dom element the camera is collecting inputs from.
  7852. * This is null if the controls have not been attached.
  7853. */
  7854. attachedElement: Nullable<HTMLElement>;
  7855. /**
  7856. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7857. */
  7858. noPreventDefault: boolean;
  7859. /**
  7860. * Defined the camera the input manager belongs to.
  7861. */
  7862. camera: TCamera;
  7863. /**
  7864. * Update the current camera state depending on the inputs that have been used this frame.
  7865. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7866. */
  7867. checkInputs: () => void;
  7868. /**
  7869. * Instantiate a new Camera Input Manager.
  7870. * @param camera Defines the camera the input manager blongs to
  7871. */
  7872. constructor(camera: TCamera);
  7873. /**
  7874. * Add an input method to a camera
  7875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7876. * @param input camera input method
  7877. */
  7878. add(input: ICameraInput<TCamera>): void;
  7879. /**
  7880. * Remove a specific input method from a camera
  7881. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7882. * @param inputToRemove camera input method
  7883. */
  7884. remove(inputToRemove: ICameraInput<TCamera>): void;
  7885. /**
  7886. * Remove a specific input type from a camera
  7887. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7888. * @param inputType the type of the input to remove
  7889. */
  7890. removeByType(inputType: string): void;
  7891. private _addCheckInputs;
  7892. /**
  7893. * Attach the input controls to the currently attached dom element to listen the events from.
  7894. * @param input Defines the input to attach
  7895. */
  7896. attachInput(input: ICameraInput<TCamera>): void;
  7897. /**
  7898. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7899. * @param element Defines the dom element to collect the events from
  7900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7901. */
  7902. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7903. /**
  7904. * Detach the current manager inputs controls from a specific dom element.
  7905. * @param element Defines the dom element to collect the events from
  7906. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7907. */
  7908. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7909. /**
  7910. * Rebuild the dynamic inputCheck function from the current list of
  7911. * defined inputs in the manager.
  7912. */
  7913. rebuildInputCheck(): void;
  7914. /**
  7915. * Remove all attached input methods from a camera
  7916. */
  7917. clear(): void;
  7918. /**
  7919. * Serialize the current input manager attached to a camera.
  7920. * This ensures than once parsed,
  7921. * the input associated to the camera will be identical to the current ones
  7922. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7923. */
  7924. serialize(serializedCamera: any): void;
  7925. /**
  7926. * Parses an input manager serialized JSON to restore the previous list of inputs
  7927. * and states associated to a camera.
  7928. * @param parsedCamera Defines the JSON to parse
  7929. */
  7930. parse(parsedCamera: any): void;
  7931. }
  7932. }
  7933. declare module BABYLON {
  7934. /**
  7935. * Gather the list of keyboard event types as constants.
  7936. */
  7937. export class KeyboardEventTypes {
  7938. /**
  7939. * The keydown event is fired when a key becomes active (pressed).
  7940. */
  7941. static readonly KEYDOWN: number;
  7942. /**
  7943. * The keyup event is fired when a key has been released.
  7944. */
  7945. static readonly KEYUP: number;
  7946. }
  7947. /**
  7948. * This class is used to store keyboard related info for the onKeyboardObservable event.
  7949. */
  7950. export class KeyboardInfo {
  7951. /**
  7952. * Defines the type of event (KeyboardEventTypes)
  7953. */
  7954. type: number;
  7955. /**
  7956. * Defines the related dom event
  7957. */
  7958. event: KeyboardEvent;
  7959. /**
  7960. * Instantiates a new keyboard info.
  7961. * This class is used to store keyboard related info for the onKeyboardObservable event.
  7962. * @param type Defines the type of event (KeyboardEventTypes)
  7963. * @param event Defines the related dom event
  7964. */
  7965. constructor(
  7966. /**
  7967. * Defines the type of event (KeyboardEventTypes)
  7968. */
  7969. type: number,
  7970. /**
  7971. * Defines the related dom event
  7972. */
  7973. event: KeyboardEvent);
  7974. }
  7975. /**
  7976. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  7977. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  7978. */
  7979. export class KeyboardInfoPre extends KeyboardInfo {
  7980. /**
  7981. * Defines the type of event (KeyboardEventTypes)
  7982. */
  7983. type: number;
  7984. /**
  7985. * Defines the related dom event
  7986. */
  7987. event: KeyboardEvent;
  7988. /**
  7989. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  7990. */
  7991. skipOnPointerObservable: boolean;
  7992. /**
  7993. * Instantiates a new keyboard pre info.
  7994. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  7995. * @param type Defines the type of event (KeyboardEventTypes)
  7996. * @param event Defines the related dom event
  7997. */
  7998. constructor(
  7999. /**
  8000. * Defines the type of event (KeyboardEventTypes)
  8001. */
  8002. type: number,
  8003. /**
  8004. * Defines the related dom event
  8005. */
  8006. event: KeyboardEvent);
  8007. }
  8008. }
  8009. declare module BABYLON {
  8010. /**
  8011. * Manage the keyboard inputs to control the movement of a free camera.
  8012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8013. */
  8014. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8015. /**
  8016. * Defines the camera the input is attached to.
  8017. */
  8018. camera: FreeCamera;
  8019. /**
  8020. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8021. */
  8022. keysUp: number[];
  8023. /**
  8024. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8025. */
  8026. keysDown: number[];
  8027. /**
  8028. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8029. */
  8030. keysLeft: number[];
  8031. /**
  8032. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8033. */
  8034. keysRight: number[];
  8035. private _keys;
  8036. private _onCanvasBlurObserver;
  8037. private _onKeyboardObserver;
  8038. private _engine;
  8039. private _scene;
  8040. /**
  8041. * Attach the input controls to a specific dom element to get the input from.
  8042. * @param element Defines the element the controls should be listened from
  8043. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8044. */
  8045. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8046. /**
  8047. * Detach the current controls from the specified dom element.
  8048. * @param element Defines the element to stop listening the inputs from
  8049. */
  8050. detachControl(element: Nullable<HTMLElement>): void;
  8051. /**
  8052. * Update the current camera state depending on the inputs that have been used this frame.
  8053. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8054. */
  8055. checkInputs(): void;
  8056. /**
  8057. * Gets the class name of the current intput.
  8058. * @returns the class name
  8059. */
  8060. getClassName(): string;
  8061. /** @hidden */ onLostFocus(): void;
  8062. /**
  8063. * Get the friendly name associated with the input class.
  8064. * @returns the input friendly name
  8065. */
  8066. getSimpleName(): string;
  8067. }
  8068. }
  8069. declare module BABYLON {
  8070. /**
  8071. * Gather the list of pointer event types as constants.
  8072. */
  8073. export class PointerEventTypes {
  8074. /**
  8075. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  8076. */
  8077. static readonly POINTERDOWN: number;
  8078. /**
  8079. * The pointerup event is fired when a pointer is no longer active.
  8080. */
  8081. static readonly POINTERUP: number;
  8082. /**
  8083. * The pointermove event is fired when a pointer changes coordinates.
  8084. */
  8085. static readonly POINTERMOVE: number;
  8086. /**
  8087. * The pointerwheel event is fired when a mouse wheel has been rotated.
  8088. */
  8089. static readonly POINTERWHEEL: number;
  8090. /**
  8091. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  8092. */
  8093. static readonly POINTERPICK: number;
  8094. /**
  8095. * The pointertap event is fired when a the object has been touched and released without drag.
  8096. */
  8097. static readonly POINTERTAP: number;
  8098. /**
  8099. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  8100. */
  8101. static readonly POINTERDOUBLETAP: number;
  8102. }
  8103. /**
  8104. * Base class of pointer info types.
  8105. */
  8106. export class PointerInfoBase {
  8107. /**
  8108. * Defines the type of event (PointerEventTypes)
  8109. */
  8110. type: number;
  8111. /**
  8112. * Defines the related dom event
  8113. */
  8114. event: PointerEvent | MouseWheelEvent;
  8115. /**
  8116. * Instantiates the base class of pointers info.
  8117. * @param type Defines the type of event (PointerEventTypes)
  8118. * @param event Defines the related dom event
  8119. */
  8120. constructor(
  8121. /**
  8122. * Defines the type of event (PointerEventTypes)
  8123. */
  8124. type: number,
  8125. /**
  8126. * Defines the related dom event
  8127. */
  8128. event: PointerEvent | MouseWheelEvent);
  8129. }
  8130. /**
  8131. * This class is used to store pointer related info for the onPrePointerObservable event.
  8132. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  8133. */
  8134. export class PointerInfoPre extends PointerInfoBase {
  8135. /**
  8136. * Ray from a pointer if availible (eg. 6dof controller)
  8137. */
  8138. ray: Nullable<Ray>;
  8139. /**
  8140. * Defines the local position of the pointer on the canvas.
  8141. */
  8142. localPosition: Vector2;
  8143. /**
  8144. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  8145. */
  8146. skipOnPointerObservable: boolean;
  8147. /**
  8148. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  8149. * @param type Defines the type of event (PointerEventTypes)
  8150. * @param event Defines the related dom event
  8151. * @param localX Defines the local x coordinates of the pointer when the event occured
  8152. * @param localY Defines the local y coordinates of the pointer when the event occured
  8153. */
  8154. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  8155. }
  8156. /**
  8157. * This type contains all the data related to a pointer event in Babylon.js.
  8158. * 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.
  8159. */
  8160. export class PointerInfo extends PointerInfoBase {
  8161. /**
  8162. * Defines the picking info associated to the info (if any)\
  8163. */
  8164. pickInfo: Nullable<PickingInfo>;
  8165. /**
  8166. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  8167. * @param type Defines the type of event (PointerEventTypes)
  8168. * @param event Defines the related dom event
  8169. * @param pickInfo Defines the picking info associated to the info (if any)\
  8170. */
  8171. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  8172. /**
  8173. * Defines the picking info associated to the info (if any)\
  8174. */
  8175. pickInfo: Nullable<PickingInfo>);
  8176. }
  8177. }
  8178. declare module BABYLON {
  8179. /**
  8180. * Manage the mouse inputs to control the movement of a free camera.
  8181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8182. */
  8183. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  8184. /**
  8185. * Define if touch is enabled in the mouse input
  8186. */
  8187. touchEnabled: boolean;
  8188. /**
  8189. * Defines the camera the input is attached to.
  8190. */
  8191. camera: FreeCamera;
  8192. /**
  8193. * Defines the buttons associated with the input to handle camera move.
  8194. */
  8195. buttons: number[];
  8196. /**
  8197. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  8198. */
  8199. angularSensibility: number;
  8200. private _pointerInput;
  8201. private _onMouseMove;
  8202. private _observer;
  8203. private previousPosition;
  8204. /**
  8205. * Manage the mouse inputs to control the movement of a free camera.
  8206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8207. * @param touchEnabled Defines if touch is enabled or not
  8208. */
  8209. constructor(
  8210. /**
  8211. * Define if touch is enabled in the mouse input
  8212. */
  8213. touchEnabled?: boolean);
  8214. /**
  8215. * Attach the input controls to a specific dom element to get the input from.
  8216. * @param element Defines the element the controls should be listened from
  8217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8218. */
  8219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8220. /**
  8221. * Detach the current controls from the specified dom element.
  8222. * @param element Defines the element to stop listening the inputs from
  8223. */
  8224. detachControl(element: Nullable<HTMLElement>): void;
  8225. /**
  8226. * Gets the class name of the current intput.
  8227. * @returns the class name
  8228. */
  8229. getClassName(): string;
  8230. /**
  8231. * Get the friendly name associated with the input class.
  8232. * @returns the input friendly name
  8233. */
  8234. getSimpleName(): string;
  8235. }
  8236. }
  8237. declare module BABYLON {
  8238. /**
  8239. * Manage the touch inputs to control the movement of a free camera.
  8240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8241. */
  8242. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  8243. /**
  8244. * Defines the camera the input is attached to.
  8245. */
  8246. camera: FreeCamera;
  8247. /**
  8248. * Defines the touch sensibility for rotation.
  8249. * The higher the faster.
  8250. */
  8251. touchAngularSensibility: number;
  8252. /**
  8253. * Defines the touch sensibility for move.
  8254. * The higher the faster.
  8255. */
  8256. touchMoveSensibility: number;
  8257. private _offsetX;
  8258. private _offsetY;
  8259. private _pointerPressed;
  8260. private _pointerInput;
  8261. private _observer;
  8262. private _onLostFocus;
  8263. /**
  8264. * Attach the input controls to a specific dom element to get the input from.
  8265. * @param element Defines the element the controls should be listened from
  8266. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8267. */
  8268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8269. /**
  8270. * Detach the current controls from the specified dom element.
  8271. * @param element Defines the element to stop listening the inputs from
  8272. */
  8273. detachControl(element: Nullable<HTMLElement>): void;
  8274. /**
  8275. * Update the current camera state depending on the inputs that have been used this frame.
  8276. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8277. */
  8278. checkInputs(): void;
  8279. /**
  8280. * Gets the class name of the current intput.
  8281. * @returns the class name
  8282. */
  8283. getClassName(): string;
  8284. /**
  8285. * Get the friendly name associated with the input class.
  8286. * @returns the input friendly name
  8287. */
  8288. getSimpleName(): string;
  8289. }
  8290. }
  8291. declare module BABYLON {
  8292. /**
  8293. * Default Inputs manager for the FreeCamera.
  8294. * It groups all the default supported inputs for ease of use.
  8295. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8296. */
  8297. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8298. /**
  8299. * Instantiates a new FreeCameraInputsManager.
  8300. * @param camera Defines the camera the inputs belong to
  8301. */
  8302. constructor(camera: FreeCamera);
  8303. /**
  8304. * Add keyboard input support to the input manager.
  8305. * @returns the current input manager
  8306. */
  8307. addKeyboard(): FreeCameraInputsManager;
  8308. /**
  8309. * Add mouse input support to the input manager.
  8310. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8311. * @returns the current input manager
  8312. */
  8313. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8314. /**
  8315. * Add touch input support to the input manager.
  8316. * @returns the current input manager
  8317. */
  8318. addTouch(): FreeCameraInputsManager;
  8319. }
  8320. }
  8321. declare module BABYLON {
  8322. /**
  8323. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8324. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8325. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8326. */
  8327. export class FreeCamera extends TargetCamera {
  8328. /**
  8329. * Define the collision ellipsoid of the camera.
  8330. * This is helpful to simulate a camera body like the player body around the camera
  8331. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8332. */
  8333. ellipsoid: Vector3;
  8334. /**
  8335. * Define an offset for the position of the ellipsoid around the camera.
  8336. * This can be helpful to determine the center of the body near the gravity center of the body
  8337. * instead of its head.
  8338. */
  8339. ellipsoidOffset: Vector3;
  8340. /**
  8341. * Enable or disable collisions of the camera with the rest of the scene objects.
  8342. */
  8343. checkCollisions: boolean;
  8344. /**
  8345. * Enable or disable gravity on the camera.
  8346. */
  8347. applyGravity: boolean;
  8348. /**
  8349. * Define the input manager associated to the camera.
  8350. */
  8351. inputs: FreeCameraInputsManager;
  8352. /**
  8353. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8354. * Higher values reduce sensitivity.
  8355. */
  8356. /**
  8357. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8358. * Higher values reduce sensitivity.
  8359. */
  8360. angularSensibility: number;
  8361. /**
  8362. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8363. */
  8364. keysUp: number[];
  8365. /**
  8366. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8367. */
  8368. keysDown: number[];
  8369. /**
  8370. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8371. */
  8372. keysLeft: number[];
  8373. /**
  8374. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8375. */
  8376. keysRight: number[];
  8377. /**
  8378. * Event raised when the camera collide with a mesh in the scene.
  8379. */
  8380. onCollide: (collidedMesh: AbstractMesh) => void;
  8381. private _collider;
  8382. private _needMoveForGravity;
  8383. private _oldPosition;
  8384. private _diffPosition;
  8385. private _newPosition;
  8386. /** @hidden */ localDirection: Vector3;
  8387. /** @hidden */ transformedDirection: Vector3;
  8388. /**
  8389. * Instantiates a Free Camera.
  8390. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8391. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8392. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8393. * @param name Define the name of the camera in the scene
  8394. * @param position Define the start position of the camera in the scene
  8395. * @param scene Define the scene the camera belongs to
  8396. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8397. */
  8398. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8399. /**
  8400. * Attached controls to the current camera.
  8401. * @param element Defines the element the controls should be listened from
  8402. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8403. */
  8404. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8405. /**
  8406. * Detach the current controls from the camera.
  8407. * The camera will stop reacting to inputs.
  8408. * @param element Defines the element to stop listening the inputs from
  8409. */
  8410. detachControl(element: HTMLElement): void;
  8411. private _collisionMask;
  8412. /**
  8413. * Define a collision mask to limit the list of object the camera can collide with
  8414. */
  8415. collisionMask: number;
  8416. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  8417. private _onCollisionPositionChange;
  8418. /** @hidden */ checkInputs(): void;
  8419. /** @hidden */ decideIfNeedsToMove(): boolean;
  8420. /** @hidden */ updatePosition(): void;
  8421. /**
  8422. * Destroy the camera and release the current resources hold by it.
  8423. */
  8424. dispose(): void;
  8425. /**
  8426. * Gets the current object class name.
  8427. * @return the class name
  8428. */
  8429. getClassName(): string;
  8430. }
  8431. }
  8432. declare module BABYLON {
  8433. /**
  8434. * Represents a gamepad control stick position
  8435. */
  8436. export class StickValues {
  8437. /**
  8438. * The x component of the control stick
  8439. */
  8440. x: number;
  8441. /**
  8442. * The y component of the control stick
  8443. */
  8444. y: number;
  8445. /**
  8446. * Initializes the gamepad x and y control stick values
  8447. * @param x The x component of the gamepad control stick value
  8448. * @param y The y component of the gamepad control stick value
  8449. */
  8450. constructor(
  8451. /**
  8452. * The x component of the control stick
  8453. */
  8454. x: number,
  8455. /**
  8456. * The y component of the control stick
  8457. */
  8458. y: number);
  8459. }
  8460. /**
  8461. * An interface which manages callbacks for gamepad button changes
  8462. */
  8463. export interface GamepadButtonChanges {
  8464. /**
  8465. * Called when a gamepad has been changed
  8466. */
  8467. changed: boolean;
  8468. /**
  8469. * Called when a gamepad press event has been triggered
  8470. */
  8471. pressChanged: boolean;
  8472. /**
  8473. * Called when a touch event has been triggered
  8474. */
  8475. touchChanged: boolean;
  8476. /**
  8477. * Called when a value has changed
  8478. */
  8479. valueChanged: boolean;
  8480. }
  8481. /**
  8482. * Represents a gamepad
  8483. */
  8484. export class Gamepad {
  8485. /**
  8486. * The id of the gamepad
  8487. */
  8488. id: string;
  8489. /**
  8490. * The index of the gamepad
  8491. */
  8492. index: number;
  8493. /**
  8494. * The browser gamepad
  8495. */
  8496. browserGamepad: any;
  8497. /**
  8498. * Specifies what type of gamepad this represents
  8499. */
  8500. type: number;
  8501. private _leftStick;
  8502. private _rightStick;
  8503. /** @hidden */ isConnected: boolean;
  8504. private _leftStickAxisX;
  8505. private _leftStickAxisY;
  8506. private _rightStickAxisX;
  8507. private _rightStickAxisY;
  8508. /**
  8509. * Triggered when the left control stick has been changed
  8510. */
  8511. private _onleftstickchanged;
  8512. /**
  8513. * Triggered when the right control stick has been changed
  8514. */
  8515. private _onrightstickchanged;
  8516. /**
  8517. * Represents a gamepad controller
  8518. */
  8519. static GAMEPAD: number;
  8520. /**
  8521. * Represents a generic controller
  8522. */
  8523. static GENERIC: number;
  8524. /**
  8525. * Represents an XBox controller
  8526. */
  8527. static XBOX: number;
  8528. /**
  8529. * Represents a pose-enabled controller
  8530. */
  8531. static POSE_ENABLED: number;
  8532. /**
  8533. * Specifies whether the left control stick should be Y-inverted
  8534. */
  8535. protected _invertLeftStickY: boolean;
  8536. /**
  8537. * Specifies if the gamepad has been connected
  8538. */
  8539. readonly isConnected: boolean;
  8540. /**
  8541. * Initializes the gamepad
  8542. * @param id The id of the gamepad
  8543. * @param index The index of the gamepad
  8544. * @param browserGamepad The browser gamepad
  8545. * @param leftStickX The x component of the left joystick
  8546. * @param leftStickY The y component of the left joystick
  8547. * @param rightStickX The x component of the right joystick
  8548. * @param rightStickY The y component of the right joystick
  8549. */
  8550. constructor(
  8551. /**
  8552. * The id of the gamepad
  8553. */
  8554. id: string,
  8555. /**
  8556. * The index of the gamepad
  8557. */
  8558. index: number,
  8559. /**
  8560. * The browser gamepad
  8561. */
  8562. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  8563. /**
  8564. * Callback triggered when the left joystick has changed
  8565. * @param callback
  8566. */
  8567. onleftstickchanged(callback: (values: StickValues) => void): void;
  8568. /**
  8569. * Callback triggered when the right joystick has changed
  8570. * @param callback
  8571. */
  8572. onrightstickchanged(callback: (values: StickValues) => void): void;
  8573. /**
  8574. * Gets the left joystick
  8575. */
  8576. /**
  8577. * Sets the left joystick values
  8578. */
  8579. leftStick: StickValues;
  8580. /**
  8581. * Gets the right joystick
  8582. */
  8583. /**
  8584. * Sets the right joystick value
  8585. */
  8586. rightStick: StickValues;
  8587. /**
  8588. * Updates the gamepad joystick positions
  8589. */
  8590. update(): void;
  8591. /**
  8592. * Disposes the gamepad
  8593. */
  8594. dispose(): void;
  8595. }
  8596. /**
  8597. * Represents a generic gamepad
  8598. */
  8599. export class GenericPad extends Gamepad {
  8600. private _buttons;
  8601. private _onbuttondown;
  8602. private _onbuttonup;
  8603. /**
  8604. * Observable triggered when a button has been pressed
  8605. */
  8606. onButtonDownObservable: Observable<number>;
  8607. /**
  8608. * Observable triggered when a button has been released
  8609. */
  8610. onButtonUpObservable: Observable<number>;
  8611. /**
  8612. * Callback triggered when a button has been pressed
  8613. * @param callback Called when a button has been pressed
  8614. */
  8615. onbuttondown(callback: (buttonPressed: number) => void): void;
  8616. /**
  8617. * Callback triggered when a button has been released
  8618. * @param callback Called when a button has been released
  8619. */
  8620. onbuttonup(callback: (buttonReleased: number) => void): void;
  8621. /**
  8622. * Initializes the generic gamepad
  8623. * @param id The id of the generic gamepad
  8624. * @param index The index of the generic gamepad
  8625. * @param browserGamepad The browser gamepad
  8626. */
  8627. constructor(id: string, index: number, browserGamepad: any);
  8628. private _setButtonValue;
  8629. /**
  8630. * Updates the generic gamepad
  8631. */
  8632. update(): void;
  8633. /**
  8634. * Disposes the generic gamepad
  8635. */
  8636. dispose(): void;
  8637. }
  8638. }
  8639. declare module BABYLON {
  8640. /**
  8641. * Raw texture can help creating a texture directly from an array of data.
  8642. * This can be super useful if you either get the data from an uncompressed source or
  8643. * if you wish to create your texture pixel by pixel.
  8644. */
  8645. export class RawTexture extends Texture {
  8646. /**
  8647. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8648. */
  8649. format: number;
  8650. private _engine;
  8651. /**
  8652. * Instantiates a new RawTexture.
  8653. * Raw texture can help creating a texture directly from an array of data.
  8654. * This can be super useful if you either get the data from an uncompressed source or
  8655. * if you wish to create your texture pixel by pixel.
  8656. * @param data define the array of data to use to create the texture
  8657. * @param width define the width of the texture
  8658. * @param height define the height of the texture
  8659. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8660. * @param scene define the scene the texture belongs to
  8661. * @param generateMipMaps define whether mip maps should be generated or not
  8662. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8663. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8664. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8665. */
  8666. constructor(data: ArrayBufferView, width: number, height: number,
  8667. /**
  8668. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8669. */
  8670. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  8671. /**
  8672. * Updates the texture underlying data.
  8673. * @param data Define the new data of the texture
  8674. */
  8675. update(data: ArrayBufferView): void;
  8676. /**
  8677. * Creates a luminance texture from some data.
  8678. * @param data Define the texture data
  8679. * @param width Define the width of the texture
  8680. * @param height Define the height of the texture
  8681. * @param scene Define the scene the texture belongs to
  8682. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8683. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8684. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8685. * @returns the luminance texture
  8686. */
  8687. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8688. /**
  8689. * Creates a luminance alpha texture from some data.
  8690. * @param data Define the texture data
  8691. * @param width Define the width of the texture
  8692. * @param height Define the height of the texture
  8693. * @param scene Define the scene the texture belongs to
  8694. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8695. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8696. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8697. * @returns the luminance alpha texture
  8698. */
  8699. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8700. /**
  8701. * Creates an alpha texture from some data.
  8702. * @param data Define the texture data
  8703. * @param width Define the width of the texture
  8704. * @param height Define the height of the texture
  8705. * @param scene Define the scene the texture belongs to
  8706. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8707. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8708. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8709. * @returns the alpha texture
  8710. */
  8711. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8712. /**
  8713. * Creates a RGB texture from some data.
  8714. * @param data Define the texture data
  8715. * @param width Define the width of the texture
  8716. * @param height Define the height of the texture
  8717. * @param scene Define the scene the texture belongs to
  8718. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8719. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8720. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8721. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8722. * @returns the RGB alpha texture
  8723. */
  8724. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8725. /**
  8726. * Creates a RGBA texture from some data.
  8727. * @param data Define the texture data
  8728. * @param width Define the width of the texture
  8729. * @param height Define the height of the texture
  8730. * @param scene Define the scene the texture belongs to
  8731. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8732. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8733. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8734. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8735. * @returns the RGBA texture
  8736. */
  8737. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8738. /**
  8739. * Creates a R texture from some data.
  8740. * @param data Define the texture data
  8741. * @param width Define the width of the texture
  8742. * @param height Define the height of the texture
  8743. * @param scene Define the scene the texture belongs to
  8744. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8745. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8746. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8747. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8748. * @returns the R texture
  8749. */
  8750. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8751. }
  8752. }
  8753. declare module BABYLON {
  8754. /**
  8755. * Class used to handle skinning animations
  8756. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8757. */
  8758. export class Skeleton implements IAnimatable {
  8759. /** defines the skeleton name */
  8760. name: string;
  8761. /** defines the skeleton Id */
  8762. id: string;
  8763. /**
  8764. * Defines the list of child bones
  8765. */
  8766. bones: Bone[];
  8767. /**
  8768. * Defines an estimate of the dimension of the skeleton at rest
  8769. */
  8770. dimensionsAtRest: Vector3;
  8771. /**
  8772. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  8773. */
  8774. needInitialSkinMatrix: boolean;
  8775. /**
  8776. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  8777. */
  8778. overrideMesh: Nullable<AbstractMesh>;
  8779. /**
  8780. * Gets the list of animations attached to this skeleton
  8781. */
  8782. animations: Array<Animation>;
  8783. private _scene;
  8784. private _isDirty;
  8785. private _transformMatrices;
  8786. private _transformMatrixTexture;
  8787. private _meshesWithPoseMatrix;
  8788. private _animatables;
  8789. private _identity;
  8790. private _synchronizedWithMesh;
  8791. private _ranges;
  8792. private _lastAbsoluteTransformsUpdateId;
  8793. private _canUseTextureForBones;
  8794. /** @hidden */ numBonesWithLinkedTransformNode: number;
  8795. /**
  8796. * Specifies if the skeleton should be serialized
  8797. */
  8798. doNotSerialize: boolean;
  8799. /**
  8800. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  8801. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  8802. */
  8803. useTextureToStoreBoneMatrices: boolean;
  8804. private _animationPropertiesOverride;
  8805. /**
  8806. * Gets or sets the animation properties override
  8807. */
  8808. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8809. /**
  8810. * An observable triggered before computing the skeleton's matrices
  8811. */
  8812. onBeforeComputeObservable: Observable<Skeleton>;
  8813. /**
  8814. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  8815. */
  8816. readonly isUsingTextureForMatrices: boolean;
  8817. /**
  8818. * Creates a new skeleton
  8819. * @param name defines the skeleton name
  8820. * @param id defines the skeleton Id
  8821. * @param scene defines the hosting scene
  8822. */
  8823. constructor(
  8824. /** defines the skeleton name */
  8825. name: string,
  8826. /** defines the skeleton Id */
  8827. id: string, scene: Scene);
  8828. /**
  8829. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  8830. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  8831. * @returns a Float32Array containing matrices data
  8832. */
  8833. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  8834. /**
  8835. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  8836. * @returns a raw texture containing the data
  8837. */
  8838. getTransformMatrixTexture(): Nullable<RawTexture>;
  8839. /**
  8840. * Gets the current hosting scene
  8841. * @returns a scene object
  8842. */
  8843. getScene(): Scene;
  8844. /**
  8845. * Gets a string representing the current skeleton data
  8846. * @param fullDetails defines a boolean indicating if we want a verbose version
  8847. * @returns a string representing the current skeleton data
  8848. */
  8849. toString(fullDetails?: boolean): string;
  8850. /**
  8851. * Get bone's index searching by name
  8852. * @param name defines bone's name to search for
  8853. * @return the indice of the bone. Returns -1 if not found
  8854. */
  8855. getBoneIndexByName(name: string): number;
  8856. /**
  8857. * Creater a new animation range
  8858. * @param name defines the name of the range
  8859. * @param from defines the start key
  8860. * @param to defines the end key
  8861. */
  8862. createAnimationRange(name: string, from: number, to: number): void;
  8863. /**
  8864. * Delete a specific animation range
  8865. * @param name defines the name of the range
  8866. * @param deleteFrames defines if frames must be removed as well
  8867. */
  8868. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  8869. /**
  8870. * Gets a specific animation range
  8871. * @param name defines the name of the range to look for
  8872. * @returns the requested animation range or null if not found
  8873. */
  8874. getAnimationRange(name: string): Nullable<AnimationRange>;
  8875. /**
  8876. * Gets the list of all animation ranges defined on this skeleton
  8877. * @returns an array
  8878. */
  8879. getAnimationRanges(): Nullable<AnimationRange>[];
  8880. /**
  8881. * Copy animation range from a source skeleton.
  8882. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  8883. * @param source defines the source skeleton
  8884. * @param name defines the name of the range to copy
  8885. * @param rescaleAsRequired defines if rescaling must be applied if required
  8886. * @returns true if operation was successful
  8887. */
  8888. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  8889. /**
  8890. * Forces the skeleton to go to rest pose
  8891. */
  8892. returnToRest(): void;
  8893. private _getHighestAnimationFrame;
  8894. /**
  8895. * Begin a specific animation range
  8896. * @param name defines the name of the range to start
  8897. * @param loop defines if looping must be turned on (false by default)
  8898. * @param speedRatio defines the speed ratio to apply (1 by default)
  8899. * @param onAnimationEnd defines a callback which will be called when animation will end
  8900. * @returns a new animatable
  8901. */
  8902. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  8903. /** @hidden */ markAsDirty(): void;
  8904. /** @hidden */ registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  8905. /** @hidden */ unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  8906. private _computeTransformMatrices;
  8907. /**
  8908. * Build all resources required to render a skeleton
  8909. */
  8910. prepare(): void;
  8911. /**
  8912. * Gets the list of animatables currently running for this skeleton
  8913. * @returns an array of animatables
  8914. */
  8915. getAnimatables(): IAnimatable[];
  8916. /**
  8917. * Clone the current skeleton
  8918. * @param name defines the name of the new skeleton
  8919. * @param id defines the id of the enw skeleton
  8920. * @returns the new skeleton
  8921. */
  8922. clone(name: string, id: string): Skeleton;
  8923. /**
  8924. * Enable animation blending for this skeleton
  8925. * @param blendingSpeed defines the blending speed to apply
  8926. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  8927. */
  8928. enableBlending(blendingSpeed?: number): void;
  8929. /**
  8930. * Releases all resources associated with the current skeleton
  8931. */
  8932. dispose(): void;
  8933. /**
  8934. * Serialize the skeleton in a JSON object
  8935. * @returns a JSON object
  8936. */
  8937. serialize(): any;
  8938. /**
  8939. * Creates a new skeleton from serialized data
  8940. * @param parsedSkeleton defines the serialized data
  8941. * @param scene defines the hosting scene
  8942. * @returns a new skeleton
  8943. */
  8944. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  8945. /**
  8946. * Compute all node absolute transforms
  8947. * @param forceUpdate defines if computation must be done even if cache is up to date
  8948. */
  8949. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  8950. /**
  8951. * Gets the root pose matrix
  8952. * @returns a matrix
  8953. */
  8954. getPoseMatrix(): Nullable<Matrix>;
  8955. /**
  8956. * Sorts bones per internal index
  8957. */
  8958. sortBones(): void;
  8959. private _sortBones;
  8960. }
  8961. }
  8962. declare module BABYLON {
  8963. /**
  8964. * Class used to store bone information
  8965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8966. */
  8967. export class Bone extends Node {
  8968. /**
  8969. * defines the bone name
  8970. */
  8971. name: string;
  8972. private static _tmpVecs;
  8973. private static _tmpQuat;
  8974. private static _tmpMats;
  8975. /**
  8976. * Gets the list of child bones
  8977. */
  8978. children: Bone[];
  8979. /** Gets the animations associated with this bone */
  8980. animations: Animation[];
  8981. /**
  8982. * Gets or sets bone length
  8983. */
  8984. length: number;
  8985. /**
  8986. * @hidden Internal only
  8987. * Set this value to map this bone to a different index in the transform matrices
  8988. * Set this value to -1 to exclude the bone from the transform matrices
  8989. */ index: Nullable<number>;
  8990. private _skeleton;
  8991. private _localMatrix;
  8992. private _restPose;
  8993. private _baseMatrix;
  8994. private _absoluteTransform;
  8995. private _invertedAbsoluteTransform;
  8996. private _parent;
  8997. private _scalingDeterminant;
  8998. private _worldTransform;
  8999. private _localScaling;
  9000. private _localRotation;
  9001. private _localPosition;
  9002. private _needToDecompose;
  9003. private _needToCompose;
  9004. /** @hidden */ linkedTransformNode: Nullable<TransformNode>;
  9005. /** @hidden */
  9006. /** @hidden */ matrix: Matrix;
  9007. /**
  9008. * Create a new bone
  9009. * @param name defines the bone name
  9010. * @param skeleton defines the parent skeleton
  9011. * @param parentBone defines the parent (can be null if the bone is the root)
  9012. * @param localMatrix defines the local matrix
  9013. * @param restPose defines the rest pose matrix
  9014. * @param baseMatrix defines the base matrix
  9015. * @param index defines index of the bone in the hiearchy
  9016. */
  9017. constructor(
  9018. /**
  9019. * defines the bone name
  9020. */
  9021. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9022. /**
  9023. * Gets the parent skeleton
  9024. * @returns a skeleton
  9025. */
  9026. getSkeleton(): Skeleton;
  9027. /**
  9028. * Gets parent bone
  9029. * @returns a bone or null if the bone is the root of the bone hierarchy
  9030. */
  9031. getParent(): Nullable<Bone>;
  9032. /**
  9033. * Sets the parent bone
  9034. * @param parent defines the parent (can be null if the bone is the root)
  9035. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9036. */
  9037. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9038. /**
  9039. * Gets the local matrix
  9040. * @returns a matrix
  9041. */
  9042. getLocalMatrix(): Matrix;
  9043. /**
  9044. * Gets the base matrix (initial matrix which remains unchanged)
  9045. * @returns a matrix
  9046. */
  9047. getBaseMatrix(): Matrix;
  9048. /**
  9049. * Gets the rest pose matrix
  9050. * @returns a matrix
  9051. */
  9052. getRestPose(): Matrix;
  9053. /**
  9054. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9055. */
  9056. getWorldMatrix(): Matrix;
  9057. /**
  9058. * Sets the local matrix to rest pose matrix
  9059. */
  9060. returnToRest(): void;
  9061. /**
  9062. * Gets the inverse of the absolute transform matrix.
  9063. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9064. * @returns a matrix
  9065. */
  9066. getInvertedAbsoluteTransform(): Matrix;
  9067. /**
  9068. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9069. * @returns a matrix
  9070. */
  9071. getAbsoluteTransform(): Matrix;
  9072. /**
  9073. * Links with the given transform node.
  9074. * The local matrix of this bone is copied from the transform node every frame.
  9075. * @param transformNode defines the transform node to link to
  9076. */
  9077. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9078. /** Gets or sets current position (in local space) */
  9079. position: Vector3;
  9080. /** Gets or sets current rotation (in local space) */
  9081. rotation: Vector3;
  9082. /** Gets or sets current rotation quaternion (in local space) */
  9083. rotationQuaternion: Quaternion;
  9084. /** Gets or sets current scaling (in local space) */
  9085. scaling: Vector3;
  9086. /**
  9087. * Gets the animation properties override
  9088. */
  9089. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9090. private _decompose;
  9091. private _compose;
  9092. /**
  9093. * Update the base and local matrices
  9094. * @param matrix defines the new base or local matrix
  9095. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9096. * @param updateLocalMatrix defines if the local matrix should be updated
  9097. */
  9098. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9099. /** @hidden */ updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9100. /**
  9101. * Flag the bone as dirty (Forcing it to update everything)
  9102. */
  9103. markAsDirty(): void;
  9104. private _markAsDirtyAndCompose;
  9105. private _markAsDirtyAndDecompose;
  9106. /**
  9107. * Copy an animation range from another bone
  9108. * @param source defines the source bone
  9109. * @param rangeName defines the range name to copy
  9110. * @param frameOffset defines the frame offset
  9111. * @param rescaleAsRequired defines if rescaling must be applied if required
  9112. * @param skelDimensionsRatio defines the scaling ratio
  9113. * @returns true if operation was successful
  9114. */
  9115. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  9116. /**
  9117. * Translate the bone in local or world space
  9118. * @param vec The amount to translate the bone
  9119. * @param space The space that the translation is in
  9120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9121. */
  9122. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9123. /**
  9124. * Set the postion of the bone in local or world space
  9125. * @param position The position to set the bone
  9126. * @param space The space that the position is in
  9127. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9128. */
  9129. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9130. /**
  9131. * Set the absolute position of the bone (world space)
  9132. * @param position The position to set the bone
  9133. * @param mesh The mesh that this bone is attached to
  9134. */
  9135. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9136. /**
  9137. * Scale the bone on the x, y and z axes (in local space)
  9138. * @param x The amount to scale the bone on the x axis
  9139. * @param y The amount to scale the bone on the y axis
  9140. * @param z The amount to scale the bone on the z axis
  9141. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9142. */
  9143. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9144. /**
  9145. * Set the bone scaling in local space
  9146. * @param scale defines the scaling vector
  9147. */
  9148. setScale(scale: Vector3): void;
  9149. /**
  9150. * Gets the current scaling in local space
  9151. * @returns the current scaling vector
  9152. */
  9153. getScale(): Vector3;
  9154. /**
  9155. * Gets the current scaling in local space and stores it in a target vector
  9156. * @param result defines the target vector
  9157. */
  9158. getScaleToRef(result: Vector3): void;
  9159. /**
  9160. * Set the yaw, pitch, and roll of the bone in local or world space
  9161. * @param yaw The rotation of the bone on the y axis
  9162. * @param pitch The rotation of the bone on the x axis
  9163. * @param roll The rotation of the bone on the z axis
  9164. * @param space The space that the axes of rotation are in
  9165. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9166. */
  9167. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9168. /**
  9169. * Add a rotation to the bone on an axis in local or world space
  9170. * @param axis The axis to rotate the bone on
  9171. * @param amount The amount to rotate the bone
  9172. * @param space The space that the axis is in
  9173. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9174. */
  9175. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9176. /**
  9177. * Set the rotation of the bone to a particular axis angle in local or world space
  9178. * @param axis The axis to rotate the bone on
  9179. * @param angle The angle that the bone should be rotated to
  9180. * @param space The space that the axis is in
  9181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9182. */
  9183. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9184. /**
  9185. * Set the euler rotation of the bone in local of world space
  9186. * @param rotation The euler rotation that the bone should be set to
  9187. * @param space The space that the rotation is in
  9188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9189. */
  9190. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9191. /**
  9192. * Set the quaternion rotation of the bone in local of world space
  9193. * @param quat The quaternion rotation that the bone should be set to
  9194. * @param space The space that the rotation is in
  9195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9196. */
  9197. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9198. /**
  9199. * Set the rotation matrix of the bone in local of world space
  9200. * @param rotMat The rotation matrix that the bone should be set to
  9201. * @param space The space that the rotation is in
  9202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9203. */
  9204. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9205. private _rotateWithMatrix;
  9206. private _getNegativeRotationToRef;
  9207. /**
  9208. * Get the position of the bone in local or world space
  9209. * @param space The space that the returned position is in
  9210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9211. * @returns The position of the bone
  9212. */
  9213. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9214. /**
  9215. * Copy the position of the bone to a vector3 in local or world space
  9216. * @param space The space that the returned position is in
  9217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9218. * @param result The vector3 to copy the position to
  9219. */
  9220. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9221. /**
  9222. * Get the absolute position of the bone (world space)
  9223. * @param mesh The mesh that this bone is attached to
  9224. * @returns The absolute position of the bone
  9225. */
  9226. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9227. /**
  9228. * Copy the absolute position of the bone (world space) to the result param
  9229. * @param mesh The mesh that this bone is attached to
  9230. * @param result The vector3 to copy the absolute position to
  9231. */
  9232. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9233. /**
  9234. * Compute the absolute transforms of this bone and its children
  9235. */
  9236. computeAbsoluteTransforms(): void;
  9237. /**
  9238. * Get the world direction from an axis that is in the local space of the bone
  9239. * @param localAxis The local direction that is used to compute the world direction
  9240. * @param mesh The mesh that this bone is attached to
  9241. * @returns The world direction
  9242. */
  9243. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9244. /**
  9245. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9246. * @param localAxis The local direction that is used to compute the world direction
  9247. * @param mesh The mesh that this bone is attached to
  9248. * @param result The vector3 that the world direction will be copied to
  9249. */
  9250. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9251. /**
  9252. * Get the euler rotation of the bone in local or world space
  9253. * @param space The space that the rotation should be in
  9254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9255. * @returns The euler rotation
  9256. */
  9257. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9258. /**
  9259. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9260. * @param space The space that the rotation should be in
  9261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9262. * @param result The vector3 that the rotation should be copied to
  9263. */
  9264. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9265. /**
  9266. * Get the quaternion rotation of the bone in either local or world space
  9267. * @param space The space that the rotation should be in
  9268. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9269. * @returns The quaternion rotation
  9270. */
  9271. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9272. /**
  9273. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9274. * @param space The space that the rotation should be in
  9275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9276. * @param result The quaternion that the rotation should be copied to
  9277. */
  9278. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9279. /**
  9280. * Get the rotation matrix of the bone in local or world space
  9281. * @param space The space that the rotation should be in
  9282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9283. * @returns The rotation matrix
  9284. */
  9285. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9286. /**
  9287. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9288. * @param space The space that the rotation should be in
  9289. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9290. * @param result The quaternion that the rotation should be copied to
  9291. */
  9292. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9293. /**
  9294. * Get the world position of a point that is in the local space of the bone
  9295. * @param position The local position
  9296. * @param mesh The mesh that this bone is attached to
  9297. * @returns The world position
  9298. */
  9299. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9300. /**
  9301. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9302. * @param position The local position
  9303. * @param mesh The mesh that this bone is attached to
  9304. * @param result The vector3 that the world position should be copied to
  9305. */
  9306. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9307. /**
  9308. * Get the local position of a point that is in world space
  9309. * @param position The world position
  9310. * @param mesh The mesh that this bone is attached to
  9311. * @returns The local position
  9312. */
  9313. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9314. /**
  9315. * Get the local position of a point that is in world space and copy it to the result param
  9316. * @param position The world position
  9317. * @param mesh The mesh that this bone is attached to
  9318. * @param result The vector3 that the local position should be copied to
  9319. */
  9320. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9321. }
  9322. }
  9323. declare module BABYLON {
  9324. /**
  9325. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  9326. * @see https://doc.babylonjs.com/how_to/transformnode
  9327. */
  9328. export class TransformNode extends Node {
  9329. /**
  9330. * Object will not rotate to face the camera
  9331. */
  9332. static BILLBOARDMODE_NONE: number;
  9333. /**
  9334. * Object will rotate to face the camera but only on the x axis
  9335. */
  9336. static BILLBOARDMODE_X: number;
  9337. /**
  9338. * Object will rotate to face the camera but only on the y axis
  9339. */
  9340. static BILLBOARDMODE_Y: number;
  9341. /**
  9342. * Object will rotate to face the camera but only on the z axis
  9343. */
  9344. static BILLBOARDMODE_Z: number;
  9345. /**
  9346. * Object will rotate to face the camera
  9347. */
  9348. static BILLBOARDMODE_ALL: number;
  9349. private _forward;
  9350. private _forwardInverted;
  9351. private _up;
  9352. private _right;
  9353. private _rightInverted;
  9354. private _position;
  9355. private _rotation;
  9356. private _rotationQuaternion;
  9357. protected _scaling: Vector3;
  9358. protected _isDirty: boolean;
  9359. private _transformToBoneReferal;
  9360. /**
  9361. * Set the billboard mode. Default is 0.
  9362. *
  9363. * | Value | Type | Description |
  9364. * | --- | --- | --- |
  9365. * | 0 | BILLBOARDMODE_NONE | |
  9366. * | 1 | BILLBOARDMODE_X | |
  9367. * | 2 | BILLBOARDMODE_Y | |
  9368. * | 4 | BILLBOARDMODE_Z | |
  9369. * | 7 | BILLBOARDMODE_ALL | |
  9370. *
  9371. */
  9372. billboardMode: number;
  9373. /**
  9374. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  9375. */
  9376. scalingDeterminant: number;
  9377. /**
  9378. * Sets the distance of the object to max, often used by skybox
  9379. */
  9380. infiniteDistance: boolean;
  9381. /**
  9382. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  9383. * By default the system will update normals to compensate
  9384. */
  9385. ignoreNonUniformScaling: boolean;
  9386. /** @hidden */ poseMatrix: Matrix;
  9387. /** @hidden */ localMatrix: Matrix;
  9388. private _absolutePosition;
  9389. private _pivotMatrix;
  9390. private _pivotMatrixInverse;
  9391. protected _postMultiplyPivotMatrix: boolean;
  9392. protected _isWorldMatrixFrozen: boolean;
  9393. /** @hidden */ indexInSceneTransformNodesArray: number;
  9394. /**
  9395. * An event triggered after the world matrix is updated
  9396. */
  9397. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  9398. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  9399. /**
  9400. * Gets a string identifying the name of the class
  9401. * @returns "TransformNode" string
  9402. */
  9403. getClassName(): string;
  9404. /**
  9405. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  9406. */
  9407. position: Vector3;
  9408. /**
  9409. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  9410. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  9411. */
  9412. rotation: Vector3;
  9413. /**
  9414. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  9415. */
  9416. scaling: Vector3;
  9417. /**
  9418. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  9419. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  9420. */
  9421. rotationQuaternion: Nullable<Quaternion>;
  9422. /**
  9423. * The forward direction of that transform in world space.
  9424. */
  9425. readonly forward: Vector3;
  9426. /**
  9427. * The up direction of that transform in world space.
  9428. */
  9429. readonly up: Vector3;
  9430. /**
  9431. * The right direction of that transform in world space.
  9432. */
  9433. readonly right: Vector3;
  9434. /**
  9435. * Copies the parameter passed Matrix into the mesh Pose matrix.
  9436. * @param matrix the matrix to copy the pose from
  9437. * @returns this TransformNode.
  9438. */
  9439. updatePoseMatrix(matrix: Matrix): TransformNode;
  9440. /**
  9441. * Returns the mesh Pose matrix.
  9442. * @returns the pose matrix
  9443. */
  9444. getPoseMatrix(): Matrix;
  9445. /** @hidden */ isSynchronized(): boolean;
  9446. /** @hidden */ initCache(): void;
  9447. /**
  9448. * Flag the transform node as dirty (Forcing it to update everything)
  9449. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  9450. * @returns this transform node
  9451. */
  9452. markAsDirty(property: string): TransformNode;
  9453. /**
  9454. * Returns the current mesh absolute position.
  9455. * Returns a Vector3.
  9456. */
  9457. readonly absolutePosition: Vector3;
  9458. /**
  9459. * Sets a new matrix to apply before all other transformation
  9460. * @param matrix defines the transform matrix
  9461. * @returns the current TransformNode
  9462. */
  9463. setPreTransformMatrix(matrix: Matrix): TransformNode;
  9464. /**
  9465. * Sets a new pivot matrix to the current node
  9466. * @param matrix defines the new pivot matrix to use
  9467. * @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
  9468. * @returns the current TransformNode
  9469. */
  9470. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  9471. /**
  9472. * Returns the mesh pivot matrix.
  9473. * Default : Identity.
  9474. * @returns the matrix
  9475. */
  9476. getPivotMatrix(): Matrix;
  9477. /**
  9478. * Prevents the World matrix to be computed any longer.
  9479. * @returns the TransformNode.
  9480. */
  9481. freezeWorldMatrix(): TransformNode;
  9482. /**
  9483. * Allows back the World matrix computation.
  9484. * @returns the TransformNode.
  9485. */
  9486. unfreezeWorldMatrix(): this;
  9487. /**
  9488. * True if the World matrix has been frozen.
  9489. */
  9490. readonly isWorldMatrixFrozen: boolean;
  9491. /**
  9492. * Retuns the mesh absolute position in the World.
  9493. * @returns a Vector3.
  9494. */
  9495. getAbsolutePosition(): Vector3;
  9496. /**
  9497. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  9498. * @param absolutePosition the absolute position to set
  9499. * @returns the TransformNode.
  9500. */
  9501. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  9502. /**
  9503. * Sets the mesh position in its local space.
  9504. * @param vector3 the position to set in localspace
  9505. * @returns the TransformNode.
  9506. */
  9507. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  9508. /**
  9509. * Returns the mesh position in the local space from the current World matrix values.
  9510. * @returns a new Vector3.
  9511. */
  9512. getPositionExpressedInLocalSpace(): Vector3;
  9513. /**
  9514. * Translates the mesh along the passed Vector3 in its local space.
  9515. * @param vector3 the distance to translate in localspace
  9516. * @returns the TransformNode.
  9517. */
  9518. locallyTranslate(vector3: Vector3): TransformNode;
  9519. private static _lookAtVectorCache;
  9520. /**
  9521. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  9522. * @param targetPoint the position (must be in same space as current mesh) to look at
  9523. * @param yawCor optional yaw (y-axis) correction in radians
  9524. * @param pitchCor optional pitch (x-axis) correction in radians
  9525. * @param rollCor optional roll (z-axis) correction in radians
  9526. * @param space the choosen space of the target
  9527. * @returns the TransformNode.
  9528. */
  9529. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  9530. /**
  9531. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  9532. * This Vector3 is expressed in the World space.
  9533. * @param localAxis axis to rotate
  9534. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  9535. */
  9536. getDirection(localAxis: Vector3): Vector3;
  9537. /**
  9538. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  9539. * localAxis is expressed in the mesh local space.
  9540. * result is computed in the Wordl space from the mesh World matrix.
  9541. * @param localAxis axis to rotate
  9542. * @param result the resulting transformnode
  9543. * @returns this TransformNode.
  9544. */
  9545. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  9546. /**
  9547. * Sets this transform node rotation to the given local axis.
  9548. * @param localAxis the axis in local space
  9549. * @param yawCor optional yaw (y-axis) correction in radians
  9550. * @param pitchCor optional pitch (x-axis) correction in radians
  9551. * @param rollCor optional roll (z-axis) correction in radians
  9552. * @returns this TransformNode
  9553. */
  9554. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  9555. /**
  9556. * Sets a new pivot point to the current node
  9557. * @param point defines the new pivot point to use
  9558. * @param space defines if the point is in world or local space (local by default)
  9559. * @returns the current TransformNode
  9560. */
  9561. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  9562. /**
  9563. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  9564. * @returns the pivot point
  9565. */
  9566. getPivotPoint(): Vector3;
  9567. /**
  9568. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  9569. * @param result the vector3 to store the result
  9570. * @returns this TransformNode.
  9571. */
  9572. getPivotPointToRef(result: Vector3): TransformNode;
  9573. /**
  9574. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  9575. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  9576. */
  9577. getAbsolutePivotPoint(): Vector3;
  9578. /**
  9579. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  9580. * @param result vector3 to store the result
  9581. * @returns this TransformNode.
  9582. */
  9583. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  9584. /**
  9585. * Defines the passed node as the parent of the current node.
  9586. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  9587. * @param node the node ot set as the parent
  9588. * @returns this TransformNode.
  9589. */
  9590. setParent(node: Nullable<Node>): TransformNode;
  9591. private _nonUniformScaling;
  9592. /**
  9593. * True if the scaling property of this object is non uniform eg. (1,2,1)
  9594. */
  9595. readonly nonUniformScaling: boolean;
  9596. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  9597. /**
  9598. * Attach the current TransformNode to another TransformNode associated with a bone
  9599. * @param bone Bone affecting the TransformNode
  9600. * @param affectedTransformNode TransformNode associated with the bone
  9601. * @returns this object
  9602. */
  9603. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  9604. /**
  9605. * Detach the transform node if its associated with a bone
  9606. * @returns this object
  9607. */
  9608. detachFromBone(): TransformNode;
  9609. private static _rotationAxisCache;
  9610. /**
  9611. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  9612. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  9613. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  9614. * The passed axis is also normalized.
  9615. * @param axis the axis to rotate around
  9616. * @param amount the amount to rotate in radians
  9617. * @param space Space to rotate in (Default: local)
  9618. * @returns the TransformNode.
  9619. */
  9620. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  9621. /**
  9622. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  9623. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  9624. * The passed axis is also normalized. .
  9625. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  9626. * @param point the point to rotate around
  9627. * @param axis the axis to rotate around
  9628. * @param amount the amount to rotate in radians
  9629. * @returns the TransformNode
  9630. */
  9631. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  9632. /**
  9633. * Translates the mesh along the axis vector for the passed distance in the given space.
  9634. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  9635. * @param axis the axis to translate in
  9636. * @param distance the distance to translate
  9637. * @param space Space to rotate in (Default: local)
  9638. * @returns the TransformNode.
  9639. */
  9640. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  9641. /**
  9642. * Adds a rotation step to the mesh current rotation.
  9643. * x, y, z are Euler angles expressed in radians.
  9644. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  9645. * This means this rotation is made in the mesh local space only.
  9646. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  9647. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  9648. * ```javascript
  9649. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  9650. * ```
  9651. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  9652. * 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.
  9653. * @param x Rotation to add
  9654. * @param y Rotation to add
  9655. * @param z Rotation to add
  9656. * @returns the TransformNode.
  9657. */
  9658. addRotation(x: number, y: number, z: number): TransformNode;
  9659. /**
  9660. * Computes the world matrix of the node
  9661. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9662. * @returns the world matrix
  9663. */
  9664. computeWorldMatrix(force?: boolean): Matrix;
  9665. protected _afterComputeWorldMatrix(): void;
  9666. /**
  9667. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  9668. * @param func callback function to add
  9669. *
  9670. * @returns the TransformNode.
  9671. */
  9672. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9673. /**
  9674. * Removes a registered callback function.
  9675. * @param func callback function to remove
  9676. * @returns the TransformNode.
  9677. */
  9678. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9679. /**
  9680. * Gets the position of the current mesh in camera space
  9681. * @param camera defines the camera to use
  9682. * @returns a position
  9683. */
  9684. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  9685. /**
  9686. * Returns the distance from the mesh to the active camera
  9687. * @param camera defines the camera to use
  9688. * @returns the distance
  9689. */
  9690. getDistanceToCamera(camera?: Nullable<Camera>): number;
  9691. /**
  9692. * Clone the current transform node
  9693. * @param name Name of the new clone
  9694. * @param newParent New parent for the clone
  9695. * @param doNotCloneChildren Do not clone children hierarchy
  9696. * @returns the new transform node
  9697. */
  9698. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  9699. /**
  9700. * Serializes the objects information.
  9701. * @param currentSerializationObject defines the object to serialize in
  9702. * @returns the serialized object
  9703. */
  9704. serialize(currentSerializationObject?: any): any;
  9705. /**
  9706. * Returns a new TransformNode object parsed from the source provided.
  9707. * @param parsedTransformNode is the source.
  9708. * @param scene the scne the object belongs to
  9709. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  9710. * @returns a new TransformNode object parsed from the source provided.
  9711. */
  9712. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  9713. /**
  9714. * Get all child-transformNodes of this node
  9715. * @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
  9716. * @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
  9717. * @returns an array of TransformNode
  9718. */
  9719. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  9720. /**
  9721. * Releases resources associated with this transform node.
  9722. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9723. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9724. */
  9725. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9726. }
  9727. }
  9728. declare module BABYLON {
  9729. /**
  9730. * Defines the types of pose enabled controllers that are supported
  9731. */
  9732. export enum PoseEnabledControllerType {
  9733. /**
  9734. * HTC Vive
  9735. */
  9736. VIVE = 0,
  9737. /**
  9738. * Oculus Rift
  9739. */
  9740. OCULUS = 1,
  9741. /**
  9742. * Windows mixed reality
  9743. */
  9744. WINDOWS = 2,
  9745. /**
  9746. * Samsung gear VR
  9747. */
  9748. GEAR_VR = 3,
  9749. /**
  9750. * Google Daydream
  9751. */
  9752. DAYDREAM = 4,
  9753. /**
  9754. * Generic
  9755. */
  9756. GENERIC = 5
  9757. }
  9758. /**
  9759. * Defines the MutableGamepadButton interface for the state of a gamepad button
  9760. */
  9761. export interface MutableGamepadButton {
  9762. /**
  9763. * Value of the button/trigger
  9764. */
  9765. value: number;
  9766. /**
  9767. * If the button/trigger is currently touched
  9768. */
  9769. touched: boolean;
  9770. /**
  9771. * If the button/trigger is currently pressed
  9772. */
  9773. pressed: boolean;
  9774. }
  9775. /**
  9776. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  9777. * @hidden
  9778. */
  9779. export interface ExtendedGamepadButton extends GamepadButton {
  9780. /**
  9781. * If the button/trigger is currently pressed
  9782. */
  9783. readonly pressed: boolean;
  9784. /**
  9785. * If the button/trigger is currently touched
  9786. */
  9787. readonly touched: boolean;
  9788. /**
  9789. * Value of the button/trigger
  9790. */
  9791. readonly value: number;
  9792. }
  9793. /** @hidden */
  9794. export interface _GamePadFactory {
  9795. /**
  9796. * Returns wether or not the current gamepad can be created for this type of controller.
  9797. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  9798. * @returns true if it can be created, otherwise false
  9799. */
  9800. canCreate(gamepadInfo: any): boolean;
  9801. /**
  9802. * Creates a new instance of the Gamepad.
  9803. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  9804. * @returns the new gamepad instance
  9805. */
  9806. create(gamepadInfo: any): Gamepad;
  9807. }
  9808. /**
  9809. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  9810. */
  9811. export class PoseEnabledControllerHelper {
  9812. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  9813. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  9814. /**
  9815. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  9816. * @param vrGamepad the gamepad to initialized
  9817. * @returns a vr controller of the type the gamepad identified as
  9818. */
  9819. static InitiateController(vrGamepad: any): Gamepad;
  9820. }
  9821. /**
  9822. * Defines the PoseEnabledController object that contains state of a vr capable controller
  9823. */
  9824. export class PoseEnabledController extends Gamepad implements PoseControlled {
  9825. private _deviceRoomPosition;
  9826. private _deviceRoomRotationQuaternion;
  9827. /**
  9828. * The device position in babylon space
  9829. */
  9830. devicePosition: Vector3;
  9831. /**
  9832. * The device rotation in babylon space
  9833. */
  9834. deviceRotationQuaternion: Quaternion;
  9835. /**
  9836. * The scale factor of the device in babylon space
  9837. */
  9838. deviceScaleFactor: number;
  9839. /**
  9840. * (Likely devicePosition should be used instead) The device position in its room space
  9841. */
  9842. position: Vector3;
  9843. /**
  9844. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  9845. */
  9846. rotationQuaternion: Quaternion;
  9847. /**
  9848. * The type of controller (Eg. Windows mixed reality)
  9849. */
  9850. controllerType: PoseEnabledControllerType;
  9851. protected _calculatedPosition: Vector3;
  9852. private _calculatedRotation;
  9853. /**
  9854. * The raw pose from the device
  9855. */
  9856. rawPose: DevicePose;
  9857. private _trackPosition;
  9858. private _maxRotationDistFromHeadset;
  9859. private _draggedRoomRotation;
  9860. /**
  9861. * @hidden
  9862. */ disableTrackPosition(fixedPosition: Vector3): void;
  9863. /**
  9864. * Internal, the mesh attached to the controller
  9865. * @hidden
  9866. */ mesh: Nullable<AbstractMesh>;
  9867. private _poseControlledCamera;
  9868. private _leftHandSystemQuaternion;
  9869. /**
  9870. * Internal, matrix used to convert room space to babylon space
  9871. * @hidden
  9872. */ deviceToWorld: Matrix;
  9873. /**
  9874. * Node to be used when casting a ray from the controller
  9875. * @hidden
  9876. */ pointingPoseNode: Nullable<TransformNode>;
  9877. /**
  9878. * Name of the child mesh that can be used to cast a ray from the controller
  9879. */
  9880. static readonly POINTING_POSE: string;
  9881. /**
  9882. * Creates a new PoseEnabledController from a gamepad
  9883. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  9884. */
  9885. constructor(browserGamepad: any);
  9886. private _workingMatrix;
  9887. /**
  9888. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  9889. */
  9890. update(): void;
  9891. /**
  9892. * Updates only the pose device and mesh without doing any button event checking
  9893. */
  9894. protected _updatePoseAndMesh(): void;
  9895. /**
  9896. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  9897. * @param poseData raw pose fromthe device
  9898. */
  9899. updateFromDevice(poseData: DevicePose): void;
  9900. /**
  9901. * @hidden
  9902. */ meshAttachedObservable: Observable<AbstractMesh>;
  9903. /**
  9904. * Attaches a mesh to the controller
  9905. * @param mesh the mesh to be attached
  9906. */
  9907. attachToMesh(mesh: AbstractMesh): void;
  9908. /**
  9909. * Attaches the controllers mesh to a camera
  9910. * @param camera the camera the mesh should be attached to
  9911. */
  9912. attachToPoseControlledCamera(camera: TargetCamera): void;
  9913. /**
  9914. * Disposes of the controller
  9915. */
  9916. dispose(): void;
  9917. /**
  9918. * The mesh that is attached to the controller
  9919. */
  9920. readonly mesh: Nullable<AbstractMesh>;
  9921. /**
  9922. * Gets the ray of the controller in the direction the controller is pointing
  9923. * @param length the length the resulting ray should be
  9924. * @returns a ray in the direction the controller is pointing
  9925. */
  9926. getForwardRay(length?: number): Ray;
  9927. }
  9928. }
  9929. declare module BABYLON {
  9930. /**
  9931. * Defines the WebVRController object that represents controllers tracked in 3D space
  9932. */
  9933. export abstract class WebVRController extends PoseEnabledController {
  9934. /**
  9935. * Internal, the default controller model for the controller
  9936. */
  9937. protected _defaultModel: AbstractMesh;
  9938. /**
  9939. * Fired when the trigger state has changed
  9940. */
  9941. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  9942. /**
  9943. * Fired when the main button state has changed
  9944. */
  9945. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  9946. /**
  9947. * Fired when the secondary button state has changed
  9948. */
  9949. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  9950. /**
  9951. * Fired when the pad state has changed
  9952. */
  9953. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  9954. /**
  9955. * Fired when controllers stick values have changed
  9956. */
  9957. onPadValuesChangedObservable: Observable<StickValues>;
  9958. /**
  9959. * Array of button availible on the controller
  9960. */
  9961. protected _buttons: Array<MutableGamepadButton>;
  9962. private _onButtonStateChange;
  9963. /**
  9964. * Fired when a controller button's state has changed
  9965. * @param callback the callback containing the button that was modified
  9966. */
  9967. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  9968. /**
  9969. * X and Y axis corrisponding to the controllers joystick
  9970. */
  9971. pad: StickValues;
  9972. /**
  9973. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  9974. */
  9975. hand: string;
  9976. /**
  9977. * The default controller model for the controller
  9978. */
  9979. readonly defaultModel: AbstractMesh;
  9980. /**
  9981. * Creates a new WebVRController from a gamepad
  9982. * @param vrGamepad the gamepad that the WebVRController should be created from
  9983. */
  9984. constructor(vrGamepad: any);
  9985. /**
  9986. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  9987. */
  9988. update(): void;
  9989. /**
  9990. * Function to be called when a button is modified
  9991. */
  9992. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  9993. /**
  9994. * Loads a mesh and attaches it to the controller
  9995. * @param scene the scene the mesh should be added to
  9996. * @param meshLoaded callback for when the mesh has been loaded
  9997. */
  9998. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  9999. private _setButtonValue;
  10000. private _changes;
  10001. private _checkChanges;
  10002. /**
  10003. * Disposes of th webVRCOntroller
  10004. */
  10005. dispose(): void;
  10006. }
  10007. }
  10008. declare module BABYLON {
  10009. /**
  10010. * Interface describing all the common properties and methods a shadow light needs to implement.
  10011. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10012. * as well as binding the different shadow properties to the effects.
  10013. */
  10014. export interface IShadowLight extends Light {
  10015. /**
  10016. * The light id in the scene (used in scene.findLighById for instance)
  10017. */
  10018. id: string;
  10019. /**
  10020. * The position the shdow will be casted from.
  10021. */
  10022. position: Vector3;
  10023. /**
  10024. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10025. */
  10026. direction: Vector3;
  10027. /**
  10028. * The transformed position. Position of the light in world space taking parenting in account.
  10029. */
  10030. transformedPosition: Vector3;
  10031. /**
  10032. * The transformed direction. Direction of the light in world space taking parenting in account.
  10033. */
  10034. transformedDirection: Vector3;
  10035. /**
  10036. * The friendly name of the light in the scene.
  10037. */
  10038. name: string;
  10039. /**
  10040. * Defines the shadow projection clipping minimum z value.
  10041. */
  10042. shadowMinZ: number;
  10043. /**
  10044. * Defines the shadow projection clipping maximum z value.
  10045. */
  10046. shadowMaxZ: number;
  10047. /**
  10048. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10049. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10050. */
  10051. computeTransformedInformation(): boolean;
  10052. /**
  10053. * Gets the scene the light belongs to.
  10054. * @returns The scene
  10055. */
  10056. getScene(): Scene;
  10057. /**
  10058. * Callback defining a custom Projection Matrix Builder.
  10059. * This can be used to override the default projection matrix computation.
  10060. */
  10061. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10062. /**
  10063. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10064. * @param matrix The materix to updated with the projection information
  10065. * @param viewMatrix The transform matrix of the light
  10066. * @param renderList The list of mesh to render in the map
  10067. * @returns The current light
  10068. */
  10069. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10070. /**
  10071. * Gets the current depth scale used in ESM.
  10072. * @returns The scale
  10073. */
  10074. getDepthScale(): number;
  10075. /**
  10076. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10077. * @returns true if a cube texture needs to be use
  10078. */
  10079. needCube(): boolean;
  10080. /**
  10081. * Detects if the projection matrix requires to be recomputed this frame.
  10082. * @returns true if it requires to be recomputed otherwise, false.
  10083. */
  10084. needProjectionMatrixCompute(): boolean;
  10085. /**
  10086. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10087. */
  10088. forceProjectionMatrixCompute(): void;
  10089. /**
  10090. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10091. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10092. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10093. */
  10094. getShadowDirection(faceIndex?: number): Vector3;
  10095. /**
  10096. * Gets the minZ used for shadow according to both the scene and the light.
  10097. * @param activeCamera The camera we are returning the min for
  10098. * @returns the depth min z
  10099. */
  10100. getDepthMinZ(activeCamera: Camera): number;
  10101. /**
  10102. * Gets the maxZ used for shadow according to both the scene and the light.
  10103. * @param activeCamera The camera we are returning the max for
  10104. * @returns the depth max z
  10105. */
  10106. getDepthMaxZ(activeCamera: Camera): number;
  10107. }
  10108. /**
  10109. * Base implementation IShadowLight
  10110. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10111. */
  10112. export abstract class ShadowLight extends Light implements IShadowLight {
  10113. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10114. protected _position: Vector3;
  10115. protected _setPosition(value: Vector3): void;
  10116. /**
  10117. * Sets the position the shadow will be casted from. Also use as the light position for both
  10118. * point and spot lights.
  10119. */
  10120. /**
  10121. * Sets the position the shadow will be casted from. Also use as the light position for both
  10122. * point and spot lights.
  10123. */
  10124. position: Vector3;
  10125. protected _direction: Vector3;
  10126. protected _setDirection(value: Vector3): void;
  10127. /**
  10128. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10129. * Also use as the light direction on spot and directional lights.
  10130. */
  10131. /**
  10132. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10133. * Also use as the light direction on spot and directional lights.
  10134. */
  10135. direction: Vector3;
  10136. private _shadowMinZ;
  10137. /**
  10138. * Gets the shadow projection clipping minimum z value.
  10139. */
  10140. /**
  10141. * Sets the shadow projection clipping minimum z value.
  10142. */
  10143. shadowMinZ: number;
  10144. private _shadowMaxZ;
  10145. /**
  10146. * Sets the shadow projection clipping maximum z value.
  10147. */
  10148. /**
  10149. * Gets the shadow projection clipping maximum z value.
  10150. */
  10151. shadowMaxZ: number;
  10152. /**
  10153. * Callback defining a custom Projection Matrix Builder.
  10154. * This can be used to override the default projection matrix computation.
  10155. */
  10156. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10157. /**
  10158. * The transformed position. Position of the light in world space taking parenting in account.
  10159. */
  10160. transformedPosition: Vector3;
  10161. /**
  10162. * The transformed direction. Direction of the light in world space taking parenting in account.
  10163. */
  10164. transformedDirection: Vector3;
  10165. private _needProjectionMatrixCompute;
  10166. /**
  10167. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10168. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10169. */
  10170. computeTransformedInformation(): boolean;
  10171. /**
  10172. * Return the depth scale used for the shadow map.
  10173. * @returns the depth scale.
  10174. */
  10175. getDepthScale(): number;
  10176. /**
  10177. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10178. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10179. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10180. */
  10181. getShadowDirection(faceIndex?: number): Vector3;
  10182. /**
  10183. * Returns the ShadowLight absolute position in the World.
  10184. * @returns the position vector in world space
  10185. */
  10186. getAbsolutePosition(): Vector3;
  10187. /**
  10188. * Sets the ShadowLight direction toward the passed target.
  10189. * @param target The point tot target in local space
  10190. * @returns the updated ShadowLight direction
  10191. */
  10192. setDirectionToTarget(target: Vector3): Vector3;
  10193. /**
  10194. * Returns the light rotation in euler definition.
  10195. * @returns the x y z rotation in local space.
  10196. */
  10197. getRotation(): Vector3;
  10198. /**
  10199. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10200. * @returns true if a cube texture needs to be use
  10201. */
  10202. needCube(): boolean;
  10203. /**
  10204. * Detects if the projection matrix requires to be recomputed this frame.
  10205. * @returns true if it requires to be recomputed otherwise, false.
  10206. */
  10207. needProjectionMatrixCompute(): boolean;
  10208. /**
  10209. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10210. */
  10211. forceProjectionMatrixCompute(): void;
  10212. /** @hidden */ initCache(): void;
  10213. /** @hidden */ isSynchronized(): boolean;
  10214. /**
  10215. * Computes the world matrix of the node
  10216. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10217. * @returns the world matrix
  10218. */
  10219. computeWorldMatrix(force?: boolean): Matrix;
  10220. /**
  10221. * Gets the minZ used for shadow according to both the scene and the light.
  10222. * @param activeCamera The camera we are returning the min for
  10223. * @returns the depth min z
  10224. */
  10225. getDepthMinZ(activeCamera: Camera): number;
  10226. /**
  10227. * Gets the maxZ used for shadow according to both the scene and the light.
  10228. * @param activeCamera The camera we are returning the max for
  10229. * @returns the depth max z
  10230. */
  10231. getDepthMaxZ(activeCamera: Camera): number;
  10232. /**
  10233. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10234. * @param matrix The materix to updated with the projection information
  10235. * @param viewMatrix The transform matrix of the light
  10236. * @param renderList The list of mesh to render in the map
  10237. * @returns The current light
  10238. */
  10239. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10240. }
  10241. }
  10242. declare module BABYLON {
  10243. /**
  10244. * "Static Class" containing the most commonly used helper while dealing with material for
  10245. * rendering purpose.
  10246. *
  10247. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10248. *
  10249. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10250. */
  10251. export class MaterialHelper {
  10252. /**
  10253. * Bind the current view position to an effect.
  10254. * @param effect The effect to be bound
  10255. * @param scene The scene the eyes position is used from
  10256. */
  10257. static BindEyePosition(effect: Effect, scene: Scene): void;
  10258. /**
  10259. * Helps preparing the defines values about the UVs in used in the effect.
  10260. * UVs are shared as much as we can accross channels in the shaders.
  10261. * @param texture The texture we are preparing the UVs for
  10262. * @param defines The defines to update
  10263. * @param key The channel key "diffuse", "specular"... used in the shader
  10264. */
  10265. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10266. /**
  10267. * Binds a texture matrix value to its corrsponding uniform
  10268. * @param texture The texture to bind the matrix for
  10269. * @param uniformBuffer The uniform buffer receivin the data
  10270. * @param key The channel key "diffuse", "specular"... used in the shader
  10271. */
  10272. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10273. /**
  10274. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10275. * @param mesh defines the current mesh
  10276. * @param scene defines the current scene
  10277. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10278. * @param pointsCloud defines if point cloud rendering has to be turned on
  10279. * @param fogEnabled defines if fog has to be turned on
  10280. * @param alphaTest defines if alpha testing has to be turned on
  10281. * @param defines defines the current list of defines
  10282. */
  10283. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10284. /**
  10285. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10286. * @param scene defines the current scene
  10287. * @param engine defines the current engine
  10288. * @param defines specifies the list of active defines
  10289. * @param useInstances defines if instances have to be turned on
  10290. * @param useClipPlane defines if clip plane have to be turned on
  10291. */
  10292. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10293. /**
  10294. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10295. * @param mesh The mesh containing the geometry data we will draw
  10296. * @param defines The defines to update
  10297. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10298. * @param useBones Precise whether bones should be used or not (override mesh info)
  10299. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10300. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10301. * @returns false if defines are considered not dirty and have not been checked
  10302. */
  10303. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10304. /**
  10305. * Prepares the defines related to the light information passed in parameter
  10306. * @param scene The scene we are intending to draw
  10307. * @param mesh The mesh the effect is compiling for
  10308. * @param defines The defines to update
  10309. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10310. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10311. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10312. * @returns true if normals will be required for the rest of the effect
  10313. */
  10314. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10315. /**
  10316. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  10317. * that won t be acctive due to defines being turned off.
  10318. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10319. * @param samplersList The samplers list
  10320. * @param defines The defines helping in the list generation
  10321. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10322. */
  10323. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  10324. /**
  10325. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  10326. * @param defines The defines to update while falling back
  10327. * @param fallbacks The authorized effect fallbacks
  10328. * @param maxSimultaneousLights The maximum number of lights allowed
  10329. * @param rank the current rank of the Effect
  10330. * @returns The newly affected rank
  10331. */
  10332. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  10333. /**
  10334. * Prepares the list of attributes required for morph targets according to the effect defines.
  10335. * @param attribs The current list of supported attribs
  10336. * @param mesh The mesh to prepare the morph targets attributes for
  10337. * @param defines The current Defines of the effect
  10338. */
  10339. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  10340. /**
  10341. * Prepares the list of attributes required for bones according to the effect defines.
  10342. * @param attribs The current list of supported attribs
  10343. * @param mesh The mesh to prepare the bones attributes for
  10344. * @param defines The current Defines of the effect
  10345. * @param fallbacks The current efffect fallback strategy
  10346. */
  10347. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  10348. /**
  10349. * Prepares the list of attributes required for instances according to the effect defines.
  10350. * @param attribs The current list of supported attribs
  10351. * @param defines The current Defines of the effect
  10352. */
  10353. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  10354. /**
  10355. * Binds the light shadow information to the effect for the given mesh.
  10356. * @param light The light containing the generator
  10357. * @param scene The scene the lights belongs to
  10358. * @param mesh The mesh we are binding the information to render
  10359. * @param lightIndex The light index in the effect used to render the mesh
  10360. * @param effect The effect we are binding the data to
  10361. */
  10362. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  10363. /**
  10364. * Binds the light information to the effect.
  10365. * @param light The light containing the generator
  10366. * @param effect The effect we are binding the data to
  10367. * @param lightIndex The light index in the effect used to render
  10368. */
  10369. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  10370. /**
  10371. * Binds the lights information from the scene to the effect for the given mesh.
  10372. * @param scene The scene the lights belongs to
  10373. * @param mesh The mesh we are binding the information to render
  10374. * @param effect The effect we are binding the data to
  10375. * @param defines The generated defines for the effect
  10376. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  10377. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10378. */
  10379. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  10380. private static _tempFogColor;
  10381. /**
  10382. * Binds the fog information from the scene to the effect for the given mesh.
  10383. * @param scene The scene the lights belongs to
  10384. * @param mesh The mesh we are binding the information to render
  10385. * @param effect The effect we are binding the data to
  10386. * @param linearSpace Defines if the fog effect is applied in linear space
  10387. */
  10388. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  10389. /**
  10390. * Binds the bones information from the mesh to the effect.
  10391. * @param mesh The mesh we are binding the information to render
  10392. * @param effect The effect we are binding the data to
  10393. */
  10394. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  10395. /**
  10396. * Binds the morph targets information from the mesh to the effect.
  10397. * @param abstractMesh The mesh we are binding the information to render
  10398. * @param effect The effect we are binding the data to
  10399. */
  10400. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  10401. /**
  10402. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  10403. * @param defines The generated defines used in the effect
  10404. * @param effect The effect we are binding the data to
  10405. * @param scene The scene we are willing to render with logarithmic scale for
  10406. */
  10407. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  10408. /**
  10409. * Binds the clip plane information from the scene to the effect.
  10410. * @param scene The scene the clip plane information are extracted from
  10411. * @param effect The effect we are binding the data to
  10412. */
  10413. static BindClipPlane(effect: Effect, scene: Scene): void;
  10414. }
  10415. }
  10416. declare module BABYLON {
  10417. /** @hidden */
  10418. export var shadowMapPixelShader: {
  10419. name: string;
  10420. shader: string;
  10421. };
  10422. }
  10423. declare module BABYLON {
  10424. /** @hidden */
  10425. export var bonesDeclaration: {
  10426. name: string;
  10427. shader: string;
  10428. };
  10429. }
  10430. declare module BABYLON {
  10431. /** @hidden */
  10432. export var morphTargetsVertexGlobalDeclaration: {
  10433. name: string;
  10434. shader: string;
  10435. };
  10436. }
  10437. declare module BABYLON {
  10438. /** @hidden */
  10439. export var morphTargetsVertexDeclaration: {
  10440. name: string;
  10441. shader: string;
  10442. };
  10443. }
  10444. declare module BABYLON {
  10445. /** @hidden */
  10446. export var instancesDeclaration: {
  10447. name: string;
  10448. shader: string;
  10449. };
  10450. }
  10451. declare module BABYLON {
  10452. /** @hidden */
  10453. export var helperFunctions: {
  10454. name: string;
  10455. shader: string;
  10456. };
  10457. }
  10458. declare module BABYLON {
  10459. /** @hidden */
  10460. export var morphTargetsVertex: {
  10461. name: string;
  10462. shader: string;
  10463. };
  10464. }
  10465. declare module BABYLON {
  10466. /** @hidden */
  10467. export var instancesVertex: {
  10468. name: string;
  10469. shader: string;
  10470. };
  10471. }
  10472. declare module BABYLON {
  10473. /** @hidden */
  10474. export var bonesVertex: {
  10475. name: string;
  10476. shader: string;
  10477. };
  10478. }
  10479. declare module BABYLON {
  10480. /** @hidden */
  10481. export var shadowMapVertexShader: {
  10482. name: string;
  10483. shader: string;
  10484. };
  10485. }
  10486. declare module BABYLON {
  10487. /** @hidden */
  10488. export var depthBoxBlurPixelShader: {
  10489. name: string;
  10490. shader: string;
  10491. };
  10492. }
  10493. declare module BABYLON {
  10494. /**
  10495. * Defines the options associated with the creation of a custom shader for a shadow generator.
  10496. */
  10497. export interface ICustomShaderOptions {
  10498. /**
  10499. * Gets or sets the custom shader name to use
  10500. */
  10501. shaderName: string;
  10502. /**
  10503. * The list of attribute names used in the shader
  10504. */
  10505. attributes?: string[];
  10506. /**
  10507. * The list of unifrom names used in the shader
  10508. */
  10509. uniforms?: string[];
  10510. /**
  10511. * The list of sampler names used in the shader
  10512. */
  10513. samplers?: string[];
  10514. /**
  10515. * The list of defines used in the shader
  10516. */
  10517. defines?: string[];
  10518. }
  10519. /**
  10520. * Interface to implement to create a shadow generator compatible with BJS.
  10521. */
  10522. export interface IShadowGenerator {
  10523. /**
  10524. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10525. * @returns The render target texture if present otherwise, null
  10526. */
  10527. getShadowMap(): Nullable<RenderTargetTexture>;
  10528. /**
  10529. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10530. * @returns The render target texture if the shadow map is present otherwise, null
  10531. */
  10532. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10533. /**
  10534. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10535. * @param subMesh The submesh we want to render in the shadow map
  10536. * @param useInstances Defines wether will draw in the map using instances
  10537. * @returns true if ready otherwise, false
  10538. */
  10539. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10540. /**
  10541. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10542. * @param defines Defines of the material we want to update
  10543. * @param lightIndex Index of the light in the enabled light list of the material
  10544. */
  10545. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  10546. /**
  10547. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10548. * defined in the generator but impacting the effect).
  10549. * It implies the unifroms available on the materials are the standard BJS ones.
  10550. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10551. * @param effect The effect we are binfing the information for
  10552. */
  10553. bindShadowLight(lightIndex: string, effect: Effect): void;
  10554. /**
  10555. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10556. * (eq to shadow prjection matrix * light transform matrix)
  10557. * @returns The transform matrix used to create the shadow map
  10558. */
  10559. getTransformMatrix(): Matrix;
  10560. /**
  10561. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10562. * Cube and 2D textures for instance.
  10563. */
  10564. recreateShadowMap(): void;
  10565. /**
  10566. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10567. * @param onCompiled Callback triggered at the and of the effects compilation
  10568. * @param options Sets of optional options forcing the compilation with different modes
  10569. */
  10570. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10571. useInstances: boolean;
  10572. }>): void;
  10573. /**
  10574. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10575. * @param options Sets of optional options forcing the compilation with different modes
  10576. * @returns A promise that resolves when the compilation completes
  10577. */
  10578. forceCompilationAsync(options?: Partial<{
  10579. useInstances: boolean;
  10580. }>): Promise<void>;
  10581. /**
  10582. * Serializes the shadow generator setup to a json object.
  10583. * @returns The serialized JSON object
  10584. */
  10585. serialize(): any;
  10586. /**
  10587. * Disposes the Shadow map and related Textures and effects.
  10588. */
  10589. dispose(): void;
  10590. }
  10591. /**
  10592. * Default implementation IShadowGenerator.
  10593. * This is the main object responsible of generating shadows in the framework.
  10594. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  10595. */
  10596. export class ShadowGenerator implements IShadowGenerator {
  10597. /**
  10598. * Shadow generator mode None: no filtering applied.
  10599. */
  10600. static readonly FILTER_NONE: number;
  10601. /**
  10602. * Shadow generator mode ESM: Exponential Shadow Mapping.
  10603. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10604. */
  10605. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  10606. /**
  10607. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  10608. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  10609. */
  10610. static readonly FILTER_POISSONSAMPLING: number;
  10611. /**
  10612. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  10613. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10614. */
  10615. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  10616. /**
  10617. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  10618. * edge artifacts on steep falloff.
  10619. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10620. */
  10621. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  10622. /**
  10623. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  10624. * edge artifacts on steep falloff.
  10625. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10626. */
  10627. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  10628. /**
  10629. * Shadow generator mode PCF: Percentage Closer Filtering
  10630. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10631. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  10632. */
  10633. static readonly FILTER_PCF: number;
  10634. /**
  10635. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10636. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10637. * Contact Hardening
  10638. */
  10639. static readonly FILTER_PCSS: number;
  10640. /**
  10641. * Reserved for PCF and PCSS
  10642. * Highest Quality.
  10643. *
  10644. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10645. *
  10646. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10647. */
  10648. static readonly QUALITY_HIGH: number;
  10649. /**
  10650. * Reserved for PCF and PCSS
  10651. * Good tradeoff for quality/perf cross devices
  10652. *
  10653. * Execute PCF on a 3*3 kernel.
  10654. *
  10655. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10656. */
  10657. static readonly QUALITY_MEDIUM: number;
  10658. /**
  10659. * Reserved for PCF and PCSS
  10660. * The lowest quality but the fastest.
  10661. *
  10662. * Execute PCF on a 1*1 kernel.
  10663. *
  10664. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10665. */
  10666. static readonly QUALITY_LOW: number;
  10667. /** Gets or sets the custom shader name to use */
  10668. customShaderOptions: ICustomShaderOptions;
  10669. /**
  10670. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10671. */
  10672. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10673. private _bias;
  10674. /**
  10675. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10676. */
  10677. /**
  10678. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10679. */
  10680. bias: number;
  10681. private _normalBias;
  10682. /**
  10683. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10684. */
  10685. /**
  10686. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10687. */
  10688. normalBias: number;
  10689. private _blurBoxOffset;
  10690. /**
  10691. * Gets the blur box offset: offset applied during the blur pass.
  10692. * Only useful if useKernelBlur = false
  10693. */
  10694. /**
  10695. * Sets the blur box offset: offset applied during the blur pass.
  10696. * Only useful if useKernelBlur = false
  10697. */
  10698. blurBoxOffset: number;
  10699. private _blurScale;
  10700. /**
  10701. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10702. * 2 means half of the size.
  10703. */
  10704. /**
  10705. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10706. * 2 means half of the size.
  10707. */
  10708. blurScale: number;
  10709. private _blurKernel;
  10710. /**
  10711. * Gets the blur kernel: kernel size of the blur pass.
  10712. * Only useful if useKernelBlur = true
  10713. */
  10714. /**
  10715. * Sets the blur kernel: kernel size of the blur pass.
  10716. * Only useful if useKernelBlur = true
  10717. */
  10718. blurKernel: number;
  10719. private _useKernelBlur;
  10720. /**
  10721. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10722. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10723. */
  10724. /**
  10725. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10726. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10727. */
  10728. useKernelBlur: boolean;
  10729. private _depthScale;
  10730. /**
  10731. * Gets the depth scale used in ESM mode.
  10732. */
  10733. /**
  10734. * Sets the depth scale used in ESM mode.
  10735. * This can override the scale stored on the light.
  10736. */
  10737. depthScale: number;
  10738. private _filter;
  10739. /**
  10740. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10741. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10742. */
  10743. /**
  10744. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10745. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10746. */
  10747. filter: number;
  10748. /**
  10749. * Gets if the current filter is set to Poisson Sampling.
  10750. */
  10751. /**
  10752. * Sets the current filter to Poisson Sampling.
  10753. */
  10754. usePoissonSampling: boolean;
  10755. /**
  10756. * Gets if the current filter is set to ESM.
  10757. */
  10758. /**
  10759. * Sets the current filter is to ESM.
  10760. */
  10761. useExponentialShadowMap: boolean;
  10762. /**
  10763. * Gets if the current filter is set to filtered ESM.
  10764. */
  10765. /**
  10766. * Gets if the current filter is set to filtered ESM.
  10767. */
  10768. useBlurExponentialShadowMap: boolean;
  10769. /**
  10770. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10771. * exponential to prevent steep falloff artifacts).
  10772. */
  10773. /**
  10774. * Sets the current filter to "close ESM" (using the inverse of the
  10775. * exponential to prevent steep falloff artifacts).
  10776. */
  10777. useCloseExponentialShadowMap: boolean;
  10778. /**
  10779. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10780. * exponential to prevent steep falloff artifacts).
  10781. */
  10782. /**
  10783. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10784. * exponential to prevent steep falloff artifacts).
  10785. */
  10786. useBlurCloseExponentialShadowMap: boolean;
  10787. /**
  10788. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10789. */
  10790. /**
  10791. * Sets the current filter to "PCF" (percentage closer filtering).
  10792. */
  10793. usePercentageCloserFiltering: boolean;
  10794. private _filteringQuality;
  10795. /**
  10796. * Gets the PCF or PCSS Quality.
  10797. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10798. */
  10799. /**
  10800. * Sets the PCF or PCSS Quality.
  10801. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10802. */
  10803. filteringQuality: number;
  10804. /**
  10805. * Gets if the current filter is set to "PCSS" (contact hardening).
  10806. */
  10807. /**
  10808. * Sets the current filter to "PCSS" (contact hardening).
  10809. */
  10810. useContactHardeningShadow: boolean;
  10811. private _contactHardeningLightSizeUVRatio;
  10812. /**
  10813. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10814. * Using a ratio helps keeping shape stability independently of the map size.
  10815. *
  10816. * It does not account for the light projection as it was having too much
  10817. * instability during the light setup or during light position changes.
  10818. *
  10819. * Only valid if useContactHardeningShadow is true.
  10820. */
  10821. /**
  10822. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10823. * Using a ratio helps keeping shape stability independently of the map size.
  10824. *
  10825. * It does not account for the light projection as it was having too much
  10826. * instability during the light setup or during light position changes.
  10827. *
  10828. * Only valid if useContactHardeningShadow is true.
  10829. */
  10830. contactHardeningLightSizeUVRatio: number;
  10831. private _darkness;
  10832. /**
  10833. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10834. * 0 means strongest and 1 would means no shadow.
  10835. * @returns the darkness.
  10836. */
  10837. getDarkness(): number;
  10838. /**
  10839. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10840. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10841. * @returns the shadow generator allowing fluent coding.
  10842. */
  10843. setDarkness(darkness: number): ShadowGenerator;
  10844. private _transparencyShadow;
  10845. /**
  10846. * Sets the ability to have transparent shadow (boolean).
  10847. * @param transparent True if transparent else False
  10848. * @returns the shadow generator allowing fluent coding
  10849. */
  10850. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10851. private _shadowMap;
  10852. private _shadowMap2;
  10853. /**
  10854. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10855. * @returns The render target texture if present otherwise, null
  10856. */
  10857. getShadowMap(): Nullable<RenderTargetTexture>;
  10858. /**
  10859. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10860. * @returns The render target texture if the shadow map is present otherwise, null
  10861. */
  10862. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10863. /**
  10864. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10865. * @param mesh Mesh to add
  10866. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10867. * @returns the Shadow Generator itself
  10868. */
  10869. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10870. /**
  10871. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10872. * @param mesh Mesh to remove
  10873. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10874. * @returns the Shadow Generator itself
  10875. */
  10876. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10877. /**
  10878. * Controls the extent to which the shadows fade out at the edge of the frustum
  10879. * Used only by directionals and spots
  10880. */
  10881. frustumEdgeFalloff: number;
  10882. private _light;
  10883. /**
  10884. * Returns the associated light object.
  10885. * @returns the light generating the shadow
  10886. */
  10887. getLight(): IShadowLight;
  10888. /**
  10889. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10890. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10891. * It might on the other hand introduce peter panning.
  10892. */
  10893. forceBackFacesOnly: boolean;
  10894. private _scene;
  10895. private _lightDirection;
  10896. private _effect;
  10897. private _viewMatrix;
  10898. private _projectionMatrix;
  10899. private _transformMatrix;
  10900. private _cachedPosition;
  10901. private _cachedDirection;
  10902. private _cachedDefines;
  10903. private _currentRenderID;
  10904. private _boxBlurPostprocess;
  10905. private _kernelBlurXPostprocess;
  10906. private _kernelBlurYPostprocess;
  10907. private _blurPostProcesses;
  10908. private _mapSize;
  10909. private _currentFaceIndex;
  10910. private _currentFaceIndexCache;
  10911. private _textureType;
  10912. private _defaultTextureMatrix;
  10913. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  10914. /**
  10915. * Creates a ShadowGenerator object.
  10916. * A ShadowGenerator is the required tool to use the shadows.
  10917. * Each light casting shadows needs to use its own ShadowGenerator.
  10918. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10919. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10920. * @param light The light object generating the shadows.
  10921. * @param usefulFloatFirst 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.
  10922. */
  10923. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10924. private _initializeGenerator;
  10925. private _initializeShadowMap;
  10926. private _initializeBlurRTTAndPostProcesses;
  10927. private _renderForShadowMap;
  10928. private _renderSubMeshForShadowMap;
  10929. private _applyFilterValues;
  10930. /**
  10931. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10932. * @param onCompiled Callback triggered at the and of the effects compilation
  10933. * @param options Sets of optional options forcing the compilation with different modes
  10934. */
  10935. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10936. useInstances: boolean;
  10937. }>): void;
  10938. /**
  10939. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10940. * @param options Sets of optional options forcing the compilation with different modes
  10941. * @returns A promise that resolves when the compilation completes
  10942. */
  10943. forceCompilationAsync(options?: Partial<{
  10944. useInstances: boolean;
  10945. }>): Promise<void>;
  10946. /**
  10947. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10948. * @param subMesh The submesh we want to render in the shadow map
  10949. * @param useInstances Defines wether will draw in the map using instances
  10950. * @returns true if ready otherwise, false
  10951. */
  10952. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10953. /**
  10954. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10955. * @param defines Defines of the material we want to update
  10956. * @param lightIndex Index of the light in the enabled light list of the material
  10957. */
  10958. prepareDefines(defines: any, lightIndex: number): void;
  10959. /**
  10960. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10961. * defined in the generator but impacting the effect).
  10962. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10963. * @param effect The effect we are binfing the information for
  10964. */
  10965. bindShadowLight(lightIndex: string, effect: Effect): void;
  10966. /**
  10967. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10968. * (eq to shadow prjection matrix * light transform matrix)
  10969. * @returns The transform matrix used to create the shadow map
  10970. */
  10971. getTransformMatrix(): Matrix;
  10972. /**
  10973. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10974. * Cube and 2D textures for instance.
  10975. */
  10976. recreateShadowMap(): void;
  10977. private _disposeBlurPostProcesses;
  10978. private _disposeRTTandPostProcesses;
  10979. /**
  10980. * Disposes the ShadowGenerator.
  10981. * Returns nothing.
  10982. */
  10983. dispose(): void;
  10984. /**
  10985. * Serializes the shadow generator setup to a json object.
  10986. * @returns The serialized JSON object
  10987. */
  10988. serialize(): any;
  10989. /**
  10990. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10991. * @param parsedShadowGenerator The JSON object to parse
  10992. * @param scene The scene to create the shadow map for
  10993. * @returns The parsed shadow generator
  10994. */
  10995. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10996. }
  10997. }
  10998. declare module BABYLON {
  10999. /**
  11000. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11001. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11002. * 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.
  11003. */
  11004. export abstract class Light extends Node {
  11005. /**
  11006. * Falloff Default: light is falling off following the material specification:
  11007. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11008. */
  11009. static readonly FALLOFF_DEFAULT: number;
  11010. /**
  11011. * Falloff Physical: light is falling off following the inverse squared distance law.
  11012. */
  11013. static readonly FALLOFF_PHYSICAL: number;
  11014. /**
  11015. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11016. * to enhance interoperability with other engines.
  11017. */
  11018. static readonly FALLOFF_GLTF: number;
  11019. /**
  11020. * Falloff Standard: light is falling off like in the standard material
  11021. * to enhance interoperability with other materials.
  11022. */
  11023. static readonly FALLOFF_STANDARD: number;
  11024. /**
  11025. * If every light affecting the material is in this lightmapMode,
  11026. * material.lightmapTexture adds or multiplies
  11027. * (depends on material.useLightmapAsShadowmap)
  11028. * after every other light calculations.
  11029. */
  11030. static readonly LIGHTMAP_DEFAULT: number;
  11031. /**
  11032. * material.lightmapTexture as only diffuse lighting from this light
  11033. * adds only specular lighting from this light
  11034. * adds dynamic shadows
  11035. */
  11036. static readonly LIGHTMAP_SPECULAR: number;
  11037. /**
  11038. * material.lightmapTexture as only lighting
  11039. * no light calculation from this light
  11040. * only adds dynamic shadows from this light
  11041. */
  11042. static readonly LIGHTMAP_SHADOWSONLY: number;
  11043. /**
  11044. * Each light type uses the default quantity according to its type:
  11045. * point/spot lights use luminous intensity
  11046. * directional lights use illuminance
  11047. */
  11048. static readonly INTENSITYMODE_AUTOMATIC: number;
  11049. /**
  11050. * lumen (lm)
  11051. */
  11052. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11053. /**
  11054. * candela (lm/sr)
  11055. */
  11056. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11057. /**
  11058. * lux (lm/m^2)
  11059. */
  11060. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11061. /**
  11062. * nit (cd/m^2)
  11063. */
  11064. static readonly INTENSITYMODE_LUMINANCE: number;
  11065. /**
  11066. * Light type const id of the point light.
  11067. */
  11068. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11069. /**
  11070. * Light type const id of the directional light.
  11071. */
  11072. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11073. /**
  11074. * Light type const id of the spot light.
  11075. */
  11076. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11077. /**
  11078. * Light type const id of the hemispheric light.
  11079. */
  11080. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11081. /**
  11082. * Diffuse gives the basic color to an object.
  11083. */
  11084. diffuse: Color3;
  11085. /**
  11086. * Specular produces a highlight color on an object.
  11087. * Note: This is note affecting PBR materials.
  11088. */
  11089. specular: Color3;
  11090. /**
  11091. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11092. * falling off base on range or angle.
  11093. * This can be set to any values in Light.FALLOFF_x.
  11094. *
  11095. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11096. * other types of materials.
  11097. */
  11098. falloffType: number;
  11099. /**
  11100. * Strength of the light.
  11101. * Note: By default it is define in the framework own unit.
  11102. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11103. */
  11104. intensity: number;
  11105. private _range;
  11106. protected _inverseSquaredRange: number;
  11107. /**
  11108. * Defines how far from the source the light is impacting in scene units.
  11109. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11110. */
  11111. /**
  11112. * Defines how far from the source the light is impacting in scene units.
  11113. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11114. */
  11115. range: number;
  11116. /**
  11117. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11118. * of light.
  11119. */
  11120. private _photometricScale;
  11121. private _intensityMode;
  11122. /**
  11123. * Gets the photometric scale used to interpret the intensity.
  11124. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11125. */
  11126. /**
  11127. * Sets the photometric scale used to interpret the intensity.
  11128. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11129. */
  11130. intensityMode: number;
  11131. private _radius;
  11132. /**
  11133. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11134. */
  11135. /**
  11136. * sets the light radius used by PBR Materials to simulate soft area lights.
  11137. */
  11138. radius: number;
  11139. private _renderPriority;
  11140. /**
  11141. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11142. * exceeding the number allowed of the materials.
  11143. */
  11144. renderPriority: number;
  11145. private _shadowEnabled;
  11146. /**
  11147. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11148. * the current shadow generator.
  11149. */
  11150. /**
  11151. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11152. * the current shadow generator.
  11153. */
  11154. shadowEnabled: boolean;
  11155. private _includedOnlyMeshes;
  11156. /**
  11157. * Gets the only meshes impacted by this light.
  11158. */
  11159. /**
  11160. * Sets the only meshes impacted by this light.
  11161. */
  11162. includedOnlyMeshes: AbstractMesh[];
  11163. private _excludedMeshes;
  11164. /**
  11165. * Gets the meshes not impacted by this light.
  11166. */
  11167. /**
  11168. * Sets the meshes not impacted by this light.
  11169. */
  11170. excludedMeshes: AbstractMesh[];
  11171. private _excludeWithLayerMask;
  11172. /**
  11173. * Gets the layer id use to find what meshes are not impacted by the light.
  11174. * Inactive if 0
  11175. */
  11176. /**
  11177. * Sets the layer id use to find what meshes are not impacted by the light.
  11178. * Inactive if 0
  11179. */
  11180. excludeWithLayerMask: number;
  11181. private _includeOnlyWithLayerMask;
  11182. /**
  11183. * Gets the layer id use to find what meshes are impacted by the light.
  11184. * Inactive if 0
  11185. */
  11186. /**
  11187. * Sets the layer id use to find what meshes are impacted by the light.
  11188. * Inactive if 0
  11189. */
  11190. includeOnlyWithLayerMask: number;
  11191. private _lightmapMode;
  11192. /**
  11193. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11194. */
  11195. /**
  11196. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11197. */
  11198. lightmapMode: number;
  11199. /**
  11200. * Shadow generator associted to the light.
  11201. * @hidden Internal use only.
  11202. */ shadowGenerator: Nullable<IShadowGenerator>;
  11203. /**
  11204. * @hidden Internal use only.
  11205. */ excludedMeshesIds: string[];
  11206. /**
  11207. * @hidden Internal use only.
  11208. */ includedOnlyMeshesIds: string[];
  11209. /**
  11210. * The current light unifom buffer.
  11211. * @hidden Internal use only.
  11212. */ uniformBuffer: UniformBuffer;
  11213. /**
  11214. * Creates a Light object in the scene.
  11215. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11216. * @param name The firendly name of the light
  11217. * @param scene The scene the light belongs too
  11218. */
  11219. constructor(name: string, scene: Scene);
  11220. protected abstract _buildUniformLayout(): void;
  11221. /**
  11222. * Sets the passed Effect "effect" with the Light information.
  11223. * @param effect The effect to update
  11224. * @param lightIndex The index of the light in the effect to update
  11225. * @returns The light
  11226. */
  11227. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11228. /**
  11229. * Returns the string "Light".
  11230. * @returns the class name
  11231. */
  11232. getClassName(): string;
  11233. /** @hidden */ protected readonly _isLight: boolean;
  11234. /**
  11235. * Converts the light information to a readable string for debug purpose.
  11236. * @param fullDetails Supports for multiple levels of logging within scene loading
  11237. * @returns the human readable light info
  11238. */
  11239. toString(fullDetails?: boolean): string;
  11240. /** @hidden */
  11241. protected _syncParentEnabledState(): void;
  11242. /**
  11243. * Set the enabled state of this node.
  11244. * @param value - the new enabled state
  11245. */
  11246. setEnabled(value: boolean): void;
  11247. /**
  11248. * Returns the Light associated shadow generator if any.
  11249. * @return the associated shadow generator.
  11250. */
  11251. getShadowGenerator(): Nullable<IShadowGenerator>;
  11252. /**
  11253. * Returns a Vector3, the absolute light position in the World.
  11254. * @returns the world space position of the light
  11255. */
  11256. getAbsolutePosition(): Vector3;
  11257. /**
  11258. * Specifies if the light will affect the passed mesh.
  11259. * @param mesh The mesh to test against the light
  11260. * @return true the mesh is affected otherwise, false.
  11261. */
  11262. canAffectMesh(mesh: AbstractMesh): boolean;
  11263. /**
  11264. * Sort function to order lights for rendering.
  11265. * @param a First Light object to compare to second.
  11266. * @param b Second Light object to compare first.
  11267. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11268. */
  11269. static CompareLightsPriority(a: Light, b: Light): number;
  11270. /**
  11271. * Releases resources associated with this node.
  11272. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11273. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11274. */
  11275. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11276. /**
  11277. * Returns the light type ID (integer).
  11278. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11279. */
  11280. getTypeID(): number;
  11281. /**
  11282. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11283. * @returns the scaled intensity in intensity mode unit
  11284. */
  11285. getScaledIntensity(): number;
  11286. /**
  11287. * Returns a new Light object, named "name", from the current one.
  11288. * @param name The name of the cloned light
  11289. * @returns the new created light
  11290. */
  11291. clone(name: string): Nullable<Light>;
  11292. /**
  11293. * Serializes the current light into a Serialization object.
  11294. * @returns the serialized object.
  11295. */
  11296. serialize(): any;
  11297. /**
  11298. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11299. * This new light is named "name" and added to the passed scene.
  11300. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11301. * @param name The friendly name of the light
  11302. * @param scene The scene the new light will belong to
  11303. * @returns the constructor function
  11304. */
  11305. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11306. /**
  11307. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11308. * @param parsedLight The JSON representation of the light
  11309. * @param scene The scene to create the parsed light in
  11310. * @returns the created light after parsing
  11311. */
  11312. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11313. private _hookArrayForExcluded;
  11314. private _hookArrayForIncludedOnly;
  11315. private _resyncMeshes;
  11316. /**
  11317. * Forces the meshes to update their light related information in their rendering used effects
  11318. * @hidden Internal Use Only
  11319. */ markMeshesAsLightDirty(): void;
  11320. /**
  11321. * Recomputes the cached photometric scale if needed.
  11322. */
  11323. private _computePhotometricScale;
  11324. /**
  11325. * Returns the Photometric Scale according to the light type and intensity mode.
  11326. */
  11327. private _getPhotometricScale;
  11328. /**
  11329. * Reorder the light in the scene according to their defined priority.
  11330. * @hidden Internal Use Only
  11331. */ reorderLightsInScene(): void;
  11332. /**
  11333. * Prepares the list of defines specific to the light type.
  11334. * @param defines the list of defines
  11335. * @param lightIndex defines the index of the light for the effect
  11336. */
  11337. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11338. }
  11339. }
  11340. declare module BABYLON {
  11341. /**
  11342. * The HemisphericLight simulates the ambient environment light,
  11343. * so the passed direction is the light reflection direction, not the incoming direction.
  11344. */
  11345. export class HemisphericLight extends Light {
  11346. /**
  11347. * The groundColor is the light in the opposite direction to the one specified during creation.
  11348. * 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.
  11349. */
  11350. groundColor: Color3;
  11351. /**
  11352. * The light reflection direction, not the incoming direction.
  11353. */
  11354. direction: Vector3;
  11355. /**
  11356. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11357. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11358. * The HemisphericLight can't cast shadows.
  11359. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11360. * @param name The friendly name of the light
  11361. * @param direction The direction of the light reflection
  11362. * @param scene The scene the light belongs to
  11363. */
  11364. constructor(name: string, direction: Vector3, scene: Scene);
  11365. protected _buildUniformLayout(): void;
  11366. /**
  11367. * Returns the string "HemisphericLight".
  11368. * @return The class name
  11369. */
  11370. getClassName(): string;
  11371. /**
  11372. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11373. * Returns the updated direction.
  11374. * @param target The target the direction should point to
  11375. * @return The computed direction
  11376. */
  11377. setDirectionToTarget(target: Vector3): Vector3;
  11378. /**
  11379. * Returns the shadow generator associated to the light.
  11380. * @returns Always null for hemispheric lights because it does not support shadows.
  11381. */
  11382. getShadowGenerator(): Nullable<IShadowGenerator>;
  11383. /**
  11384. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11385. * @param effect The effect to update
  11386. * @param lightIndex The index of the light in the effect to update
  11387. * @returns The hemispheric light
  11388. */
  11389. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11390. /**
  11391. * Computes the world matrix of the node
  11392. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  11393. * @param useWasUpdatedFlag defines a reserved property
  11394. * @returns the world matrix
  11395. */
  11396. computeWorldMatrix(): Matrix;
  11397. /**
  11398. * Returns the integer 3.
  11399. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11400. */
  11401. getTypeID(): number;
  11402. /**
  11403. * Prepares the list of defines specific to the light type.
  11404. * @param defines the list of defines
  11405. * @param lightIndex defines the index of the light for the effect
  11406. */
  11407. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11408. }
  11409. }
  11410. declare module BABYLON {
  11411. /**
  11412. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  11413. * IMPORTANT!! The data is right-hand data.
  11414. * @export
  11415. * @interface DevicePose
  11416. */
  11417. export interface DevicePose {
  11418. /**
  11419. * The position of the device, values in array are [x,y,z].
  11420. */
  11421. readonly position: Nullable<Float32Array>;
  11422. /**
  11423. * The linearVelocity of the device, values in array are [x,y,z].
  11424. */
  11425. readonly linearVelocity: Nullable<Float32Array>;
  11426. /**
  11427. * The linearAcceleration of the device, values in array are [x,y,z].
  11428. */
  11429. readonly linearAcceleration: Nullable<Float32Array>;
  11430. /**
  11431. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  11432. */
  11433. readonly orientation: Nullable<Float32Array>;
  11434. /**
  11435. * The angularVelocity of the device, values in array are [x,y,z].
  11436. */
  11437. readonly angularVelocity: Nullable<Float32Array>;
  11438. /**
  11439. * The angularAcceleration of the device, values in array are [x,y,z].
  11440. */
  11441. readonly angularAcceleration: Nullable<Float32Array>;
  11442. }
  11443. /**
  11444. * Interface representing a pose controlled object in Babylon.
  11445. * A pose controlled object has both regular pose values as well as pose values
  11446. * from an external device such as a VR head mounted display
  11447. */
  11448. export interface PoseControlled {
  11449. /**
  11450. * The position of the object in babylon space.
  11451. */
  11452. position: Vector3;
  11453. /**
  11454. * The rotation quaternion of the object in babylon space.
  11455. */
  11456. rotationQuaternion: Quaternion;
  11457. /**
  11458. * The position of the device in babylon space.
  11459. */
  11460. devicePosition?: Vector3;
  11461. /**
  11462. * The rotation quaternion of the device in babylon space.
  11463. */
  11464. deviceRotationQuaternion: Quaternion;
  11465. /**
  11466. * The raw pose coming from the device.
  11467. */
  11468. rawPose: Nullable<DevicePose>;
  11469. /**
  11470. * The scale of the device to be used when translating from device space to babylon space.
  11471. */
  11472. deviceScaleFactor: number;
  11473. /**
  11474. * Updates the poseControlled values based on the input device pose.
  11475. * @param poseData the pose data to update the object with
  11476. */
  11477. updateFromDevice(poseData: DevicePose): void;
  11478. }
  11479. /**
  11480. * Set of options to customize the webVRCamera
  11481. */
  11482. export interface WebVROptions {
  11483. /**
  11484. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  11485. */
  11486. trackPosition?: boolean;
  11487. /**
  11488. * Sets the scale of the vrDevice in babylon space. (default: 1)
  11489. */
  11490. positionScale?: number;
  11491. /**
  11492. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  11493. */
  11494. displayName?: string;
  11495. /**
  11496. * Should the native controller meshes be initialized. (default: true)
  11497. */
  11498. controllerMeshes?: boolean;
  11499. /**
  11500. * Creating a default HemiLight only on controllers. (default: true)
  11501. */
  11502. defaultLightingOnControllers?: boolean;
  11503. /**
  11504. * If you don't want to use the default VR button of the helper. (default: false)
  11505. */
  11506. useCustomVRButton?: boolean;
  11507. /**
  11508. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  11509. */
  11510. customVRButton?: HTMLButtonElement;
  11511. /**
  11512. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  11513. */
  11514. rayLength?: number;
  11515. /**
  11516. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  11517. */
  11518. defaultHeight?: number;
  11519. }
  11520. /**
  11521. * This represents a WebVR camera.
  11522. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  11523. * @example http://doc.babylonjs.com/how_to/webvr_camera
  11524. */
  11525. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  11526. private webVROptions;
  11527. /**
  11528. * @hidden
  11529. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  11530. */ vrDevice: any;
  11531. /**
  11532. * The rawPose of the vrDevice.
  11533. */
  11534. rawPose: Nullable<DevicePose>;
  11535. private _onVREnabled;
  11536. private _specsVersion;
  11537. private _attached;
  11538. private _frameData;
  11539. protected _descendants: Array<Node>;
  11540. private _deviceRoomPosition;
  11541. /** @hidden */ deviceRoomRotationQuaternion: Quaternion;
  11542. private _standingMatrix;
  11543. /**
  11544. * Represents device position in babylon space.
  11545. */
  11546. devicePosition: Vector3;
  11547. /**
  11548. * Represents device rotation in babylon space.
  11549. */
  11550. deviceRotationQuaternion: Quaternion;
  11551. /**
  11552. * The scale of the device to be used when translating from device space to babylon space.
  11553. */
  11554. deviceScaleFactor: number;
  11555. private _deviceToWorld;
  11556. private _worldToDevice;
  11557. /**
  11558. * References to the webVR controllers for the vrDevice.
  11559. */
  11560. controllers: Array<WebVRController>;
  11561. /**
  11562. * Emits an event when a controller is attached.
  11563. */
  11564. onControllersAttachedObservable: Observable<WebVRController[]>;
  11565. /**
  11566. * Emits an event when a controller's mesh has been loaded;
  11567. */
  11568. onControllerMeshLoadedObservable: Observable<WebVRController>;
  11569. /**
  11570. * Emits an event when the HMD's pose has been updated.
  11571. */
  11572. onPoseUpdatedFromDeviceObservable: Observable<any>;
  11573. private _poseSet;
  11574. /**
  11575. * If the rig cameras be used as parent instead of this camera.
  11576. */
  11577. rigParenting: boolean;
  11578. private _lightOnControllers;
  11579. private _defaultHeight?;
  11580. /**
  11581. * Instantiates a WebVRFreeCamera.
  11582. * @param name The name of the WebVRFreeCamera
  11583. * @param position The starting anchor position for the camera
  11584. * @param scene The scene the camera belongs to
  11585. * @param webVROptions a set of customizable options for the webVRCamera
  11586. */
  11587. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  11588. /**
  11589. * Gets the device distance from the ground in meters.
  11590. * @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.
  11591. */
  11592. deviceDistanceToRoomGround(): number;
  11593. /**
  11594. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11595. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  11596. */
  11597. useStandingMatrix(callback?: (bool: boolean) => void): void;
  11598. /**
  11599. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11600. * @returns A promise with a boolean set to if the standing matrix is supported.
  11601. */
  11602. useStandingMatrixAsync(): Promise<boolean>;
  11603. /**
  11604. * Disposes the camera
  11605. */
  11606. dispose(): void;
  11607. /**
  11608. * Gets a vrController by name.
  11609. * @param name The name of the controller to retreive
  11610. * @returns the controller matching the name specified or null if not found
  11611. */
  11612. getControllerByName(name: string): Nullable<WebVRController>;
  11613. private _leftController;
  11614. /**
  11615. * The controller corrisponding to the users left hand.
  11616. */
  11617. readonly leftController: Nullable<WebVRController>;
  11618. private _rightController;
  11619. /**
  11620. * The controller corrisponding to the users right hand.
  11621. */
  11622. readonly rightController: Nullable<WebVRController>;
  11623. /**
  11624. * Casts a ray forward from the vrCamera's gaze.
  11625. * @param length Length of the ray (default: 100)
  11626. * @returns the ray corrisponding to the gaze
  11627. */
  11628. getForwardRay(length?: number): Ray;
  11629. /**
  11630. * @hidden
  11631. * Updates the camera based on device's frame data
  11632. */ checkInputs(): void;
  11633. /**
  11634. * Updates the poseControlled values based on the input device pose.
  11635. * @param poseData Pose coming from the device
  11636. */
  11637. updateFromDevice(poseData: DevicePose): void;
  11638. private _htmlElementAttached;
  11639. private _detachIfAttached;
  11640. /**
  11641. * WebVR's attach control will start broadcasting frames to the device.
  11642. * Note that in certain browsers (chrome for example) this function must be called
  11643. * within a user-interaction callback. Example:
  11644. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  11645. *
  11646. * @param element html element to attach the vrDevice to
  11647. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  11648. */
  11649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11650. /**
  11651. * Detaches the camera from the html element and disables VR
  11652. *
  11653. * @param element html element to detach from
  11654. */
  11655. detachControl(element: HTMLElement): void;
  11656. /**
  11657. * @returns the name of this class
  11658. */
  11659. getClassName(): string;
  11660. /**
  11661. * Calls resetPose on the vrDisplay
  11662. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  11663. */
  11664. resetToCurrentRotation(): void;
  11665. /**
  11666. * @hidden
  11667. * Updates the rig cameras (left and right eye)
  11668. */ updateRigCameras(): void;
  11669. private _workingVector;
  11670. private _oneVector;
  11671. private _workingMatrix;
  11672. private updateCacheCalled;
  11673. private _correctPositionIfNotTrackPosition;
  11674. /**
  11675. * @hidden
  11676. * Updates the cached values of the camera
  11677. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  11678. */ updateCache(ignoreParentClass?: boolean): void;
  11679. /**
  11680. * @hidden
  11681. * Get current device position in babylon world
  11682. */ computeDevicePosition(): void;
  11683. /**
  11684. * Updates the current device position and rotation in the babylon world
  11685. */
  11686. update(): void;
  11687. /**
  11688. * @hidden
  11689. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  11690. * @returns an identity matrix
  11691. */ getViewMatrix(): Matrix;
  11692. private _tmpMatrix;
  11693. /**
  11694. * This function is called by the two RIG cameras.
  11695. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  11696. * @hidden
  11697. */ getWebVRViewMatrix(): Matrix;
  11698. /** @hidden */ getWebVRProjectionMatrix(): Matrix;
  11699. private _onGamepadConnectedObserver;
  11700. private _onGamepadDisconnectedObserver;
  11701. private _updateCacheWhenTrackingDisabledObserver;
  11702. /**
  11703. * Initializes the controllers and their meshes
  11704. */
  11705. initControllers(): void;
  11706. }
  11707. }
  11708. declare module BABYLON {
  11709. /**
  11710. * Size options for a post process
  11711. */
  11712. export type PostProcessOptions = {
  11713. width: number;
  11714. height: number;
  11715. };
  11716. /**
  11717. * PostProcess can be used to apply a shader to a texture after it has been rendered
  11718. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  11719. */
  11720. export class PostProcess {
  11721. /** Name of the PostProcess. */
  11722. name: string;
  11723. /**
  11724. * Width of the texture to apply the post process on
  11725. */
  11726. width: number;
  11727. /**
  11728. * Height of the texture to apply the post process on
  11729. */
  11730. height: number;
  11731. /**
  11732. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  11733. * @hidden
  11734. */ outputTexture: Nullable<InternalTexture>;
  11735. /**
  11736. * Sampling mode used by the shader
  11737. * See https://doc.babylonjs.com/classes/3.1/texture
  11738. */
  11739. renderTargetSamplingMode: number;
  11740. /**
  11741. * Clear color to use when screen clearing
  11742. */
  11743. clearColor: Color4;
  11744. /**
  11745. * If the buffer needs to be cleared before applying the post process. (default: true)
  11746. * Should be set to false if shader will overwrite all previous pixels.
  11747. */
  11748. autoClear: boolean;
  11749. /**
  11750. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  11751. */
  11752. alphaMode: number;
  11753. /**
  11754. * Sets the setAlphaBlendConstants of the babylon engine
  11755. */
  11756. alphaConstants: Color4;
  11757. /**
  11758. * Animations to be used for the post processing
  11759. */
  11760. animations: Animation[];
  11761. /**
  11762. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  11763. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  11764. */
  11765. enablePixelPerfectMode: boolean;
  11766. /**
  11767. * Force the postprocess to be applied without taking in account viewport
  11768. */
  11769. forceFullscreenViewport: boolean;
  11770. /**
  11771. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  11772. *
  11773. * | Value | Type | Description |
  11774. * | ----- | ----------------------------------- | ----------- |
  11775. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  11776. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  11777. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  11778. *
  11779. */
  11780. scaleMode: number;
  11781. /**
  11782. * Force textures to be a power of two (default: false)
  11783. */
  11784. alwaysForcePOT: boolean;
  11785. private _samples;
  11786. /**
  11787. * Number of sample textures (default: 1)
  11788. */
  11789. samples: number;
  11790. /**
  11791. * Modify the scale of the post process to be the same as the viewport (default: false)
  11792. */
  11793. adaptScaleToCurrentViewport: boolean;
  11794. private _camera;
  11795. private _scene;
  11796. private _engine;
  11797. private _options;
  11798. private _reusable;
  11799. private _textureType;
  11800. /**
  11801. * Smart array of input and output textures for the post process.
  11802. * @hidden
  11803. */ textures: SmartArray<InternalTexture>;
  11804. /**
  11805. * The index in _textures that corresponds to the output texture.
  11806. * @hidden
  11807. */ currentRenderTextureInd: number;
  11808. private _effect;
  11809. private _samplers;
  11810. private _fragmentUrl;
  11811. private _vertexUrl;
  11812. private _parameters;
  11813. private _scaleRatio;
  11814. protected _indexParameters: any;
  11815. private _shareOutputWithPostProcess;
  11816. private _texelSize;
  11817. private _forcedOutputTexture;
  11818. /**
  11819. * Returns the fragment url or shader name used in the post process.
  11820. * @returns the fragment url or name in the shader store.
  11821. */
  11822. getEffectName(): string;
  11823. /**
  11824. * An event triggered when the postprocess is activated.
  11825. */
  11826. onActivateObservable: Observable<Camera>;
  11827. private _onActivateObserver;
  11828. /**
  11829. * A function that is added to the onActivateObservable
  11830. */
  11831. onActivate: Nullable<(camera: Camera) => void>;
  11832. /**
  11833. * An event triggered when the postprocess changes its size.
  11834. */
  11835. onSizeChangedObservable: Observable<PostProcess>;
  11836. private _onSizeChangedObserver;
  11837. /**
  11838. * A function that is added to the onSizeChangedObservable
  11839. */
  11840. onSizeChanged: (postProcess: PostProcess) => void;
  11841. /**
  11842. * An event triggered when the postprocess applies its effect.
  11843. */
  11844. onApplyObservable: Observable<Effect>;
  11845. private _onApplyObserver;
  11846. /**
  11847. * A function that is added to the onApplyObservable
  11848. */
  11849. onApply: (effect: Effect) => void;
  11850. /**
  11851. * An event triggered before rendering the postprocess
  11852. */
  11853. onBeforeRenderObservable: Observable<Effect>;
  11854. private _onBeforeRenderObserver;
  11855. /**
  11856. * A function that is added to the onBeforeRenderObservable
  11857. */
  11858. onBeforeRender: (effect: Effect) => void;
  11859. /**
  11860. * An event triggered after rendering the postprocess
  11861. */
  11862. onAfterRenderObservable: Observable<Effect>;
  11863. private _onAfterRenderObserver;
  11864. /**
  11865. * A function that is added to the onAfterRenderObservable
  11866. */
  11867. onAfterRender: (efect: Effect) => void;
  11868. /**
  11869. * 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
  11870. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  11871. */
  11872. inputTexture: InternalTexture;
  11873. /**
  11874. * Gets the camera which post process is applied to.
  11875. * @returns The camera the post process is applied to.
  11876. */
  11877. getCamera(): Camera;
  11878. /**
  11879. * Gets the texel size of the postprocess.
  11880. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  11881. */
  11882. readonly texelSize: Vector2;
  11883. /**
  11884. * Creates a new instance PostProcess
  11885. * @param name The name of the PostProcess.
  11886. * @param fragmentUrl The url of the fragment shader to be used.
  11887. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  11888. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  11889. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  11890. * @param camera The camera to apply the render pass to.
  11891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  11892. * @param engine The engine which the post process will be applied. (default: current engine)
  11893. * @param reusable If the post process can be reused on the same frame. (default: false)
  11894. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  11895. * @param textureType Type of textures used when performing the post process. (default: 0)
  11896. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  11897. * @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
  11898. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  11899. */
  11900. constructor(
  11901. /** Name of the PostProcess. */
  11902. 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);
  11903. /**
  11904. * Gets the engine which this post process belongs to.
  11905. * @returns The engine the post process was enabled with.
  11906. */
  11907. getEngine(): Engine;
  11908. /**
  11909. * The effect that is created when initializing the post process.
  11910. * @returns The created effect corrisponding the the postprocess.
  11911. */
  11912. getEffect(): Effect;
  11913. /**
  11914. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  11915. * @param postProcess The post process to share the output with.
  11916. * @returns This post process.
  11917. */
  11918. shareOutputWith(postProcess: PostProcess): PostProcess;
  11919. /**
  11920. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  11921. * This should be called if the post process that shares output with this post process is disabled/disposed.
  11922. */
  11923. useOwnOutput(): void;
  11924. /**
  11925. * Updates the effect with the current post process compile time values and recompiles the shader.
  11926. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  11927. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  11928. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  11929. * @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
  11930. * @param onCompiled Called when the shader has been compiled.
  11931. * @param onError Called if there is an error when compiling a shader.
  11932. */
  11933. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  11934. /**
  11935. * The post process is reusable if it can be used multiple times within one frame.
  11936. * @returns If the post process is reusable
  11937. */
  11938. isReusable(): boolean;
  11939. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  11940. markTextureDirty(): void;
  11941. /**
  11942. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  11943. * 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.
  11944. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  11945. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  11946. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  11947. * @returns The target texture that was bound to be written to.
  11948. */
  11949. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  11950. /**
  11951. * If the post process is supported.
  11952. */
  11953. readonly isSupported: boolean;
  11954. /**
  11955. * The aspect ratio of the output texture.
  11956. */
  11957. readonly aspectRatio: number;
  11958. /**
  11959. * Get a value indicating if the post-process is ready to be used
  11960. * @returns true if the post-process is ready (shader is compiled)
  11961. */
  11962. isReady(): boolean;
  11963. /**
  11964. * Binds all textures and uniforms to the shader, this will be run on every pass.
  11965. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  11966. */
  11967. apply(): Nullable<Effect>;
  11968. private _disposeTextures;
  11969. /**
  11970. * Disposes the post process.
  11971. * @param camera The camera to dispose the post process on.
  11972. */
  11973. dispose(camera?: Camera): void;
  11974. }
  11975. }
  11976. declare module BABYLON {
  11977. /** @hidden */
  11978. export var kernelBlurVaryingDeclaration: {
  11979. name: string;
  11980. shader: string;
  11981. };
  11982. }
  11983. declare module BABYLON {
  11984. /** @hidden */
  11985. export var kernelBlurFragment: {
  11986. name: string;
  11987. shader: string;
  11988. };
  11989. }
  11990. declare module BABYLON {
  11991. /** @hidden */
  11992. export var kernelBlurFragment2: {
  11993. name: string;
  11994. shader: string;
  11995. };
  11996. }
  11997. declare module BABYLON {
  11998. /** @hidden */
  11999. export var kernelBlurPixelShader: {
  12000. name: string;
  12001. shader: string;
  12002. };
  12003. }
  12004. declare module BABYLON {
  12005. /** @hidden */
  12006. export var kernelBlurVertex: {
  12007. name: string;
  12008. shader: string;
  12009. };
  12010. }
  12011. declare module BABYLON {
  12012. /** @hidden */
  12013. export var kernelBlurVertexShader: {
  12014. name: string;
  12015. shader: string;
  12016. };
  12017. }
  12018. declare module BABYLON {
  12019. /**
  12020. * The Blur Post Process which blurs an image based on a kernel and direction.
  12021. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  12022. */
  12023. export class BlurPostProcess extends PostProcess {
  12024. /** The direction in which to blur the image. */
  12025. direction: Vector2;
  12026. private blockCompilation;
  12027. protected _kernel: number;
  12028. protected _idealKernel: number;
  12029. protected _packedFloat: boolean;
  12030. private _staticDefines;
  12031. /**
  12032. * Sets the length in pixels of the blur sample region
  12033. */
  12034. /**
  12035. * Gets the length in pixels of the blur sample region
  12036. */
  12037. kernel: number;
  12038. /**
  12039. * Sets wether or not the blur needs to unpack/repack floats
  12040. */
  12041. /**
  12042. * Gets wether or not the blur is unpacking/repacking floats
  12043. */
  12044. packedFloat: boolean;
  12045. /**
  12046. * Creates a new instance BlurPostProcess
  12047. * @param name The name of the effect.
  12048. * @param direction The direction in which to blur the image.
  12049. * @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.
  12050. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  12051. * @param camera The camera to apply the render pass to.
  12052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  12053. * @param engine The engine which the post process will be applied. (default: current engine)
  12054. * @param reusable If the post process can be reused on the same frame. (default: false)
  12055. * @param textureType Type of textures used when performing the post process. (default: 0)
  12056. * @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)
  12057. */
  12058. constructor(name: string,
  12059. /** The direction in which to blur the image. */
  12060. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  12061. /**
  12062. * Updates the effect with the current post process compile time values and recompiles the shader.
  12063. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  12064. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  12065. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  12066. * @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
  12067. * @param onCompiled Called when the shader has been compiled.
  12068. * @param onError Called if there is an error when compiling a shader.
  12069. */
  12070. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12071. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12072. /**
  12073. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  12074. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  12075. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  12076. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  12077. * The gaps between physical kernels are compensated for in the weighting of the samples
  12078. * @param idealKernel Ideal blur kernel.
  12079. * @return Nearest best kernel.
  12080. */
  12081. protected _nearestBestKernel(idealKernel: number): number;
  12082. /**
  12083. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  12084. * @param x The point on the Gaussian distribution to sample.
  12085. * @return the value of the Gaussian function at x.
  12086. */
  12087. protected _gaussianWeight(x: number): number;
  12088. /**
  12089. * Generates a string that can be used as a floating point number in GLSL.
  12090. * @param x Value to print.
  12091. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  12092. * @return GLSL float string.
  12093. */
  12094. protected _glslFloat(x: number, decimalFigures?: number): string;
  12095. }
  12096. }
  12097. declare module BABYLON {
  12098. /**
  12099. * Mirror texture can be used to simulate the view from a mirror in a scene.
  12100. * It will dynamically be rendered every frame to adapt to the camera point of view.
  12101. * You can then easily use it as a reflectionTexture on a flat surface.
  12102. * In case the surface is not a plane, please consider relying on reflection probes.
  12103. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12104. */
  12105. export class MirrorTexture extends RenderTargetTexture {
  12106. private scene;
  12107. /**
  12108. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  12109. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  12110. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12111. */
  12112. mirrorPlane: Plane;
  12113. /**
  12114. * Define the blur ratio used to blur the reflection if needed.
  12115. */
  12116. blurRatio: number;
  12117. /**
  12118. * Define the adaptive blur kernel used to blur the reflection if needed.
  12119. * This will autocompute the closest best match for the `blurKernel`
  12120. */
  12121. adaptiveBlurKernel: number;
  12122. /**
  12123. * Define the blur kernel used to blur the reflection if needed.
  12124. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12125. */
  12126. blurKernel: number;
  12127. /**
  12128. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  12129. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12130. */
  12131. blurKernelX: number;
  12132. /**
  12133. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  12134. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12135. */
  12136. blurKernelY: number;
  12137. private _autoComputeBlurKernel;
  12138. protected _onRatioRescale(): void;
  12139. private _updateGammaSpace;
  12140. private _imageProcessingConfigChangeObserver;
  12141. private _transformMatrix;
  12142. private _mirrorMatrix;
  12143. private _savedViewMatrix;
  12144. private _blurX;
  12145. private _blurY;
  12146. private _adaptiveBlurKernel;
  12147. private _blurKernelX;
  12148. private _blurKernelY;
  12149. private _blurRatio;
  12150. /**
  12151. * Instantiates a Mirror Texture.
  12152. * Mirror texture can be used to simulate the view from a mirror in a scene.
  12153. * It will dynamically be rendered every frame to adapt to the camera point of view.
  12154. * You can then easily use it as a reflectionTexture on a flat surface.
  12155. * In case the surface is not a plane, please consider relying on reflection probes.
  12156. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12157. * @param name
  12158. * @param size
  12159. * @param scene
  12160. * @param generateMipMaps
  12161. * @param type
  12162. * @param samplingMode
  12163. * @param generateDepthBuffer
  12164. */
  12165. constructor(name: string, size: number | {
  12166. width: number;
  12167. height: number;
  12168. } | {
  12169. ratio: number;
  12170. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  12171. private _preparePostProcesses;
  12172. /**
  12173. * Clone the mirror texture.
  12174. * @returns the cloned texture
  12175. */
  12176. clone(): MirrorTexture;
  12177. /**
  12178. * Serialize the texture to a JSON representation you could use in Parse later on
  12179. * @returns the serialized JSON representation
  12180. */
  12181. serialize(): any;
  12182. /**
  12183. * Dispose the texture and release its associated resources.
  12184. */
  12185. dispose(): void;
  12186. }
  12187. }
  12188. declare module BABYLON {
  12189. /**
  12190. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  12191. * @see http://doc.babylonjs.com/babylon101/materials#texture
  12192. */
  12193. export class Texture extends BaseTexture {
  12194. /** @hidden */ private static _AnimationParser: (jsonAnimation: any) => Animation;
  12195. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  12196. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  12197. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  12198. /** nearest is mag = nearest and min = nearest and mip = linear */
  12199. static readonly NEAREST_SAMPLINGMODE: number;
  12200. /** nearest is mag = nearest and min = nearest and mip = linear */
  12201. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  12202. /** Bilinear is mag = linear and min = linear and mip = nearest */
  12203. static readonly BILINEAR_SAMPLINGMODE: number;
  12204. /** Bilinear is mag = linear and min = linear and mip = nearest */
  12205. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  12206. /** Trilinear is mag = linear and min = linear and mip = linear */
  12207. static readonly TRILINEAR_SAMPLINGMODE: number;
  12208. /** Trilinear is mag = linear and min = linear and mip = linear */
  12209. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  12210. /** mag = nearest and min = nearest and mip = nearest */
  12211. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  12212. /** mag = nearest and min = linear and mip = nearest */
  12213. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  12214. /** mag = nearest and min = linear and mip = linear */
  12215. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  12216. /** mag = nearest and min = linear and mip = none */
  12217. static readonly NEAREST_LINEAR: number;
  12218. /** mag = nearest and min = nearest and mip = none */
  12219. static readonly NEAREST_NEAREST: number;
  12220. /** mag = linear and min = nearest and mip = nearest */
  12221. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  12222. /** mag = linear and min = nearest and mip = linear */
  12223. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  12224. /** mag = linear and min = linear and mip = none */
  12225. static readonly LINEAR_LINEAR: number;
  12226. /** mag = linear and min = nearest and mip = none */
  12227. static readonly LINEAR_NEAREST: number;
  12228. /** Explicit coordinates mode */
  12229. static readonly EXPLICIT_MODE: number;
  12230. /** Spherical coordinates mode */
  12231. static readonly SPHERICAL_MODE: number;
  12232. /** Planar coordinates mode */
  12233. static readonly PLANAR_MODE: number;
  12234. /** Cubic coordinates mode */
  12235. static readonly CUBIC_MODE: number;
  12236. /** Projection coordinates mode */
  12237. static readonly PROJECTION_MODE: number;
  12238. /** Inverse Cubic coordinates mode */
  12239. static readonly SKYBOX_MODE: number;
  12240. /** Inverse Cubic coordinates mode */
  12241. static readonly INVCUBIC_MODE: number;
  12242. /** Equirectangular coordinates mode */
  12243. static readonly EQUIRECTANGULAR_MODE: number;
  12244. /** Equirectangular Fixed coordinates mode */
  12245. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  12246. /** Equirectangular Fixed Mirrored coordinates mode */
  12247. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  12248. /** Texture is not repeating outside of 0..1 UVs */
  12249. static readonly CLAMP_ADDRESSMODE: number;
  12250. /** Texture is repeating outside of 0..1 UVs */
  12251. static readonly WRAP_ADDRESSMODE: number;
  12252. /** Texture is repeating and mirrored */
  12253. static readonly MIRROR_ADDRESSMODE: number;
  12254. /**
  12255. * 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
  12256. */
  12257. static UseSerializedUrlIfAny: boolean;
  12258. /**
  12259. * Define the url of the texture.
  12260. */
  12261. url: Nullable<string>;
  12262. /**
  12263. * Define an offset on the texture to offset the u coordinates of the UVs
  12264. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  12265. */
  12266. uOffset: number;
  12267. /**
  12268. * Define an offset on the texture to offset the v coordinates of the UVs
  12269. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  12270. */
  12271. vOffset: number;
  12272. /**
  12273. * Define an offset on the texture to scale the u coordinates of the UVs
  12274. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  12275. */
  12276. uScale: number;
  12277. /**
  12278. * Define an offset on the texture to scale the v coordinates of the UVs
  12279. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  12280. */
  12281. vScale: number;
  12282. /**
  12283. * Define an offset on the texture to rotate around the u coordinates of the UVs
  12284. * @see http://doc.babylonjs.com/how_to/more_materials
  12285. */
  12286. uAng: number;
  12287. /**
  12288. * Define an offset on the texture to rotate around the v coordinates of the UVs
  12289. * @see http://doc.babylonjs.com/how_to/more_materials
  12290. */
  12291. vAng: number;
  12292. /**
  12293. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  12294. * @see http://doc.babylonjs.com/how_to/more_materials
  12295. */
  12296. wAng: number;
  12297. /**
  12298. * Defines the center of rotation (U)
  12299. */
  12300. uRotationCenter: number;
  12301. /**
  12302. * Defines the center of rotation (V)
  12303. */
  12304. vRotationCenter: number;
  12305. /**
  12306. * Defines the center of rotation (W)
  12307. */
  12308. wRotationCenter: number;
  12309. /**
  12310. * Are mip maps generated for this texture or not.
  12311. */
  12312. readonly noMipmap: boolean;
  12313. private _noMipmap;
  12314. /** @hidden */ invertY: boolean;
  12315. private _rowGenerationMatrix;
  12316. private _cachedTextureMatrix;
  12317. private _projectionModeMatrix;
  12318. private _t0;
  12319. private _t1;
  12320. private _t2;
  12321. private _cachedUOffset;
  12322. private _cachedVOffset;
  12323. private _cachedUScale;
  12324. private _cachedVScale;
  12325. private _cachedUAng;
  12326. private _cachedVAng;
  12327. private _cachedWAng;
  12328. private _cachedProjectionMatrixId;
  12329. private _cachedCoordinatesMode;
  12330. /** @hidden */
  12331. protected _initialSamplingMode: number;
  12332. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  12333. private _deleteBuffer;
  12334. protected _format: Nullable<number>;
  12335. private _delayedOnLoad;
  12336. private _delayedOnError;
  12337. /**
  12338. * Observable triggered once the texture has been loaded.
  12339. */
  12340. onLoadObservable: Observable<Texture>;
  12341. protected _isBlocking: boolean;
  12342. /**
  12343. * Is the texture preventing material to render while loading.
  12344. * If false, a default texture will be used instead of the loading one during the preparation step.
  12345. */
  12346. isBlocking: boolean;
  12347. /**
  12348. * Get the current sampling mode associated with the texture.
  12349. */
  12350. readonly samplingMode: number;
  12351. /**
  12352. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  12353. */
  12354. readonly invertY: boolean;
  12355. /**
  12356. * Instantiates a new texture.
  12357. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  12358. * @see http://doc.babylonjs.com/babylon101/materials#texture
  12359. * @param url define the url of the picture to load as a texture
  12360. * @param scene define the scene the texture will belong to
  12361. * @param noMipmap define if the texture will require mip maps or not
  12362. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12363. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12364. * @param onLoad define a callback triggered when the texture has been loaded
  12365. * @param onError define a callback triggered when an error occurred during the loading session
  12366. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12367. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12368. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12369. */
  12370. 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);
  12371. /**
  12372. * Update the url (and optional buffer) of this texture if url was null during construction.
  12373. * @param url the url of the texture
  12374. * @param buffer the buffer of the texture (defaults to null)
  12375. * @param onLoad callback called when the texture is loaded (defaults to null)
  12376. */
  12377. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  12378. /**
  12379. * Finish the loading sequence of a texture flagged as delayed load.
  12380. * @hidden
  12381. */
  12382. delayLoad(): void;
  12383. private _prepareRowForTextureGeneration;
  12384. /**
  12385. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  12386. * @returns the transform matrix of the texture.
  12387. */
  12388. getTextureMatrix(): Matrix;
  12389. /**
  12390. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  12391. * @returns The reflection texture transform
  12392. */
  12393. getReflectionTextureMatrix(): Matrix;
  12394. /**
  12395. * Clones the texture.
  12396. * @returns the cloned texture
  12397. */
  12398. clone(): Texture;
  12399. /**
  12400. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  12401. * @returns The JSON representation of the texture
  12402. */
  12403. serialize(): any;
  12404. /**
  12405. * Get the current class name of the texture useful for serialization or dynamic coding.
  12406. * @returns "Texture"
  12407. */
  12408. getClassName(): string;
  12409. /**
  12410. * Dispose the texture and release its associated resources.
  12411. */
  12412. dispose(): void;
  12413. /**
  12414. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  12415. * @param parsedTexture Define the JSON representation of the texture
  12416. * @param scene Define the scene the parsed texture should be instantiated in
  12417. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  12418. * @returns The parsed texture if successful
  12419. */
  12420. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  12421. /**
  12422. * Creates a texture from its base 64 representation.
  12423. * @param data Define the base64 payload without the data: prefix
  12424. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12425. * @param scene Define the scene the texture should belong to
  12426. * @param noMipmap Forces the texture to not create mip map information if true
  12427. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12428. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12429. * @param onLoad define a callback triggered when the texture has been loaded
  12430. * @param onError define a callback triggered when an error occurred during the loading session
  12431. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12432. * @returns the created texture
  12433. */
  12434. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  12435. /**
  12436. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  12437. * @param data Define the base64 payload without the data: prefix
  12438. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12439. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12440. * @param scene Define the scene the texture should belong to
  12441. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12442. * @param noMipmap Forces the texture to not create mip map information if true
  12443. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12444. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12445. * @param onLoad define a callback triggered when the texture has been loaded
  12446. * @param onError define a callback triggered when an error occurred during the loading session
  12447. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12448. * @returns the created texture
  12449. */
  12450. 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;
  12451. }
  12452. }
  12453. declare module BABYLON {
  12454. /**
  12455. * PostProcessManager is used to manage one or more post processes or post process pipelines
  12456. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  12457. */
  12458. export class PostProcessManager {
  12459. private _scene;
  12460. private _indexBuffer;
  12461. private _vertexBuffers;
  12462. /**
  12463. * Creates a new instance PostProcess
  12464. * @param scene The scene that the post process is associated with.
  12465. */
  12466. constructor(scene: Scene);
  12467. private _prepareBuffers;
  12468. private _buildIndexBuffer;
  12469. /**
  12470. * Rebuilds the vertex buffers of the manager.
  12471. * @hidden
  12472. */ rebuild(): void;
  12473. /**
  12474. * Prepares a frame to be run through a post process.
  12475. * @param sourceTexture The input texture to the post procesess. (default: null)
  12476. * @param postProcesses An array of post processes to be run. (default: null)
  12477. * @returns True if the post processes were able to be run.
  12478. * @hidden
  12479. */ prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  12480. /**
  12481. * Manually render a set of post processes to a texture.
  12482. * @param postProcesses An array of post processes to be run.
  12483. * @param targetTexture The target texture to render to.
  12484. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  12485. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  12486. * @param lodLevel defines which lod of the texture to render to
  12487. */
  12488. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  12489. /**
  12490. * Finalize the result of the output of the postprocesses.
  12491. * @param doNotPresent If true the result will not be displayed to the screen.
  12492. * @param targetTexture The target texture to render to.
  12493. * @param faceIndex The index of the face to bind the target texture to.
  12494. * @param postProcesses The array of post processes to render.
  12495. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  12496. * @hidden
  12497. */ finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  12498. /**
  12499. * Disposes of the post process manager.
  12500. */
  12501. dispose(): void;
  12502. }
  12503. }
  12504. declare module BABYLON {
  12505. /**
  12506. * Groups all the scene component constants in one place to ease maintenance.
  12507. * @hidden
  12508. */
  12509. export class SceneComponentConstants {
  12510. static readonly NAME_EFFECTLAYER: string;
  12511. static readonly NAME_LAYER: string;
  12512. static readonly NAME_LENSFLARESYSTEM: string;
  12513. static readonly NAME_BOUNDINGBOXRENDERER: string;
  12514. static readonly NAME_PARTICLESYSTEM: string;
  12515. static readonly NAME_GAMEPAD: string;
  12516. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  12517. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  12518. static readonly NAME_DEPTHRENDERER: string;
  12519. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  12520. static readonly NAME_SPRITE: string;
  12521. static readonly NAME_OUTLINERENDERER: string;
  12522. static readonly NAME_PROCEDURALTEXTURE: string;
  12523. static readonly NAME_SHADOWGENERATOR: string;
  12524. static readonly NAME_OCTREE: string;
  12525. static readonly NAME_PHYSICSENGINE: string;
  12526. static readonly NAME_AUDIO: string;
  12527. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  12528. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  12529. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  12530. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  12531. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  12532. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  12533. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  12534. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  12535. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  12536. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  12537. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  12538. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  12539. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  12540. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  12541. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  12542. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  12543. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  12544. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  12545. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  12546. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  12547. static readonly STEP_AFTERRENDER_AUDIO: number;
  12548. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  12549. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  12550. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  12551. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  12552. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  12553. static readonly STEP_POINTERMOVE_SPRITE: number;
  12554. static readonly STEP_POINTERDOWN_SPRITE: number;
  12555. static readonly STEP_POINTERUP_SPRITE: number;
  12556. }
  12557. /**
  12558. * This represents a scene component.
  12559. *
  12560. * This is used to decouple the dependency the scene is having on the different workloads like
  12561. * layers, post processes...
  12562. */
  12563. export interface ISceneComponent {
  12564. /**
  12565. * The name of the component. Each component must have a unique name.
  12566. */
  12567. name: string;
  12568. /**
  12569. * The scene the component belongs to.
  12570. */
  12571. scene: Scene;
  12572. /**
  12573. * Register the component to one instance of a scene.
  12574. */
  12575. register(): void;
  12576. /**
  12577. * Rebuilds the elements related to this component in case of
  12578. * context lost for instance.
  12579. */
  12580. rebuild(): void;
  12581. /**
  12582. * Disposes the component and the associated ressources.
  12583. */
  12584. dispose(): void;
  12585. }
  12586. /**
  12587. * This represents a SERIALIZABLE scene component.
  12588. *
  12589. * This extends Scene Component to add Serialization methods on top.
  12590. */
  12591. export interface ISceneSerializableComponent extends ISceneComponent {
  12592. /**
  12593. * Adds all the element from the container to the scene
  12594. * @param container the container holding the elements
  12595. */
  12596. addFromContainer(container: AbstractScene): void;
  12597. /**
  12598. * Removes all the elements in the container from the scene
  12599. * @param container contains the elements to remove
  12600. */
  12601. removeFromContainer(container: AbstractScene): void;
  12602. /**
  12603. * Serializes the component data to the specified json object
  12604. * @param serializationObject The object to serialize to
  12605. */
  12606. serialize(serializationObject: any): void;
  12607. }
  12608. /**
  12609. * Strong typing of a Mesh related stage step action
  12610. */
  12611. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  12612. /**
  12613. * Strong typing of a Evaluate Sub Mesh related stage step action
  12614. */
  12615. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  12616. /**
  12617. * Strong typing of a Active Mesh related stage step action
  12618. */
  12619. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  12620. /**
  12621. * Strong typing of a Camera related stage step action
  12622. */
  12623. export type CameraStageAction = (camera: Camera) => void;
  12624. /**
  12625. * Strong typing of a Render Target related stage step action
  12626. */
  12627. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  12628. /**
  12629. * Strong typing of a RenderingGroup related stage step action
  12630. */
  12631. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  12632. /**
  12633. * Strong typing of a Mesh Render related stage step action
  12634. */
  12635. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  12636. /**
  12637. * Strong typing of a simple stage step action
  12638. */
  12639. export type SimpleStageAction = () => void;
  12640. /**
  12641. * Strong typing of a render target action.
  12642. */
  12643. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  12644. /**
  12645. * Strong typing of a pointer move action.
  12646. */
  12647. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  12648. /**
  12649. * Strong typing of a pointer up/down action.
  12650. */
  12651. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  12652. /**
  12653. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  12654. * @hidden
  12655. */
  12656. export class Stage<T extends Function> extends Array<{
  12657. index: number;
  12658. component: ISceneComponent;
  12659. action: T;
  12660. }> {
  12661. /**
  12662. * Hide ctor from the rest of the world.
  12663. * @param items The items to add.
  12664. */
  12665. private constructor();
  12666. /**
  12667. * Creates a new Stage.
  12668. * @returns A new instance of a Stage
  12669. */
  12670. static Create<T extends Function>(): Stage<T>;
  12671. /**
  12672. * Registers a step in an ordered way in the targeted stage.
  12673. * @param index Defines the position to register the step in
  12674. * @param component Defines the component attached to the step
  12675. * @param action Defines the action to launch during the step
  12676. */
  12677. registerStep(index: number, component: ISceneComponent, action: T): void;
  12678. /**
  12679. * Clears all the steps from the stage.
  12680. */
  12681. clear(): void;
  12682. }
  12683. }
  12684. declare module BABYLON {
  12685. interface Scene {
  12686. /** @hidden */ pointerOverSprite: Nullable<Sprite>;
  12687. /** @hidden */ pickedDownSprite: Nullable<Sprite>;
  12688. /** @hidden */ tempSpritePickingRay: Nullable<Ray>;
  12689. /**
  12690. * All of the sprite managers added to this scene
  12691. * @see http://doc.babylonjs.com/babylon101/sprites
  12692. */
  12693. spriteManagers: Array<ISpriteManager>;
  12694. /**
  12695. * An event triggered when sprites rendering is about to start
  12696. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12697. */
  12698. onBeforeSpritesRenderingObservable: Observable<Scene>;
  12699. /**
  12700. * An event triggered when sprites rendering is done
  12701. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12702. */
  12703. onAfterSpritesRenderingObservable: Observable<Scene>;
  12704. /** @hidden */ internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12705. /** Launch a ray to try to pick a sprite in the scene
  12706. * @param x position on screen
  12707. * @param y position on screen
  12708. * @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
  12709. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12710. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  12711. * @returns a PickingInfo
  12712. */
  12713. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12714. /** Use the given ray to pick a sprite in the scene
  12715. * @param ray The ray (in world space) to use to pick meshes
  12716. * @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
  12717. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12718. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  12719. * @returns a PickingInfo
  12720. */
  12721. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12722. /**
  12723. * Force the sprite under the pointer
  12724. * @param sprite defines the sprite to use
  12725. */
  12726. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  12727. /**
  12728. * Gets the sprite under the pointer
  12729. * @returns a Sprite or null if no sprite is under the pointer
  12730. */
  12731. getPointerOverSprite(): Nullable<Sprite>;
  12732. }
  12733. /**
  12734. * Defines the sprite scene component responsible to manage sprites
  12735. * in a given scene.
  12736. */
  12737. export class SpriteSceneComponent implements ISceneComponent {
  12738. /**
  12739. * The component name helpfull to identify the component in the list of scene components.
  12740. */
  12741. readonly name: string;
  12742. /**
  12743. * The scene the component belongs to.
  12744. */
  12745. scene: Scene;
  12746. /** @hidden */
  12747. private _spritePredicate;
  12748. /**
  12749. * Creates a new instance of the component for the given scene
  12750. * @param scene Defines the scene to register the component in
  12751. */
  12752. constructor(scene: Scene);
  12753. /**
  12754. * Registers the component in a given scene
  12755. */
  12756. register(): void;
  12757. /**
  12758. * Rebuilds the elements related to this component in case of
  12759. * context lost for instance.
  12760. */
  12761. rebuild(): void;
  12762. /**
  12763. * Disposes the component and the associated ressources.
  12764. */
  12765. dispose(): void;
  12766. private _pickSpriteButKeepRay;
  12767. private _pointerMove;
  12768. private _pointerDown;
  12769. private _pointerUp;
  12770. }
  12771. }
  12772. declare module BABYLON {
  12773. /** @hidden */
  12774. export var fogFragmentDeclaration: {
  12775. name: string;
  12776. shader: string;
  12777. };
  12778. }
  12779. declare module BABYLON {
  12780. /** @hidden */
  12781. export var fogFragment: {
  12782. name: string;
  12783. shader: string;
  12784. };
  12785. }
  12786. declare module BABYLON {
  12787. /** @hidden */
  12788. export var spritesPixelShader: {
  12789. name: string;
  12790. shader: string;
  12791. };
  12792. }
  12793. declare module BABYLON {
  12794. /** @hidden */
  12795. export var fogVertexDeclaration: {
  12796. name: string;
  12797. shader: string;
  12798. };
  12799. }
  12800. declare module BABYLON {
  12801. /** @hidden */
  12802. export var spritesVertexShader: {
  12803. name: string;
  12804. shader: string;
  12805. };
  12806. }
  12807. declare module BABYLON {
  12808. /**
  12809. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12810. */
  12811. export interface ISpriteManager extends IDisposable {
  12812. /**
  12813. * Restricts the camera to viewing objects with the same layerMask.
  12814. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12815. */
  12816. layerMask: number;
  12817. /**
  12818. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12819. */
  12820. isPickable: boolean;
  12821. /**
  12822. * Specifies the rendering group id for this mesh (0 by default)
  12823. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12824. */
  12825. renderingGroupId: number;
  12826. /**
  12827. * Defines the list of sprites managed by the manager.
  12828. */
  12829. sprites: Array<Sprite>;
  12830. /**
  12831. * Tests the intersection of a sprite with a specific ray.
  12832. * @param ray The ray we are sending to test the collision
  12833. * @param camera The camera space we are sending rays in
  12834. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12835. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12836. * @returns picking info or null.
  12837. */
  12838. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12839. /**
  12840. * Renders the list of sprites on screen.
  12841. */
  12842. render(): void;
  12843. }
  12844. /**
  12845. * Class used to manage multiple sprites on the same spritesheet
  12846. * @see http://doc.babylonjs.com/babylon101/sprites
  12847. */
  12848. export class SpriteManager implements ISpriteManager {
  12849. /** defines the manager's name */
  12850. name: string;
  12851. /** Gets the list of sprites */
  12852. sprites: Sprite[];
  12853. /** Gets or sets the rendering group id (0 by default) */
  12854. renderingGroupId: number;
  12855. /** Gets or sets camera layer mask */
  12856. layerMask: number;
  12857. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12858. fogEnabled: boolean;
  12859. /** Gets or sets a boolean indicating if the sprites are pickable */
  12860. isPickable: boolean;
  12861. /** Defines the default width of a cell in the spritesheet */
  12862. cellWidth: number;
  12863. /** Defines the default height of a cell in the spritesheet */
  12864. cellHeight: number;
  12865. /**
  12866. * An event triggered when the manager is disposed.
  12867. */
  12868. onDisposeObservable: Observable<SpriteManager>;
  12869. private _onDisposeObserver;
  12870. /**
  12871. * Callback called when the manager is disposed
  12872. */
  12873. onDispose: () => void;
  12874. private _capacity;
  12875. private _spriteTexture;
  12876. private _epsilon;
  12877. private _scene;
  12878. private _vertexData;
  12879. private _buffer;
  12880. private _vertexBuffers;
  12881. private _indexBuffer;
  12882. private _effectBase;
  12883. private _effectFog;
  12884. /**
  12885. * Gets or sets the spritesheet texture
  12886. */
  12887. texture: Texture;
  12888. /**
  12889. * Creates a new sprite manager
  12890. * @param name defines the manager's name
  12891. * @param imgUrl defines the sprite sheet url
  12892. * @param capacity defines the maximum allowed number of sprites
  12893. * @param cellSize defines the size of a sprite cell
  12894. * @param scene defines the hosting scene
  12895. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12896. * @param samplingMode defines the smapling mode to use with spritesheet
  12897. */
  12898. constructor(
  12899. /** defines the manager's name */
  12900. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12901. private _appendSpriteVertex;
  12902. /**
  12903. * Intersects the sprites with a ray
  12904. * @param ray defines the ray to intersect with
  12905. * @param camera defines the current active camera
  12906. * @param predicate defines a predicate used to select candidate sprites
  12907. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12908. * @returns null if no hit or a PickingInfo
  12909. */
  12910. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12911. /**
  12912. * Render all child sprites
  12913. */
  12914. render(): void;
  12915. /**
  12916. * Release associated resources
  12917. */
  12918. dispose(): void;
  12919. }
  12920. }
  12921. declare module BABYLON {
  12922. interface AbstractScene {
  12923. /**
  12924. * The list of layers (background and foreground) of the scene
  12925. */
  12926. layers: Array<Layer>;
  12927. }
  12928. /**
  12929. * Defines the layer scene component responsible to manage any layers
  12930. * in a given scene.
  12931. */
  12932. export class LayerSceneComponent implements ISceneComponent {
  12933. /**
  12934. * The component name helpfull to identify the component in the list of scene components.
  12935. */
  12936. readonly name: string;
  12937. /**
  12938. * The scene the component belongs to.
  12939. */
  12940. scene: Scene;
  12941. private _engine;
  12942. /**
  12943. * Creates a new instance of the component for the given scene
  12944. * @param scene Defines the scene to register the component in
  12945. */
  12946. constructor(scene: Scene);
  12947. /**
  12948. * Registers the component in a given scene
  12949. */
  12950. register(): void;
  12951. /**
  12952. * Rebuilds the elements related to this component in case of
  12953. * context lost for instance.
  12954. */
  12955. rebuild(): void;
  12956. /**
  12957. * Disposes the component and the associated ressources.
  12958. */
  12959. dispose(): void;
  12960. private _draw;
  12961. private _drawCameraPredicate;
  12962. private _drawCameraBackground;
  12963. private _drawCameraForeground;
  12964. private _drawRenderTargetPredicate;
  12965. private _drawRenderTargetBackground;
  12966. private _drawRenderTargetForeground;
  12967. }
  12968. }
  12969. declare module BABYLON {
  12970. /** @hidden */
  12971. export var layerPixelShader: {
  12972. name: string;
  12973. shader: string;
  12974. };
  12975. }
  12976. declare module BABYLON {
  12977. /** @hidden */
  12978. export var layerVertexShader: {
  12979. name: string;
  12980. shader: string;
  12981. };
  12982. }
  12983. declare module BABYLON {
  12984. /**
  12985. * This represents a full screen 2d layer.
  12986. * This can be useful to display a picture in the background of your scene for instance.
  12987. * @see https://www.babylonjs-playground.com/#08A2BS#1
  12988. */
  12989. export class Layer {
  12990. /**
  12991. * Define the name of the layer.
  12992. */
  12993. name: string;
  12994. /**
  12995. * Define the texture the layer should display.
  12996. */
  12997. texture: Nullable<Texture>;
  12998. /**
  12999. * Is the layer in background or foreground.
  13000. */
  13001. isBackground: boolean;
  13002. /**
  13003. * Define the color of the layer (instead of texture).
  13004. */
  13005. color: Color4;
  13006. /**
  13007. * Define the scale of the layer in order to zoom in out of the texture.
  13008. */
  13009. scale: Vector2;
  13010. /**
  13011. * Define an offset for the layer in order to shift the texture.
  13012. */
  13013. offset: Vector2;
  13014. /**
  13015. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13016. */
  13017. alphaBlendingMode: number;
  13018. /**
  13019. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13020. * Alpha test will not mix with the background color in case of transparency.
  13021. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13022. */
  13023. alphaTest: boolean;
  13024. /**
  13025. * Define a mask to restrict the layer to only some of the scene cameras.
  13026. */
  13027. layerMask: number;
  13028. /**
  13029. * Define the list of render target the layer is visible into.
  13030. */
  13031. renderTargetTextures: RenderTargetTexture[];
  13032. /**
  13033. * Define if the layer is only used in renderTarget or if it also
  13034. * renders in the main frame buffer of the canvas.
  13035. */
  13036. renderOnlyInRenderTargetTextures: boolean;
  13037. private _scene;
  13038. private _vertexBuffers;
  13039. private _indexBuffer;
  13040. private _effect;
  13041. private _alphaTestEffect;
  13042. /**
  13043. * An event triggered when the layer is disposed.
  13044. */
  13045. onDisposeObservable: Observable<Layer>;
  13046. private _onDisposeObserver;
  13047. /**
  13048. * Back compatibility with callback before the onDisposeObservable existed.
  13049. * The set callback will be triggered when the layer has been disposed.
  13050. */
  13051. onDispose: () => void;
  13052. /**
  13053. * An event triggered before rendering the scene
  13054. */
  13055. onBeforeRenderObservable: Observable<Layer>;
  13056. private _onBeforeRenderObserver;
  13057. /**
  13058. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13059. * The set callback will be triggered just before rendering the layer.
  13060. */
  13061. onBeforeRender: () => void;
  13062. /**
  13063. * An event triggered after rendering the scene
  13064. */
  13065. onAfterRenderObservable: Observable<Layer>;
  13066. private _onAfterRenderObserver;
  13067. /**
  13068. * Back compatibility with callback before the onAfterRenderObservable existed.
  13069. * The set callback will be triggered just after rendering the layer.
  13070. */
  13071. onAfterRender: () => void;
  13072. /**
  13073. * Instantiates a new layer.
  13074. * This represents a full screen 2d layer.
  13075. * This can be useful to display a picture in the background of your scene for instance.
  13076. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13077. * @param name Define the name of the layer in the scene
  13078. * @param imgUrl Define the url of the texture to display in the layer
  13079. * @param scene Define the scene the layer belongs to
  13080. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13081. * @param color Defines a color for the layer
  13082. */
  13083. constructor(
  13084. /**
  13085. * Define the name of the layer.
  13086. */
  13087. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13088. private _createIndexBuffer;
  13089. /** @hidden */ rebuild(): void;
  13090. /**
  13091. * Renders the layer in the scene.
  13092. */
  13093. render(): void;
  13094. /**
  13095. * Disposes and releases the associated ressources.
  13096. */
  13097. dispose(): void;
  13098. }
  13099. }
  13100. declare module BABYLON {
  13101. interface AbstractScene {
  13102. /**
  13103. * The list of procedural textures added to the scene
  13104. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13105. */
  13106. proceduralTextures: Array<ProceduralTexture>;
  13107. }
  13108. /**
  13109. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13110. * in a given scene.
  13111. */
  13112. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13113. /**
  13114. * The component name helpfull to identify the component in the list of scene components.
  13115. */
  13116. readonly name: string;
  13117. /**
  13118. * The scene the component belongs to.
  13119. */
  13120. scene: Scene;
  13121. /**
  13122. * Creates a new instance of the component for the given scene
  13123. * @param scene Defines the scene to register the component in
  13124. */
  13125. constructor(scene: Scene);
  13126. /**
  13127. * Registers the component in a given scene
  13128. */
  13129. register(): void;
  13130. /**
  13131. * Rebuilds the elements related to this component in case of
  13132. * context lost for instance.
  13133. */
  13134. rebuild(): void;
  13135. /**
  13136. * Disposes the component and the associated ressources.
  13137. */
  13138. dispose(): void;
  13139. private _beforeClear;
  13140. }
  13141. }
  13142. declare module BABYLON {
  13143. /** @hidden */
  13144. export var proceduralVertexShader: {
  13145. name: string;
  13146. shader: string;
  13147. };
  13148. }
  13149. declare module BABYLON {
  13150. /**
  13151. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  13152. * This is the base class of any Procedural texture and contains most of the shareable code.
  13153. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13154. */
  13155. export class ProceduralTexture extends Texture {
  13156. isCube: boolean;
  13157. /**
  13158. * Define if the texture is enabled or not (disabled texture will not render)
  13159. */
  13160. isEnabled: boolean;
  13161. /**
  13162. * Define if the texture must be cleared before rendering (default is true)
  13163. */
  13164. autoClear: boolean;
  13165. /**
  13166. * Callback called when the texture is generated
  13167. */
  13168. onGenerated: () => void;
  13169. /**
  13170. * Event raised when the texture is generated
  13171. */
  13172. onGeneratedObservable: Observable<ProceduralTexture>;
  13173. /** @hidden */ generateMipMaps: boolean;
  13174. /** @hidden **/ effect: Effect;
  13175. /** @hidden */ textures: {
  13176. [key: string]: Texture;
  13177. };
  13178. private _size;
  13179. private _currentRefreshId;
  13180. private _refreshRate;
  13181. private _vertexBuffers;
  13182. private _indexBuffer;
  13183. private _uniforms;
  13184. private _samplers;
  13185. private _fragment;
  13186. private _floats;
  13187. private _ints;
  13188. private _floatsArrays;
  13189. private _colors3;
  13190. private _colors4;
  13191. private _vectors2;
  13192. private _vectors3;
  13193. private _matrices;
  13194. private _fallbackTexture;
  13195. private _fallbackTextureUsed;
  13196. private _engine;
  13197. private _cachedDefines;
  13198. private _contentUpdateId;
  13199. private _contentData;
  13200. /**
  13201. * Instantiates a new procedural texture.
  13202. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  13203. * This is the base class of any Procedural texture and contains most of the shareable code.
  13204. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13205. * @param name Define the name of the texture
  13206. * @param size Define the size of the texture to create
  13207. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13208. * @param scene Define the scene the texture belongs to
  13209. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13210. * @param generateMipMaps Define if the texture should creates mip maps or not
  13211. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13212. */
  13213. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13214. /**
  13215. * The effect that is created when initializing the post process.
  13216. * @returns The created effect corrisponding the the postprocess.
  13217. */
  13218. getEffect(): Effect;
  13219. /**
  13220. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13221. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13222. */
  13223. getContent(): Nullable<ArrayBufferView>;
  13224. private _createIndexBuffer;
  13225. /** @hidden */ rebuild(): void;
  13226. /**
  13227. * Resets the texture in order to recreate its associated resources.
  13228. * This can be called in case of context loss
  13229. */
  13230. reset(): void;
  13231. protected _getDefines(): string;
  13232. /**
  13233. * Is the texture ready to be used ? (rendered at least once)
  13234. * @returns true if ready, otherwise, false.
  13235. */
  13236. isReady(): boolean;
  13237. /**
  13238. * Resets the refresh counter of the texture and start bak from scratch.
  13239. * Could be useful to regenerate the texture if it is setup to render only once.
  13240. */
  13241. resetRefreshCounter(): void;
  13242. /**
  13243. * Set the fragment shader to use in order to render the texture.
  13244. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13245. */
  13246. setFragment(fragment: any): void;
  13247. /**
  13248. * Define the refresh rate of the texture or the rendering frequency.
  13249. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13250. */
  13251. refreshRate: number;
  13252. /** @hidden */ shouldRender(): boolean;
  13253. /**
  13254. * Get the size the texture is rendering at.
  13255. * @returns the size (texture is always squared)
  13256. */
  13257. getRenderSize(): number;
  13258. /**
  13259. * Resize the texture to new value.
  13260. * @param size Define the new size the texture should have
  13261. * @param generateMipMaps Define whether the new texture should create mip maps
  13262. */
  13263. resize(size: number, generateMipMaps: boolean): void;
  13264. private _checkUniform;
  13265. /**
  13266. * Set a texture in the shader program used to render.
  13267. * @param name Define the name of the uniform samplers as defined in the shader
  13268. * @param texture Define the texture to bind to this sampler
  13269. * @return the texture itself allowing "fluent" like uniform updates
  13270. */
  13271. setTexture(name: string, texture: Texture): ProceduralTexture;
  13272. /**
  13273. * Set a float in the shader.
  13274. * @param name Define the name of the uniform as defined in the shader
  13275. * @param value Define the value to give to the uniform
  13276. * @return the texture itself allowing "fluent" like uniform updates
  13277. */
  13278. setFloat(name: string, value: number): ProceduralTexture;
  13279. /**
  13280. * Set a int in the shader.
  13281. * @param name Define the name of the uniform as defined in the shader
  13282. * @param value Define the value to give to the uniform
  13283. * @return the texture itself allowing "fluent" like uniform updates
  13284. */
  13285. setInt(name: string, value: number): ProceduralTexture;
  13286. /**
  13287. * Set an array of floats in the shader.
  13288. * @param name Define the name of the uniform as defined in the shader
  13289. * @param value Define the value to give to the uniform
  13290. * @return the texture itself allowing "fluent" like uniform updates
  13291. */
  13292. setFloats(name: string, value: number[]): ProceduralTexture;
  13293. /**
  13294. * Set a vec3 in the shader from a Color3.
  13295. * @param name Define the name of the uniform as defined in the shader
  13296. * @param value Define the value to give to the uniform
  13297. * @return the texture itself allowing "fluent" like uniform updates
  13298. */
  13299. setColor3(name: string, value: Color3): ProceduralTexture;
  13300. /**
  13301. * Set a vec4 in the shader from a Color4.
  13302. * @param name Define the name of the uniform as defined in the shader
  13303. * @param value Define the value to give to the uniform
  13304. * @return the texture itself allowing "fluent" like uniform updates
  13305. */
  13306. setColor4(name: string, value: Color4): ProceduralTexture;
  13307. /**
  13308. * Set a vec2 in the shader from a Vector2.
  13309. * @param name Define the name of the uniform as defined in the shader
  13310. * @param value Define the value to give to the uniform
  13311. * @return the texture itself allowing "fluent" like uniform updates
  13312. */
  13313. setVector2(name: string, value: Vector2): ProceduralTexture;
  13314. /**
  13315. * Set a vec3 in the shader from a Vector3.
  13316. * @param name Define the name of the uniform as defined in the shader
  13317. * @param value Define the value to give to the uniform
  13318. * @return the texture itself allowing "fluent" like uniform updates
  13319. */
  13320. setVector3(name: string, value: Vector3): ProceduralTexture;
  13321. /**
  13322. * Set a mat4 in the shader from a MAtrix.
  13323. * @param name Define the name of the uniform as defined in the shader
  13324. * @param value Define the value to give to the uniform
  13325. * @return the texture itself allowing "fluent" like uniform updates
  13326. */
  13327. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13328. /**
  13329. * Render the texture to its associated render target.
  13330. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13331. */
  13332. render(useCameraPostProcess?: boolean): void;
  13333. /**
  13334. * Clone the texture.
  13335. * @returns the cloned texture
  13336. */
  13337. clone(): ProceduralTexture;
  13338. /**
  13339. * Dispose the texture and release its asoociated resources.
  13340. */
  13341. dispose(): void;
  13342. }
  13343. }
  13344. declare module BABYLON {
  13345. /**
  13346. * This represents the base class for particle system in Babylon.
  13347. * 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.
  13348. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13349. * @example https://doc.babylonjs.com/babylon101/particles
  13350. */
  13351. export class BaseParticleSystem {
  13352. /**
  13353. * Source color is added to the destination color without alpha affecting the result
  13354. */
  13355. static BLENDMODE_ONEONE: number;
  13356. /**
  13357. * Blend current color and particle color using particle’s alpha
  13358. */
  13359. static BLENDMODE_STANDARD: number;
  13360. /**
  13361. * Add current color and particle color multiplied by particle’s alpha
  13362. */
  13363. static BLENDMODE_ADD: number;
  13364. /**
  13365. * Multiply current color with particle color
  13366. */
  13367. static BLENDMODE_MULTIPLY: number;
  13368. /**
  13369. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13370. */
  13371. static BLENDMODE_MULTIPLYADD: number;
  13372. /**
  13373. * List of animations used by the particle system.
  13374. */
  13375. animations: Animation[];
  13376. /**
  13377. * The id of the Particle system.
  13378. */
  13379. id: string;
  13380. /**
  13381. * The friendly name of the Particle system.
  13382. */
  13383. name: string;
  13384. /**
  13385. * The rendering group used by the Particle system to chose when to render.
  13386. */
  13387. renderingGroupId: number;
  13388. /**
  13389. * The emitter represents the Mesh or position we are attaching the particle system to.
  13390. */
  13391. emitter: Nullable<AbstractMesh | Vector3>;
  13392. /**
  13393. * The maximum number of particles to emit per frame
  13394. */
  13395. emitRate: number;
  13396. /**
  13397. * If you want to launch only a few particles at once, that can be done, as well.
  13398. */
  13399. manualEmitCount: number;
  13400. /**
  13401. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13402. */
  13403. updateSpeed: number;
  13404. /**
  13405. * The amount of time the particle system is running (depends of the overall update speed).
  13406. */
  13407. targetStopDuration: number;
  13408. /**
  13409. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13410. */
  13411. disposeOnStop: boolean;
  13412. /**
  13413. * Minimum power of emitting particles.
  13414. */
  13415. minEmitPower: number;
  13416. /**
  13417. * Maximum power of emitting particles.
  13418. */
  13419. maxEmitPower: number;
  13420. /**
  13421. * Minimum life time of emitting particles.
  13422. */
  13423. minLifeTime: number;
  13424. /**
  13425. * Maximum life time of emitting particles.
  13426. */
  13427. maxLifeTime: number;
  13428. /**
  13429. * Minimum Size of emitting particles.
  13430. */
  13431. minSize: number;
  13432. /**
  13433. * Maximum Size of emitting particles.
  13434. */
  13435. maxSize: number;
  13436. /**
  13437. * Minimum scale of emitting particles on X axis.
  13438. */
  13439. minScaleX: number;
  13440. /**
  13441. * Maximum scale of emitting particles on X axis.
  13442. */
  13443. maxScaleX: number;
  13444. /**
  13445. * Minimum scale of emitting particles on Y axis.
  13446. */
  13447. minScaleY: number;
  13448. /**
  13449. * Maximum scale of emitting particles on Y axis.
  13450. */
  13451. maxScaleY: number;
  13452. /**
  13453. * Gets or sets the minimal initial rotation in radians.
  13454. */
  13455. minInitialRotation: number;
  13456. /**
  13457. * Gets or sets the maximal initial rotation in radians.
  13458. */
  13459. maxInitialRotation: number;
  13460. /**
  13461. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13462. */
  13463. minAngularSpeed: number;
  13464. /**
  13465. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13466. */
  13467. maxAngularSpeed: number;
  13468. /**
  13469. * The texture used to render each particle. (this can be a spritesheet)
  13470. */
  13471. particleTexture: Nullable<Texture>;
  13472. /**
  13473. * The layer mask we are rendering the particles through.
  13474. */
  13475. layerMask: number;
  13476. /**
  13477. * This can help using your own shader to render the particle system.
  13478. * The according effect will be created
  13479. */
  13480. customShader: any;
  13481. /**
  13482. * By default particle system starts as soon as they are created. This prevents the
  13483. * automatic start to happen and let you decide when to start emitting particles.
  13484. */
  13485. preventAutoStart: boolean;
  13486. private _noiseTexture;
  13487. /**
  13488. * Gets or sets a texture used to add random noise to particle positions
  13489. */
  13490. noiseTexture: Nullable<ProceduralTexture>;
  13491. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13492. noiseStrength: Vector3;
  13493. /**
  13494. * Callback triggered when the particle animation is ending.
  13495. */
  13496. onAnimationEnd: Nullable<() => void>;
  13497. /**
  13498. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  13499. */
  13500. blendMode: number;
  13501. /**
  13502. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  13503. * to override the particles.
  13504. */
  13505. forceDepthWrite: boolean;
  13506. /** 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 */
  13507. preWarmCycles: number;
  13508. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  13509. preWarmStepOffset: number;
  13510. /**
  13511. * 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)
  13512. */
  13513. spriteCellChangeSpeed: number;
  13514. /**
  13515. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13516. */
  13517. startSpriteCellID: number;
  13518. /**
  13519. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13520. */
  13521. endSpriteCellID: number;
  13522. /**
  13523. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13524. */
  13525. spriteCellWidth: number;
  13526. /**
  13527. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13528. */
  13529. spriteCellHeight: number;
  13530. /**
  13531. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13532. */
  13533. spriteRandomStartCell: boolean;
  13534. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13535. translationPivot: Vector2;
  13536. /** @hidden */
  13537. protected _isAnimationSheetEnabled: boolean;
  13538. /**
  13539. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13540. */
  13541. beginAnimationOnStart: boolean;
  13542. /**
  13543. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13544. */
  13545. beginAnimationFrom: number;
  13546. /**
  13547. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13548. */
  13549. beginAnimationTo: number;
  13550. /**
  13551. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13552. */
  13553. beginAnimationLoop: boolean;
  13554. /**
  13555. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  13556. */
  13557. isAnimationSheetEnabled: boolean;
  13558. /**
  13559. * Get hosting scene
  13560. * @returns the scene
  13561. */
  13562. getScene(): Scene;
  13563. /**
  13564. * You can use gravity if you want to give an orientation to your particles.
  13565. */
  13566. gravity: Vector3;
  13567. protected _colorGradients: Nullable<Array<ColorGradient>>;
  13568. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  13569. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  13570. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  13571. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  13572. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  13573. protected _dragGradients: Nullable<Array<FactorGradient>>;
  13574. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  13575. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  13576. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  13577. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  13578. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  13579. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  13580. /**
  13581. * Defines the delay in milliseconds before starting the system (0 by default)
  13582. */
  13583. startDelay: number;
  13584. /**
  13585. * Gets the current list of drag gradients.
  13586. * You must use addDragGradient and removeDragGradient to udpate this list
  13587. * @returns the list of drag gradients
  13588. */
  13589. getDragGradients(): Nullable<Array<FactorGradient>>;
  13590. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13591. limitVelocityDamping: number;
  13592. /**
  13593. * Gets the current list of limit velocity gradients.
  13594. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13595. * @returns the list of limit velocity gradients
  13596. */
  13597. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13598. /**
  13599. * Gets the current list of color gradients.
  13600. * You must use addColorGradient and removeColorGradient to udpate this list
  13601. * @returns the list of color gradients
  13602. */
  13603. getColorGradients(): Nullable<Array<ColorGradient>>;
  13604. /**
  13605. * Gets the current list of size gradients.
  13606. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13607. * @returns the list of size gradients
  13608. */
  13609. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13610. /**
  13611. * Gets the current list of color remap gradients.
  13612. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13613. * @returns the list of color remap gradients
  13614. */
  13615. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13616. /**
  13617. * Gets the current list of alpha remap gradients.
  13618. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13619. * @returns the list of alpha remap gradients
  13620. */
  13621. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13622. /**
  13623. * Gets the current list of life time gradients.
  13624. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13625. * @returns the list of life time gradients
  13626. */
  13627. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13628. /**
  13629. * Gets the current list of angular speed gradients.
  13630. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13631. * @returns the list of angular speed gradients
  13632. */
  13633. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13634. /**
  13635. * Gets the current list of velocity gradients.
  13636. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13637. * @returns the list of velocity gradients
  13638. */
  13639. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13640. /**
  13641. * Gets the current list of start size gradients.
  13642. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13643. * @returns the list of start size gradients
  13644. */
  13645. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13646. /**
  13647. * Gets the current list of emit rate gradients.
  13648. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13649. * @returns the list of emit rate gradients
  13650. */
  13651. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13652. /**
  13653. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13654. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13655. */
  13656. direction1: Vector3;
  13657. /**
  13658. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13659. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13660. */
  13661. direction2: Vector3;
  13662. /**
  13663. * 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.
  13664. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13665. */
  13666. minEmitBox: Vector3;
  13667. /**
  13668. * 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.
  13669. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13670. */
  13671. maxEmitBox: Vector3;
  13672. /**
  13673. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  13674. */
  13675. color1: Color4;
  13676. /**
  13677. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  13678. */
  13679. color2: Color4;
  13680. /**
  13681. * Color the particle will have at the end of its lifetime
  13682. */
  13683. colorDead: Color4;
  13684. /**
  13685. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  13686. */
  13687. textureMask: Color4;
  13688. /**
  13689. * The particle emitter type defines the emitter used by the particle system.
  13690. * It can be for example box, sphere, or cone...
  13691. */
  13692. particleEmitterType: IParticleEmitterType;
  13693. /** @hidden */ isSubEmitter: boolean;
  13694. /**
  13695. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13696. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13697. */
  13698. billboardMode: number;
  13699. protected _isBillboardBased: boolean;
  13700. /**
  13701. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13702. */
  13703. isBillboardBased: boolean;
  13704. /**
  13705. * The scene the particle system belongs to.
  13706. */
  13707. protected _scene: Scene;
  13708. /**
  13709. * Local cache of defines for image processing.
  13710. */
  13711. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  13712. /**
  13713. * Default configuration related to image processing available in the standard Material.
  13714. */
  13715. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  13716. /**
  13717. * Gets the image processing configuration used either in this material.
  13718. */
  13719. /**
  13720. * Sets the Default image processing configuration used either in the this material.
  13721. *
  13722. * If sets to null, the scene one is in use.
  13723. */
  13724. imageProcessingConfiguration: ImageProcessingConfiguration;
  13725. /**
  13726. * Attaches a new image processing configuration to the Standard Material.
  13727. * @param configuration
  13728. */
  13729. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  13730. /** @hidden */
  13731. protected _reset(): void;
  13732. /** @hidden */
  13733. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  13734. /**
  13735. * Instantiates a particle system.
  13736. * 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.
  13737. * @param name The name of the particle system
  13738. */
  13739. constructor(name: string);
  13740. /**
  13741. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13742. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13743. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13744. * @returns the emitter
  13745. */
  13746. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13747. /**
  13748. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13749. * @param radius The radius of the hemisphere to emit from
  13750. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13751. * @returns the emitter
  13752. */
  13753. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  13754. /**
  13755. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13756. * @param radius The radius of the sphere to emit from
  13757. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13758. * @returns the emitter
  13759. */
  13760. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  13761. /**
  13762. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13763. * @param radius The radius of the sphere to emit from
  13764. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13765. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13766. * @returns the emitter
  13767. */
  13768. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  13769. /**
  13770. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13771. * @param radius The radius of the emission cylinder
  13772. * @param height The height of the emission cylinder
  13773. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13774. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13775. * @returns the emitter
  13776. */
  13777. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  13778. /**
  13779. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13780. * @param radius The radius of the cylinder to emit from
  13781. * @param height The height of the emission cylinder
  13782. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13783. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13784. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13785. * @returns the emitter
  13786. */
  13787. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  13788. /**
  13789. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13790. * @param radius The radius of the cone to emit from
  13791. * @param angle The base angle of the cone
  13792. * @returns the emitter
  13793. */
  13794. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  13795. /**
  13796. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13797. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13798. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13799. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13800. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13801. * @returns the emitter
  13802. */
  13803. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13804. }
  13805. }
  13806. declare module BABYLON {
  13807. /**
  13808. * Type of sub emitter
  13809. */
  13810. export enum SubEmitterType {
  13811. /**
  13812. * Attached to the particle over it's lifetime
  13813. */
  13814. ATTACHED = 0,
  13815. /**
  13816. * Created when the particle dies
  13817. */
  13818. END = 1
  13819. }
  13820. /**
  13821. * Sub emitter class used to emit particles from an existing particle
  13822. */
  13823. export class SubEmitter {
  13824. /**
  13825. * the particle system to be used by the sub emitter
  13826. */
  13827. particleSystem: ParticleSystem;
  13828. /**
  13829. * Type of the submitter (Default: END)
  13830. */
  13831. type: SubEmitterType;
  13832. /**
  13833. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  13834. * Note: This only is supported when using an emitter of type Mesh
  13835. */
  13836. inheritDirection: boolean;
  13837. /**
  13838. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  13839. */
  13840. inheritedVelocityAmount: number;
  13841. /**
  13842. * Creates a sub emitter
  13843. * @param particleSystem the particle system to be used by the sub emitter
  13844. */
  13845. constructor(
  13846. /**
  13847. * the particle system to be used by the sub emitter
  13848. */
  13849. particleSystem: ParticleSystem);
  13850. /**
  13851. * Clones the sub emitter
  13852. * @returns the cloned sub emitter
  13853. */
  13854. clone(): SubEmitter;
  13855. /**
  13856. * Serialize current object to a JSON object
  13857. * @returns the serialized object
  13858. */
  13859. serialize(): any;
  13860. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  13861. /**
  13862. * Creates a new SubEmitter from a serialized JSON version
  13863. * @param serializationObject defines the JSON object to read from
  13864. * @param scene defines the hosting scene
  13865. * @param rootUrl defines the rootUrl for data loading
  13866. * @returns a new SubEmitter
  13867. */
  13868. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  13869. /** Release associated resources */
  13870. dispose(): void;
  13871. }
  13872. }
  13873. declare module BABYLON {
  13874. /** @hidden */
  13875. export var clipPlaneFragmentDeclaration: {
  13876. name: string;
  13877. shader: string;
  13878. };
  13879. }
  13880. declare module BABYLON {
  13881. /** @hidden */
  13882. export var imageProcessingDeclaration: {
  13883. name: string;
  13884. shader: string;
  13885. };
  13886. }
  13887. declare module BABYLON {
  13888. /** @hidden */
  13889. export var imageProcessingFunctions: {
  13890. name: string;
  13891. shader: string;
  13892. };
  13893. }
  13894. declare module BABYLON {
  13895. /** @hidden */
  13896. export var clipPlaneFragment: {
  13897. name: string;
  13898. shader: string;
  13899. };
  13900. }
  13901. declare module BABYLON {
  13902. /** @hidden */
  13903. export var particlesPixelShader: {
  13904. name: string;
  13905. shader: string;
  13906. };
  13907. }
  13908. declare module BABYLON {
  13909. /** @hidden */
  13910. export var clipPlaneVertexDeclaration: {
  13911. name: string;
  13912. shader: string;
  13913. };
  13914. }
  13915. declare module BABYLON {
  13916. /** @hidden */
  13917. export var clipPlaneVertex: {
  13918. name: string;
  13919. shader: string;
  13920. };
  13921. }
  13922. declare module BABYLON {
  13923. /** @hidden */
  13924. export var particlesVertexShader: {
  13925. name: string;
  13926. shader: string;
  13927. };
  13928. }
  13929. declare module BABYLON {
  13930. /**
  13931. * This represents a particle system in Babylon.
  13932. * 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.
  13933. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13934. * @example https://doc.babylonjs.com/babylon101/particles
  13935. */
  13936. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  13937. /**
  13938. * Billboard mode will only apply to Y axis
  13939. */
  13940. static readonly BILLBOARDMODE_Y: number;
  13941. /**
  13942. * Billboard mode will apply to all axes
  13943. */
  13944. static readonly BILLBOARDMODE_ALL: number;
  13945. /**
  13946. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  13947. */
  13948. static readonly BILLBOARDMODE_STRETCHED: number;
  13949. /**
  13950. * This function can be defined to provide custom update for active particles.
  13951. * This function will be called instead of regular update (age, position, color, etc.).
  13952. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  13953. */
  13954. updateFunction: (particles: Particle[]) => void;
  13955. private _emitterWorldMatrix;
  13956. /**
  13957. * This function can be defined to specify initial direction for every new particle.
  13958. * It by default use the emitterType defined function
  13959. */
  13960. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  13961. /**
  13962. * This function can be defined to specify initial position for every new particle.
  13963. * It by default use the emitterType defined function
  13964. */
  13965. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  13966. /**
  13967. * @hidden
  13968. */ inheritedVelocityOffset: Vector3;
  13969. /**
  13970. * An event triggered when the system is disposed
  13971. */
  13972. onDisposeObservable: Observable<ParticleSystem>;
  13973. private _onDisposeObserver;
  13974. /**
  13975. * Sets a callback that will be triggered when the system is disposed
  13976. */
  13977. onDispose: () => void;
  13978. private _particles;
  13979. private _epsilon;
  13980. private _capacity;
  13981. private _stockParticles;
  13982. private _newPartsExcess;
  13983. private _vertexData;
  13984. private _vertexBuffer;
  13985. private _vertexBuffers;
  13986. private _spriteBuffer;
  13987. private _indexBuffer;
  13988. private _effect;
  13989. private _customEffect;
  13990. private _cachedDefines;
  13991. private _scaledColorStep;
  13992. private _colorDiff;
  13993. private _scaledDirection;
  13994. private _scaledGravity;
  13995. private _currentRenderId;
  13996. private _alive;
  13997. private _useInstancing;
  13998. private _started;
  13999. private _stopped;
  14000. private _actualFrame;
  14001. private _scaledUpdateSpeed;
  14002. private _vertexBufferSize;
  14003. /** @hidden */ currentEmitRateGradient: Nullable<FactorGradient>;
  14004. /** @hidden */ currentEmitRate1: number;
  14005. /** @hidden */ currentEmitRate2: number;
  14006. /** @hidden */ currentStartSizeGradient: Nullable<FactorGradient>;
  14007. /** @hidden */ currentStartSize1: number;
  14008. /** @hidden */ currentStartSize2: number;
  14009. private readonly _rawTextureWidth;
  14010. private _rampGradientsTexture;
  14011. private _useRampGradients;
  14012. /** Gets or sets a boolean indicating that ramp gradients must be used
  14013. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14014. */
  14015. useRampGradients: boolean;
  14016. /**
  14017. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  14018. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  14019. */
  14020. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14021. private _subEmitters;
  14022. /**
  14023. * @hidden
  14024. * If the particle systems emitter should be disposed when the particle system is disposed
  14025. */ disposeEmitterOnDispose: boolean;
  14026. /**
  14027. * The current active Sub-systems, this property is used by the root particle system only.
  14028. */
  14029. activeSubSystems: Array<ParticleSystem>;
  14030. private _rootParticleSystem;
  14031. /**
  14032. * Gets the current list of active particles
  14033. */
  14034. readonly particles: Particle[];
  14035. /**
  14036. * Returns the string "ParticleSystem"
  14037. * @returns a string containing the class name
  14038. */
  14039. getClassName(): string;
  14040. /**
  14041. * Instantiates a particle system.
  14042. * 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.
  14043. * @param name The name of the particle system
  14044. * @param capacity The max number of particles alive at the same time
  14045. * @param scene The scene the particle system belongs to
  14046. * @param customEffect a custom effect used to change the way particles are rendered by default
  14047. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14048. * @param epsilon Offset used to render the particles
  14049. */
  14050. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14051. private _addFactorGradient;
  14052. private _removeFactorGradient;
  14053. /**
  14054. * Adds a new life time gradient
  14055. * @param gradient defines the gradient to use (between 0 and 1)
  14056. * @param factor defines the life time factor to affect to the specified gradient
  14057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14058. * @returns the current particle system
  14059. */
  14060. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14061. /**
  14062. * Remove a specific life time gradient
  14063. * @param gradient defines the gradient to remove
  14064. * @returns the current particle system
  14065. */
  14066. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14067. /**
  14068. * Adds a new size gradient
  14069. * @param gradient defines the gradient to use (between 0 and 1)
  14070. * @param factor defines the size factor to affect to the specified gradient
  14071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14072. * @returns the current particle system
  14073. */
  14074. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14075. /**
  14076. * Remove a specific size gradient
  14077. * @param gradient defines the gradient to remove
  14078. * @returns the current particle system
  14079. */
  14080. removeSizeGradient(gradient: number): IParticleSystem;
  14081. /**
  14082. * Adds a new color remap gradient
  14083. * @param gradient defines the gradient to use (between 0 and 1)
  14084. * @param min defines the color remap minimal range
  14085. * @param max defines the color remap maximal range
  14086. * @returns the current particle system
  14087. */
  14088. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14089. /**
  14090. * Remove a specific color remap gradient
  14091. * @param gradient defines the gradient to remove
  14092. * @returns the current particle system
  14093. */
  14094. removeColorRemapGradient(gradient: number): IParticleSystem;
  14095. /**
  14096. * Adds a new alpha remap gradient
  14097. * @param gradient defines the gradient to use (between 0 and 1)
  14098. * @param min defines the alpha remap minimal range
  14099. * @param max defines the alpha remap maximal range
  14100. * @returns the current particle system
  14101. */
  14102. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14103. /**
  14104. * Remove a specific alpha remap gradient
  14105. * @param gradient defines the gradient to remove
  14106. * @returns the current particle system
  14107. */
  14108. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14109. /**
  14110. * Adds a new angular speed gradient
  14111. * @param gradient defines the gradient to use (between 0 and 1)
  14112. * @param factor defines the angular speed to affect to the specified gradient
  14113. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14114. * @returns the current particle system
  14115. */
  14116. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14117. /**
  14118. * Remove a specific angular speed gradient
  14119. * @param gradient defines the gradient to remove
  14120. * @returns the current particle system
  14121. */
  14122. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14123. /**
  14124. * Adds a new velocity gradient
  14125. * @param gradient defines the gradient to use (between 0 and 1)
  14126. * @param factor defines the velocity to affect to the specified gradient
  14127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14128. * @returns the current particle system
  14129. */
  14130. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14131. /**
  14132. * Remove a specific velocity gradient
  14133. * @param gradient defines the gradient to remove
  14134. * @returns the current particle system
  14135. */
  14136. removeVelocityGradient(gradient: number): IParticleSystem;
  14137. /**
  14138. * Adds a new limit velocity gradient
  14139. * @param gradient defines the gradient to use (between 0 and 1)
  14140. * @param factor defines the limit velocity value to affect to the specified gradient
  14141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14142. * @returns the current particle system
  14143. */
  14144. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14145. /**
  14146. * Remove a specific limit velocity gradient
  14147. * @param gradient defines the gradient to remove
  14148. * @returns the current particle system
  14149. */
  14150. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14151. /**
  14152. * Adds a new drag gradient
  14153. * @param gradient defines the gradient to use (between 0 and 1)
  14154. * @param factor defines the drag value to affect to the specified gradient
  14155. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14156. * @returns the current particle system
  14157. */
  14158. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14159. /**
  14160. * Remove a specific drag gradient
  14161. * @param gradient defines the gradient to remove
  14162. * @returns the current particle system
  14163. */
  14164. removeDragGradient(gradient: number): IParticleSystem;
  14165. /**
  14166. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14167. * @param gradient defines the gradient to use (between 0 and 1)
  14168. * @param factor defines the emit rate value to affect to the specified gradient
  14169. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14170. * @returns the current particle system
  14171. */
  14172. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14173. /**
  14174. * Remove a specific emit rate gradient
  14175. * @param gradient defines the gradient to remove
  14176. * @returns the current particle system
  14177. */
  14178. removeEmitRateGradient(gradient: number): IParticleSystem;
  14179. /**
  14180. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14181. * @param gradient defines the gradient to use (between 0 and 1)
  14182. * @param factor defines the start size value to affect to the specified gradient
  14183. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14184. * @returns the current particle system
  14185. */
  14186. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14187. /**
  14188. * Remove a specific start size gradient
  14189. * @param gradient defines the gradient to remove
  14190. * @returns the current particle system
  14191. */
  14192. removeStartSizeGradient(gradient: number): IParticleSystem;
  14193. private _createRampGradientTexture;
  14194. /**
  14195. * Gets the current list of ramp gradients.
  14196. * You must use addRampGradient and removeRampGradient to udpate this list
  14197. * @returns the list of ramp gradients
  14198. */
  14199. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14200. /**
  14201. * Adds a new ramp gradient used to remap particle colors
  14202. * @param gradient defines the gradient to use (between 0 and 1)
  14203. * @param color defines the color to affect to the specified gradient
  14204. * @returns the current particle system
  14205. */
  14206. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14207. /**
  14208. * Remove a specific ramp gradient
  14209. * @param gradient defines the gradient to remove
  14210. * @returns the current particle system
  14211. */
  14212. removeRampGradient(gradient: number): ParticleSystem;
  14213. /**
  14214. * Adds a new color gradient
  14215. * @param gradient defines the gradient to use (between 0 and 1)
  14216. * @param color1 defines the color to affect to the specified gradient
  14217. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14218. * @returns this particle system
  14219. */
  14220. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14221. /**
  14222. * Remove a specific color gradient
  14223. * @param gradient defines the gradient to remove
  14224. * @returns this particle system
  14225. */
  14226. removeColorGradient(gradient: number): IParticleSystem;
  14227. private _fetchR;
  14228. protected _reset(): void;
  14229. private _resetEffect;
  14230. private _createVertexBuffers;
  14231. private _createIndexBuffer;
  14232. /**
  14233. * Gets the maximum number of particles active at the same time.
  14234. * @returns The max number of active particles.
  14235. */
  14236. getCapacity(): number;
  14237. /**
  14238. * Gets whether there are still active particles in the system.
  14239. * @returns True if it is alive, otherwise false.
  14240. */
  14241. isAlive(): boolean;
  14242. /**
  14243. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14244. * @returns True if it has been started, otherwise false.
  14245. */
  14246. isStarted(): boolean;
  14247. private _prepareSubEmitterInternalArray;
  14248. /**
  14249. * Starts the particle system and begins to emit
  14250. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14251. */
  14252. start(delay?: number): void;
  14253. /**
  14254. * Stops the particle system.
  14255. * @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.
  14256. */
  14257. stop(stopSubEmitters?: boolean): void;
  14258. /**
  14259. * Remove all active particles
  14260. */
  14261. reset(): void;
  14262. /**
  14263. * @hidden (for internal use only)
  14264. */ appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14265. /**
  14266. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14267. * Its lifetime will start back at 0.
  14268. */
  14269. recycleParticle: (particle: Particle) => void;
  14270. private _stopSubEmitters;
  14271. private _createParticle;
  14272. private _removeFromRoot;
  14273. private _emitFromParticle;
  14274. private _update;
  14275. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14276. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14277. /** @hidden */
  14278. private _getEffect;
  14279. /**
  14280. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14281. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14282. */
  14283. animate(preWarmOnly?: boolean): void;
  14284. private _appendParticleVertices;
  14285. /**
  14286. * Rebuilds the particle system.
  14287. */
  14288. rebuild(): void;
  14289. /**
  14290. * Is this system ready to be used/rendered
  14291. * @return true if the system is ready
  14292. */
  14293. isReady(): boolean;
  14294. private _render;
  14295. /**
  14296. * Renders the particle system in its current state.
  14297. * @returns the current number of particles
  14298. */
  14299. render(): number;
  14300. /**
  14301. * Disposes the particle system and free the associated resources
  14302. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14303. */
  14304. dispose(disposeTexture?: boolean): void;
  14305. /**
  14306. * Clones the particle system.
  14307. * @param name The name of the cloned object
  14308. * @param newEmitter The new emitter to use
  14309. * @returns the cloned particle system
  14310. */
  14311. clone(name: string, newEmitter: any): ParticleSystem;
  14312. /**
  14313. * Serializes the particle system to a JSON object.
  14314. * @returns the JSON object
  14315. */
  14316. serialize(): any;
  14317. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14318. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14319. /**
  14320. * Parses a JSON object to create a particle system.
  14321. * @param parsedParticleSystem The JSON object to parse
  14322. * @param scene The scene to create the particle system in
  14323. * @param rootUrl The root url to use to load external dependencies like texture
  14324. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14325. * @returns the Parsed particle system
  14326. */
  14327. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14328. }
  14329. }
  14330. declare module BABYLON {
  14331. /**
  14332. * A particle represents one of the element emitted by a particle system.
  14333. * This is mainly define by its coordinates, direction, velocity and age.
  14334. */
  14335. export class Particle {
  14336. /**
  14337. * The particle system the particle belongs to.
  14338. */
  14339. particleSystem: ParticleSystem;
  14340. private static _Count;
  14341. /**
  14342. * Unique ID of the particle
  14343. */
  14344. id: number;
  14345. /**
  14346. * The world position of the particle in the scene.
  14347. */
  14348. position: Vector3;
  14349. /**
  14350. * The world direction of the particle in the scene.
  14351. */
  14352. direction: Vector3;
  14353. /**
  14354. * The color of the particle.
  14355. */
  14356. color: Color4;
  14357. /**
  14358. * The color change of the particle per step.
  14359. */
  14360. colorStep: Color4;
  14361. /**
  14362. * Defines how long will the life of the particle be.
  14363. */
  14364. lifeTime: number;
  14365. /**
  14366. * The current age of the particle.
  14367. */
  14368. age: number;
  14369. /**
  14370. * The current size of the particle.
  14371. */
  14372. size: number;
  14373. /**
  14374. * The current scale of the particle.
  14375. */
  14376. scale: Vector2;
  14377. /**
  14378. * The current angle of the particle.
  14379. */
  14380. angle: number;
  14381. /**
  14382. * Defines how fast is the angle changing.
  14383. */
  14384. angularSpeed: number;
  14385. /**
  14386. * Defines the cell index used by the particle to be rendered from a sprite.
  14387. */
  14388. cellIndex: number;
  14389. /**
  14390. * The information required to support color remapping
  14391. */
  14392. remapData: Vector4;
  14393. /** @hidden */ randomCellOffset?: number;
  14394. /** @hidden */ initialDirection: Nullable<Vector3>;
  14395. /** @hidden */ attachedSubEmitters: Nullable<Array<SubEmitter>>;
  14396. /** @hidden */ initialStartSpriteCellID: number;
  14397. /** @hidden */ initialEndSpriteCellID: number;
  14398. /** @hidden */ currentColorGradient: Nullable<ColorGradient>;
  14399. /** @hidden */ currentColor1: Color4;
  14400. /** @hidden */ currentColor2: Color4;
  14401. /** @hidden */ currentSizeGradient: Nullable<FactorGradient>;
  14402. /** @hidden */ currentSize1: number;
  14403. /** @hidden */ currentSize2: number;
  14404. /** @hidden */ currentAngularSpeedGradient: Nullable<FactorGradient>;
  14405. /** @hidden */ currentAngularSpeed1: number;
  14406. /** @hidden */ currentAngularSpeed2: number;
  14407. /** @hidden */ currentVelocityGradient: Nullable<FactorGradient>;
  14408. /** @hidden */ currentVelocity1: number;
  14409. /** @hidden */ currentVelocity2: number;
  14410. /** @hidden */ currentLimitVelocityGradient: Nullable<FactorGradient>;
  14411. /** @hidden */ currentLimitVelocity1: number;
  14412. /** @hidden */ currentLimitVelocity2: number;
  14413. /** @hidden */ currentDragGradient: Nullable<FactorGradient>;
  14414. /** @hidden */ currentDrag1: number;
  14415. /** @hidden */ currentDrag2: number;
  14416. /** @hidden */ randomNoiseCoordinates1: Vector3;
  14417. /** @hidden */ randomNoiseCoordinates2: Vector3;
  14418. /**
  14419. * Creates a new instance Particle
  14420. * @param particleSystem the particle system the particle belongs to
  14421. */
  14422. constructor(
  14423. /**
  14424. * The particle system the particle belongs to.
  14425. */
  14426. particleSystem: ParticleSystem);
  14427. private updateCellInfoFromSystem;
  14428. /**
  14429. * Defines how the sprite cell index is updated for the particle
  14430. */
  14431. updateCellIndex(): void;
  14432. /** @hidden */ inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  14433. /** @hidden */ inheritParticleInfoToSubEmitters(): void;
  14434. /** @hidden */ reset(): void;
  14435. /**
  14436. * Copy the properties of particle to another one.
  14437. * @param other the particle to copy the information to.
  14438. */
  14439. copyTo(other: Particle): void;
  14440. }
  14441. }
  14442. declare module BABYLON {
  14443. /**
  14444. * Particle emitter represents a volume emitting particles.
  14445. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  14446. */
  14447. export interface IParticleEmitterType {
  14448. /**
  14449. * Called by the particle System when the direction is computed for the created particle.
  14450. * @param worldMatrix is the world matrix of the particle system
  14451. * @param directionToUpdate is the direction vector to update with the result
  14452. * @param particle is the particle we are computed the direction for
  14453. */
  14454. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14455. /**
  14456. * Called by the particle System when the position is computed for the created particle.
  14457. * @param worldMatrix is the world matrix of the particle system
  14458. * @param positionToUpdate is the position vector to update with the result
  14459. * @param particle is the particle we are computed the position for
  14460. */
  14461. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14462. /**
  14463. * Clones the current emitter and returns a copy of it
  14464. * @returns the new emitter
  14465. */
  14466. clone(): IParticleEmitterType;
  14467. /**
  14468. * Called by the GPUParticleSystem to setup the update shader
  14469. * @param effect defines the update shader
  14470. */
  14471. applyToShader(effect: Effect): void;
  14472. /**
  14473. * Returns a string to use to update the GPU particles update shader
  14474. * @returns the effect defines string
  14475. */
  14476. getEffectDefines(): string;
  14477. /**
  14478. * Returns a string representing the class name
  14479. * @returns a string containing the class name
  14480. */
  14481. getClassName(): string;
  14482. /**
  14483. * Serializes the particle system to a JSON object.
  14484. * @returns the JSON object
  14485. */
  14486. serialize(): any;
  14487. /**
  14488. * Parse properties from a JSON object
  14489. * @param serializationObject defines the JSON object
  14490. */
  14491. parse(serializationObject: any): void;
  14492. }
  14493. }
  14494. declare module BABYLON {
  14495. /**
  14496. * Particle emitter emitting particles from the inside of a box.
  14497. * It emits the particles randomly between 2 given directions.
  14498. */
  14499. export class BoxParticleEmitter implements IParticleEmitterType {
  14500. /**
  14501. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14502. */
  14503. direction1: Vector3;
  14504. /**
  14505. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14506. */
  14507. direction2: Vector3;
  14508. /**
  14509. * 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.
  14510. */
  14511. minEmitBox: Vector3;
  14512. /**
  14513. * 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.
  14514. */
  14515. maxEmitBox: Vector3;
  14516. /**
  14517. * Creates a new instance BoxParticleEmitter
  14518. */
  14519. constructor();
  14520. /**
  14521. * Called by the particle System when the direction is computed for the created particle.
  14522. * @param worldMatrix is the world matrix of the particle system
  14523. * @param directionToUpdate is the direction vector to update with the result
  14524. * @param particle is the particle we are computed the direction for
  14525. */
  14526. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14527. /**
  14528. * Called by the particle System when the position is computed for the created particle.
  14529. * @param worldMatrix is the world matrix of the particle system
  14530. * @param positionToUpdate is the position vector to update with the result
  14531. * @param particle is the particle we are computed the position for
  14532. */
  14533. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14534. /**
  14535. * Clones the current emitter and returns a copy of it
  14536. * @returns the new emitter
  14537. */
  14538. clone(): BoxParticleEmitter;
  14539. /**
  14540. * Called by the GPUParticleSystem to setup the update shader
  14541. * @param effect defines the update shader
  14542. */
  14543. applyToShader(effect: Effect): void;
  14544. /**
  14545. * Returns a string to use to update the GPU particles update shader
  14546. * @returns a string containng the defines string
  14547. */
  14548. getEffectDefines(): string;
  14549. /**
  14550. * Returns the string "BoxParticleEmitter"
  14551. * @returns a string containing the class name
  14552. */
  14553. getClassName(): string;
  14554. /**
  14555. * Serializes the particle system to a JSON object.
  14556. * @returns the JSON object
  14557. */
  14558. serialize(): any;
  14559. /**
  14560. * Parse properties from a JSON object
  14561. * @param serializationObject defines the JSON object
  14562. */
  14563. parse(serializationObject: any): void;
  14564. }
  14565. }
  14566. declare module BABYLON {
  14567. /**
  14568. * Particle emitter emitting particles from the inside of a cone.
  14569. * It emits the particles alongside the cone volume from the base to the particle.
  14570. * The emission direction might be randomized.
  14571. */
  14572. export class ConeParticleEmitter implements IParticleEmitterType {
  14573. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  14574. directionRandomizer: number;
  14575. private _radius;
  14576. private _angle;
  14577. private _height;
  14578. /**
  14579. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  14580. */
  14581. radiusRange: number;
  14582. /**
  14583. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  14584. */
  14585. heightRange: number;
  14586. /**
  14587. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  14588. */
  14589. emitFromSpawnPointOnly: boolean;
  14590. /**
  14591. * Gets or sets the radius of the emission cone
  14592. */
  14593. radius: number;
  14594. /**
  14595. * Gets or sets the angle of the emission cone
  14596. */
  14597. angle: number;
  14598. private _buildHeight;
  14599. /**
  14600. * Creates a new instance ConeParticleEmitter
  14601. * @param radius the radius of the emission cone (1 by default)
  14602. * @param angle the cone base angle (PI by default)
  14603. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  14604. */
  14605. constructor(radius?: number, angle?: number,
  14606. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  14607. directionRandomizer?: number);
  14608. /**
  14609. * Called by the particle System when the direction is computed for the created particle.
  14610. * @param worldMatrix is the world matrix of the particle system
  14611. * @param directionToUpdate is the direction vector to update with the result
  14612. * @param particle is the particle we are computed the direction for
  14613. */
  14614. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14615. /**
  14616. * Called by the particle System when the position is computed for the created particle.
  14617. * @param worldMatrix is the world matrix of the particle system
  14618. * @param positionToUpdate is the position vector to update with the result
  14619. * @param particle is the particle we are computed the position for
  14620. */
  14621. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14622. /**
  14623. * Clones the current emitter and returns a copy of it
  14624. * @returns the new emitter
  14625. */
  14626. clone(): ConeParticleEmitter;
  14627. /**
  14628. * Called by the GPUParticleSystem to setup the update shader
  14629. * @param effect defines the update shader
  14630. */
  14631. applyToShader(effect: Effect): void;
  14632. /**
  14633. * Returns a string to use to update the GPU particles update shader
  14634. * @returns a string containng the defines string
  14635. */
  14636. getEffectDefines(): string;
  14637. /**
  14638. * Returns the string "ConeParticleEmitter"
  14639. * @returns a string containing the class name
  14640. */
  14641. getClassName(): string;
  14642. /**
  14643. * Serializes the particle system to a JSON object.
  14644. * @returns the JSON object
  14645. */
  14646. serialize(): any;
  14647. /**
  14648. * Parse properties from a JSON object
  14649. * @param serializationObject defines the JSON object
  14650. */
  14651. parse(serializationObject: any): void;
  14652. }
  14653. }
  14654. declare module BABYLON {
  14655. /**
  14656. * Particle emitter emitting particles from the inside of a cylinder.
  14657. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  14658. */
  14659. export class CylinderParticleEmitter implements IParticleEmitterType {
  14660. /**
  14661. * The radius of the emission cylinder.
  14662. */
  14663. radius: number;
  14664. /**
  14665. * The height of the emission cylinder.
  14666. */
  14667. height: number;
  14668. /**
  14669. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14670. */
  14671. radiusRange: number;
  14672. /**
  14673. * How much to randomize the particle direction [0-1].
  14674. */
  14675. directionRandomizer: number;
  14676. /**
  14677. * Creates a new instance CylinderParticleEmitter
  14678. * @param radius the radius of the emission cylinder (1 by default)
  14679. * @param height the height of the emission cylinder (1 by default)
  14680. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14681. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14682. */
  14683. constructor(
  14684. /**
  14685. * The radius of the emission cylinder.
  14686. */
  14687. radius?: number,
  14688. /**
  14689. * The height of the emission cylinder.
  14690. */
  14691. height?: number,
  14692. /**
  14693. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14694. */
  14695. radiusRange?: number,
  14696. /**
  14697. * How much to randomize the particle direction [0-1].
  14698. */
  14699. directionRandomizer?: number);
  14700. /**
  14701. * Called by the particle System when the direction is computed for the created particle.
  14702. * @param worldMatrix is the world matrix of the particle system
  14703. * @param directionToUpdate is the direction vector to update with the result
  14704. * @param particle is the particle we are computed the direction for
  14705. */
  14706. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14707. /**
  14708. * Called by the particle System when the position is computed for the created particle.
  14709. * @param worldMatrix is the world matrix of the particle system
  14710. * @param positionToUpdate is the position vector to update with the result
  14711. * @param particle is the particle we are computed the position for
  14712. */
  14713. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14714. /**
  14715. * Clones the current emitter and returns a copy of it
  14716. * @returns the new emitter
  14717. */
  14718. clone(): CylinderParticleEmitter;
  14719. /**
  14720. * Called by the GPUParticleSystem to setup the update shader
  14721. * @param effect defines the update shader
  14722. */
  14723. applyToShader(effect: Effect): void;
  14724. /**
  14725. * Returns a string to use to update the GPU particles update shader
  14726. * @returns a string containng the defines string
  14727. */
  14728. getEffectDefines(): string;
  14729. /**
  14730. * Returns the string "CylinderParticleEmitter"
  14731. * @returns a string containing the class name
  14732. */
  14733. getClassName(): string;
  14734. /**
  14735. * Serializes the particle system to a JSON object.
  14736. * @returns the JSON object
  14737. */
  14738. serialize(): any;
  14739. /**
  14740. * Parse properties from a JSON object
  14741. * @param serializationObject defines the JSON object
  14742. */
  14743. parse(serializationObject: any): void;
  14744. }
  14745. /**
  14746. * Particle emitter emitting particles from the inside of a cylinder.
  14747. * It emits the particles randomly between two vectors.
  14748. */
  14749. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  14750. /**
  14751. * The min limit of the emission direction.
  14752. */
  14753. direction1: Vector3;
  14754. /**
  14755. * The max limit of the emission direction.
  14756. */
  14757. direction2: Vector3;
  14758. /**
  14759. * Creates a new instance CylinderDirectedParticleEmitter
  14760. * @param radius the radius of the emission cylinder (1 by default)
  14761. * @param height the height of the emission cylinder (1 by default)
  14762. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14763. * @param direction1 the min limit of the emission direction (up vector by default)
  14764. * @param direction2 the max limit of the emission direction (up vector by default)
  14765. */
  14766. constructor(radius?: number, height?: number, radiusRange?: number,
  14767. /**
  14768. * The min limit of the emission direction.
  14769. */
  14770. direction1?: Vector3,
  14771. /**
  14772. * The max limit of the emission direction.
  14773. */
  14774. direction2?: Vector3);
  14775. /**
  14776. * Called by the particle System when the direction is computed for the created particle.
  14777. * @param worldMatrix is the world matrix of the particle system
  14778. * @param directionToUpdate is the direction vector to update with the result
  14779. * @param particle is the particle we are computed the direction for
  14780. */
  14781. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14782. /**
  14783. * Clones the current emitter and returns a copy of it
  14784. * @returns the new emitter
  14785. */
  14786. clone(): CylinderDirectedParticleEmitter;
  14787. /**
  14788. * Called by the GPUParticleSystem to setup the update shader
  14789. * @param effect defines the update shader
  14790. */
  14791. applyToShader(effect: Effect): void;
  14792. /**
  14793. * Returns a string to use to update the GPU particles update shader
  14794. * @returns a string containng the defines string
  14795. */
  14796. getEffectDefines(): string;
  14797. /**
  14798. * Returns the string "CylinderDirectedParticleEmitter"
  14799. * @returns a string containing the class name
  14800. */
  14801. getClassName(): string;
  14802. /**
  14803. * Serializes the particle system to a JSON object.
  14804. * @returns the JSON object
  14805. */
  14806. serialize(): any;
  14807. /**
  14808. * Parse properties from a JSON object
  14809. * @param serializationObject defines the JSON object
  14810. */
  14811. parse(serializationObject: any): void;
  14812. }
  14813. }
  14814. declare module BABYLON {
  14815. /**
  14816. * Particle emitter emitting particles from the inside of a hemisphere.
  14817. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  14818. */
  14819. export class HemisphericParticleEmitter implements IParticleEmitterType {
  14820. /**
  14821. * The radius of the emission hemisphere.
  14822. */
  14823. radius: number;
  14824. /**
  14825. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14826. */
  14827. radiusRange: number;
  14828. /**
  14829. * How much to randomize the particle direction [0-1].
  14830. */
  14831. directionRandomizer: number;
  14832. /**
  14833. * Creates a new instance HemisphericParticleEmitter
  14834. * @param radius the radius of the emission hemisphere (1 by default)
  14835. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14836. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14837. */
  14838. constructor(
  14839. /**
  14840. * The radius of the emission hemisphere.
  14841. */
  14842. radius?: number,
  14843. /**
  14844. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14845. */
  14846. radiusRange?: number,
  14847. /**
  14848. * How much to randomize the particle direction [0-1].
  14849. */
  14850. directionRandomizer?: number);
  14851. /**
  14852. * Called by the particle System when the direction is computed for the created particle.
  14853. * @param worldMatrix is the world matrix of the particle system
  14854. * @param directionToUpdate is the direction vector to update with the result
  14855. * @param particle is the particle we are computed the direction for
  14856. */
  14857. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14858. /**
  14859. * Called by the particle System when the position is computed for the created particle.
  14860. * @param worldMatrix is the world matrix of the particle system
  14861. * @param positionToUpdate is the position vector to update with the result
  14862. * @param particle is the particle we are computed the position for
  14863. */
  14864. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14865. /**
  14866. * Clones the current emitter and returns a copy of it
  14867. * @returns the new emitter
  14868. */
  14869. clone(): HemisphericParticleEmitter;
  14870. /**
  14871. * Called by the GPUParticleSystem to setup the update shader
  14872. * @param effect defines the update shader
  14873. */
  14874. applyToShader(effect: Effect): void;
  14875. /**
  14876. * Returns a string to use to update the GPU particles update shader
  14877. * @returns a string containng the defines string
  14878. */
  14879. getEffectDefines(): string;
  14880. /**
  14881. * Returns the string "HemisphericParticleEmitter"
  14882. * @returns a string containing the class name
  14883. */
  14884. getClassName(): string;
  14885. /**
  14886. * Serializes the particle system to a JSON object.
  14887. * @returns the JSON object
  14888. */
  14889. serialize(): any;
  14890. /**
  14891. * Parse properties from a JSON object
  14892. * @param serializationObject defines the JSON object
  14893. */
  14894. parse(serializationObject: any): void;
  14895. }
  14896. }
  14897. declare module BABYLON {
  14898. /**
  14899. * Particle emitter emitting particles from a point.
  14900. * It emits the particles randomly between 2 given directions.
  14901. */
  14902. export class PointParticleEmitter implements IParticleEmitterType {
  14903. /**
  14904. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14905. */
  14906. direction1: Vector3;
  14907. /**
  14908. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14909. */
  14910. direction2: Vector3;
  14911. /**
  14912. * Creates a new instance PointParticleEmitter
  14913. */
  14914. constructor();
  14915. /**
  14916. * Called by the particle System when the direction is computed for the created particle.
  14917. * @param worldMatrix is the world matrix of the particle system
  14918. * @param directionToUpdate is the direction vector to update with the result
  14919. * @param particle is the particle we are computed the direction for
  14920. */
  14921. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14922. /**
  14923. * Called by the particle System when the position is computed for the created particle.
  14924. * @param worldMatrix is the world matrix of the particle system
  14925. * @param positionToUpdate is the position vector to update with the result
  14926. * @param particle is the particle we are computed the position for
  14927. */
  14928. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14929. /**
  14930. * Clones the current emitter and returns a copy of it
  14931. * @returns the new emitter
  14932. */
  14933. clone(): PointParticleEmitter;
  14934. /**
  14935. * Called by the GPUParticleSystem to setup the update shader
  14936. * @param effect defines the update shader
  14937. */
  14938. applyToShader(effect: Effect): void;
  14939. /**
  14940. * Returns a string to use to update the GPU particles update shader
  14941. * @returns a string containng the defines string
  14942. */
  14943. getEffectDefines(): string;
  14944. /**
  14945. * Returns the string "PointParticleEmitter"
  14946. * @returns a string containing the class name
  14947. */
  14948. getClassName(): string;
  14949. /**
  14950. * Serializes the particle system to a JSON object.
  14951. * @returns the JSON object
  14952. */
  14953. serialize(): any;
  14954. /**
  14955. * Parse properties from a JSON object
  14956. * @param serializationObject defines the JSON object
  14957. */
  14958. parse(serializationObject: any): void;
  14959. }
  14960. }
  14961. declare module BABYLON {
  14962. /**
  14963. * Particle emitter emitting particles from the inside of a sphere.
  14964. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14965. */
  14966. export class SphereParticleEmitter implements IParticleEmitterType {
  14967. /**
  14968. * The radius of the emission sphere.
  14969. */
  14970. radius: number;
  14971. /**
  14972. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14973. */
  14974. radiusRange: number;
  14975. /**
  14976. * How much to randomize the particle direction [0-1].
  14977. */
  14978. directionRandomizer: number;
  14979. /**
  14980. * Creates a new instance SphereParticleEmitter
  14981. * @param radius the radius of the emission sphere (1 by default)
  14982. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14983. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14984. */
  14985. constructor(
  14986. /**
  14987. * The radius of the emission sphere.
  14988. */
  14989. radius?: number,
  14990. /**
  14991. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14992. */
  14993. radiusRange?: number,
  14994. /**
  14995. * How much to randomize the particle direction [0-1].
  14996. */
  14997. directionRandomizer?: number);
  14998. /**
  14999. * Called by the particle System when the direction is computed for the created particle.
  15000. * @param worldMatrix is the world matrix of the particle system
  15001. * @param directionToUpdate is the direction vector to update with the result
  15002. * @param particle is the particle we are computed the direction for
  15003. */
  15004. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15005. /**
  15006. * Called by the particle System when the position is computed for the created particle.
  15007. * @param worldMatrix is the world matrix of the particle system
  15008. * @param positionToUpdate is the position vector to update with the result
  15009. * @param particle is the particle we are computed the position for
  15010. */
  15011. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15012. /**
  15013. * Clones the current emitter and returns a copy of it
  15014. * @returns the new emitter
  15015. */
  15016. clone(): SphereParticleEmitter;
  15017. /**
  15018. * Called by the GPUParticleSystem to setup the update shader
  15019. * @param effect defines the update shader
  15020. */
  15021. applyToShader(effect: Effect): void;
  15022. /**
  15023. * Returns a string to use to update the GPU particles update shader
  15024. * @returns a string containng the defines string
  15025. */
  15026. getEffectDefines(): string;
  15027. /**
  15028. * Returns the string "SphereParticleEmitter"
  15029. * @returns a string containing the class name
  15030. */
  15031. getClassName(): string;
  15032. /**
  15033. * Serializes the particle system to a JSON object.
  15034. * @returns the JSON object
  15035. */
  15036. serialize(): any;
  15037. /**
  15038. * Parse properties from a JSON object
  15039. * @param serializationObject defines the JSON object
  15040. */
  15041. parse(serializationObject: any): void;
  15042. }
  15043. /**
  15044. * Particle emitter emitting particles from the inside of a sphere.
  15045. * It emits the particles randomly between two vectors.
  15046. */
  15047. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15048. /**
  15049. * The min limit of the emission direction.
  15050. */
  15051. direction1: Vector3;
  15052. /**
  15053. * The max limit of the emission direction.
  15054. */
  15055. direction2: Vector3;
  15056. /**
  15057. * Creates a new instance SphereDirectedParticleEmitter
  15058. * @param radius the radius of the emission sphere (1 by default)
  15059. * @param direction1 the min limit of the emission direction (up vector by default)
  15060. * @param direction2 the max limit of the emission direction (up vector by default)
  15061. */
  15062. constructor(radius?: number,
  15063. /**
  15064. * The min limit of the emission direction.
  15065. */
  15066. direction1?: Vector3,
  15067. /**
  15068. * The max limit of the emission direction.
  15069. */
  15070. direction2?: Vector3);
  15071. /**
  15072. * Called by the particle System when the direction is computed for the created particle.
  15073. * @param worldMatrix is the world matrix of the particle system
  15074. * @param directionToUpdate is the direction vector to update with the result
  15075. * @param particle is the particle we are computed the direction for
  15076. */
  15077. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15078. /**
  15079. * Clones the current emitter and returns a copy of it
  15080. * @returns the new emitter
  15081. */
  15082. clone(): SphereDirectedParticleEmitter;
  15083. /**
  15084. * Called by the GPUParticleSystem to setup the update shader
  15085. * @param effect defines the update shader
  15086. */
  15087. applyToShader(effect: Effect): void;
  15088. /**
  15089. * Returns a string to use to update the GPU particles update shader
  15090. * @returns a string containng the defines string
  15091. */
  15092. getEffectDefines(): string;
  15093. /**
  15094. * Returns the string "SphereDirectedParticleEmitter"
  15095. * @returns a string containing the class name
  15096. */
  15097. getClassName(): string;
  15098. /**
  15099. * Serializes the particle system to a JSON object.
  15100. * @returns the JSON object
  15101. */
  15102. serialize(): any;
  15103. /**
  15104. * Parse properties from a JSON object
  15105. * @param serializationObject defines the JSON object
  15106. */
  15107. parse(serializationObject: any): void;
  15108. }
  15109. }
  15110. declare module BABYLON {
  15111. /**
  15112. * Interface representing a particle system in Babylon.js.
  15113. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15114. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15115. */
  15116. export interface IParticleSystem {
  15117. /**
  15118. * List of animations used by the particle system.
  15119. */
  15120. animations: Animation[];
  15121. /**
  15122. * The id of the Particle system.
  15123. */
  15124. id: string;
  15125. /**
  15126. * The name of the Particle system.
  15127. */
  15128. name: string;
  15129. /**
  15130. * The emitter represents the Mesh or position we are attaching the particle system to.
  15131. */
  15132. emitter: Nullable<AbstractMesh | Vector3>;
  15133. /**
  15134. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15135. */
  15136. isBillboardBased: boolean;
  15137. /**
  15138. * The rendering group used by the Particle system to chose when to render.
  15139. */
  15140. renderingGroupId: number;
  15141. /**
  15142. * The layer mask we are rendering the particles through.
  15143. */
  15144. layerMask: number;
  15145. /**
  15146. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15147. */
  15148. updateSpeed: number;
  15149. /**
  15150. * The amount of time the particle system is running (depends of the overall update speed).
  15151. */
  15152. targetStopDuration: number;
  15153. /**
  15154. * The texture used to render each particle. (this can be a spritesheet)
  15155. */
  15156. particleTexture: Nullable<Texture>;
  15157. /**
  15158. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15159. */
  15160. blendMode: number;
  15161. /**
  15162. * Minimum life time of emitting particles.
  15163. */
  15164. minLifeTime: number;
  15165. /**
  15166. * Maximum life time of emitting particles.
  15167. */
  15168. maxLifeTime: number;
  15169. /**
  15170. * Minimum Size of emitting particles.
  15171. */
  15172. minSize: number;
  15173. /**
  15174. * Maximum Size of emitting particles.
  15175. */
  15176. maxSize: number;
  15177. /**
  15178. * Minimum scale of emitting particles on X axis.
  15179. */
  15180. minScaleX: number;
  15181. /**
  15182. * Maximum scale of emitting particles on X axis.
  15183. */
  15184. maxScaleX: number;
  15185. /**
  15186. * Minimum scale of emitting particles on Y axis.
  15187. */
  15188. minScaleY: number;
  15189. /**
  15190. * Maximum scale of emitting particles on Y axis.
  15191. */
  15192. maxScaleY: number;
  15193. /**
  15194. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15195. */
  15196. color1: Color4;
  15197. /**
  15198. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15199. */
  15200. color2: Color4;
  15201. /**
  15202. * Color the particle will have at the end of its lifetime.
  15203. */
  15204. colorDead: Color4;
  15205. /**
  15206. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15207. */
  15208. emitRate: number;
  15209. /**
  15210. * You can use gravity if you want to give an orientation to your particles.
  15211. */
  15212. gravity: Vector3;
  15213. /**
  15214. * Minimum power of emitting particles.
  15215. */
  15216. minEmitPower: number;
  15217. /**
  15218. * Maximum power of emitting particles.
  15219. */
  15220. maxEmitPower: number;
  15221. /**
  15222. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15223. */
  15224. minAngularSpeed: number;
  15225. /**
  15226. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15227. */
  15228. maxAngularSpeed: number;
  15229. /**
  15230. * Gets or sets the minimal initial rotation in radians.
  15231. */
  15232. minInitialRotation: number;
  15233. /**
  15234. * Gets or sets the maximal initial rotation in radians.
  15235. */
  15236. maxInitialRotation: number;
  15237. /**
  15238. * The particle emitter type defines the emitter used by the particle system.
  15239. * It can be for example box, sphere, or cone...
  15240. */
  15241. particleEmitterType: Nullable<IParticleEmitterType>;
  15242. /**
  15243. * Defines the delay in milliseconds before starting the system (0 by default)
  15244. */
  15245. startDelay: number;
  15246. /**
  15247. * 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
  15248. */
  15249. preWarmCycles: number;
  15250. /**
  15251. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15252. */
  15253. preWarmStepOffset: number;
  15254. /**
  15255. * 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)
  15256. */
  15257. spriteCellChangeSpeed: number;
  15258. /**
  15259. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15260. */
  15261. startSpriteCellID: number;
  15262. /**
  15263. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15264. */
  15265. endSpriteCellID: number;
  15266. /**
  15267. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15268. */
  15269. spriteCellWidth: number;
  15270. /**
  15271. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15272. */
  15273. spriteCellHeight: number;
  15274. /**
  15275. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15276. */
  15277. spriteRandomStartCell: boolean;
  15278. /**
  15279. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15280. */
  15281. isAnimationSheetEnabled: boolean;
  15282. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15283. translationPivot: Vector2;
  15284. /**
  15285. * Gets or sets a texture used to add random noise to particle positions
  15286. */
  15287. noiseTexture: Nullable<BaseTexture>;
  15288. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15289. noiseStrength: Vector3;
  15290. /**
  15291. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15292. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15293. */
  15294. billboardMode: number;
  15295. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15296. limitVelocityDamping: number;
  15297. /**
  15298. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15299. */
  15300. beginAnimationOnStart: boolean;
  15301. /**
  15302. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15303. */
  15304. beginAnimationFrom: number;
  15305. /**
  15306. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15307. */
  15308. beginAnimationTo: number;
  15309. /**
  15310. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15311. */
  15312. beginAnimationLoop: boolean;
  15313. /**
  15314. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15315. */
  15316. disposeOnStop: boolean;
  15317. /**
  15318. * Gets the maximum number of particles active at the same time.
  15319. * @returns The max number of active particles.
  15320. */
  15321. getCapacity(): number;
  15322. /**
  15323. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15324. * @returns True if it has been started, otherwise false.
  15325. */
  15326. isStarted(): boolean;
  15327. /**
  15328. * Animates the particle system for this frame.
  15329. */
  15330. animate(): void;
  15331. /**
  15332. * Renders the particle system in its current state.
  15333. * @returns the current number of particles
  15334. */
  15335. render(): number;
  15336. /**
  15337. * Dispose the particle system and frees its associated resources.
  15338. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15339. */
  15340. dispose(disposeTexture?: boolean): void;
  15341. /**
  15342. * Clones the particle system.
  15343. * @param name The name of the cloned object
  15344. * @param newEmitter The new emitter to use
  15345. * @returns the cloned particle system
  15346. */
  15347. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  15348. /**
  15349. * Serializes the particle system to a JSON object.
  15350. * @returns the JSON object
  15351. */
  15352. serialize(): any;
  15353. /**
  15354. * Rebuild the particle system
  15355. */
  15356. rebuild(): void;
  15357. /**
  15358. * Starts the particle system and begins to emit
  15359. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  15360. */
  15361. start(delay?: number): void;
  15362. /**
  15363. * Stops the particle system.
  15364. */
  15365. stop(): void;
  15366. /**
  15367. * Remove all active particles
  15368. */
  15369. reset(): void;
  15370. /**
  15371. * Is this system ready to be used/rendered
  15372. * @return true if the system is ready
  15373. */
  15374. isReady(): boolean;
  15375. /**
  15376. * Adds a new color gradient
  15377. * @param gradient defines the gradient to use (between 0 and 1)
  15378. * @param color1 defines the color to affect to the specified gradient
  15379. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15380. * @returns the current particle system
  15381. */
  15382. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15383. /**
  15384. * Remove a specific color gradient
  15385. * @param gradient defines the gradient to remove
  15386. * @returns the current particle system
  15387. */
  15388. removeColorGradient(gradient: number): IParticleSystem;
  15389. /**
  15390. * Adds a new size gradient
  15391. * @param gradient defines the gradient to use (between 0 and 1)
  15392. * @param factor defines the size factor to affect to the specified gradient
  15393. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15394. * @returns the current particle system
  15395. */
  15396. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15397. /**
  15398. * Remove a specific size gradient
  15399. * @param gradient defines the gradient to remove
  15400. * @returns the current particle system
  15401. */
  15402. removeSizeGradient(gradient: number): IParticleSystem;
  15403. /**
  15404. * Gets the current list of color gradients.
  15405. * You must use addColorGradient and removeColorGradient to udpate this list
  15406. * @returns the list of color gradients
  15407. */
  15408. getColorGradients(): Nullable<Array<ColorGradient>>;
  15409. /**
  15410. * Gets the current list of size gradients.
  15411. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15412. * @returns the list of size gradients
  15413. */
  15414. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15415. /**
  15416. * Gets the current list of angular speed gradients.
  15417. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15418. * @returns the list of angular speed gradients
  15419. */
  15420. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15421. /**
  15422. * Adds a new angular speed gradient
  15423. * @param gradient defines the gradient to use (between 0 and 1)
  15424. * @param factor defines the angular speed to affect to the specified gradient
  15425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15426. * @returns the current particle system
  15427. */
  15428. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15429. /**
  15430. * Remove a specific angular speed gradient
  15431. * @param gradient defines the gradient to remove
  15432. * @returns the current particle system
  15433. */
  15434. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15435. /**
  15436. * Gets the current list of velocity gradients.
  15437. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15438. * @returns the list of velocity gradients
  15439. */
  15440. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15441. /**
  15442. * Adds a new velocity gradient
  15443. * @param gradient defines the gradient to use (between 0 and 1)
  15444. * @param factor defines the velocity to affect to the specified gradient
  15445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15446. * @returns the current particle system
  15447. */
  15448. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15449. /**
  15450. * Remove a specific velocity gradient
  15451. * @param gradient defines the gradient to remove
  15452. * @returns the current particle system
  15453. */
  15454. removeVelocityGradient(gradient: number): IParticleSystem;
  15455. /**
  15456. * Gets the current list of limit velocity gradients.
  15457. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15458. * @returns the list of limit velocity gradients
  15459. */
  15460. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15461. /**
  15462. * Adds a new limit velocity gradient
  15463. * @param gradient defines the gradient to use (between 0 and 1)
  15464. * @param factor defines the limit velocity to affect to the specified gradient
  15465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15466. * @returns the current particle system
  15467. */
  15468. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15469. /**
  15470. * Remove a specific limit velocity gradient
  15471. * @param gradient defines the gradient to remove
  15472. * @returns the current particle system
  15473. */
  15474. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15475. /**
  15476. * Adds a new drag gradient
  15477. * @param gradient defines the gradient to use (between 0 and 1)
  15478. * @param factor defines the drag to affect to the specified gradient
  15479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15480. * @returns the current particle system
  15481. */
  15482. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15483. /**
  15484. * Remove a specific drag gradient
  15485. * @param gradient defines the gradient to remove
  15486. * @returns the current particle system
  15487. */
  15488. removeDragGradient(gradient: number): IParticleSystem;
  15489. /**
  15490. * Gets the current list of drag gradients.
  15491. * You must use addDragGradient and removeDragGradient to udpate this list
  15492. * @returns the list of drag gradients
  15493. */
  15494. getDragGradients(): Nullable<Array<FactorGradient>>;
  15495. /**
  15496. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15497. * @param gradient defines the gradient to use (between 0 and 1)
  15498. * @param factor defines the emit rate to affect to the specified gradient
  15499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15500. * @returns the current particle system
  15501. */
  15502. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15503. /**
  15504. * Remove a specific emit rate gradient
  15505. * @param gradient defines the gradient to remove
  15506. * @returns the current particle system
  15507. */
  15508. removeEmitRateGradient(gradient: number): IParticleSystem;
  15509. /**
  15510. * Gets the current list of emit rate gradients.
  15511. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15512. * @returns the list of emit rate gradients
  15513. */
  15514. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15515. /**
  15516. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15517. * @param gradient defines the gradient to use (between 0 and 1)
  15518. * @param factor defines the start size to affect to the specified gradient
  15519. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15520. * @returns the current particle system
  15521. */
  15522. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15523. /**
  15524. * Remove a specific start size gradient
  15525. * @param gradient defines the gradient to remove
  15526. * @returns the current particle system
  15527. */
  15528. removeStartSizeGradient(gradient: number): IParticleSystem;
  15529. /**
  15530. * Gets the current list of start size gradients.
  15531. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15532. * @returns the list of start size gradients
  15533. */
  15534. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15535. /**
  15536. * Adds a new life time gradient
  15537. * @param gradient defines the gradient to use (between 0 and 1)
  15538. * @param factor defines the life time factor to affect to the specified gradient
  15539. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15540. * @returns the current particle system
  15541. */
  15542. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15543. /**
  15544. * Remove a specific life time gradient
  15545. * @param gradient defines the gradient to remove
  15546. * @returns the current particle system
  15547. */
  15548. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15549. /**
  15550. * Gets the current list of life time gradients.
  15551. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15552. * @returns the list of life time gradients
  15553. */
  15554. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15555. /**
  15556. * Gets the current list of color gradients.
  15557. * You must use addColorGradient and removeColorGradient to udpate this list
  15558. * @returns the list of color gradients
  15559. */
  15560. getColorGradients(): Nullable<Array<ColorGradient>>;
  15561. /**
  15562. * Adds a new ramp gradient used to remap particle colors
  15563. * @param gradient defines the gradient to use (between 0 and 1)
  15564. * @param color defines the color to affect to the specified gradient
  15565. * @returns the current particle system
  15566. */
  15567. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  15568. /**
  15569. * Gets the current list of ramp gradients.
  15570. * You must use addRampGradient and removeRampGradient to udpate this list
  15571. * @returns the list of ramp gradients
  15572. */
  15573. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15574. /** Gets or sets a boolean indicating that ramp gradients must be used
  15575. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15576. */
  15577. useRampGradients: boolean;
  15578. /**
  15579. * Adds a new color remap gradient
  15580. * @param gradient defines the gradient to use (between 0 and 1)
  15581. * @param min defines the color remap minimal range
  15582. * @param max defines the color remap maximal range
  15583. * @returns the current particle system
  15584. */
  15585. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15586. /**
  15587. * Gets the current list of color remap gradients.
  15588. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15589. * @returns the list of color remap gradients
  15590. */
  15591. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15592. /**
  15593. * Adds a new alpha remap gradient
  15594. * @param gradient defines the gradient to use (between 0 and 1)
  15595. * @param min defines the alpha remap minimal range
  15596. * @param max defines the alpha remap maximal range
  15597. * @returns the current particle system
  15598. */
  15599. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15600. /**
  15601. * Gets the current list of alpha remap gradients.
  15602. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15603. * @returns the list of alpha remap gradients
  15604. */
  15605. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15606. /**
  15607. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15610. * @returns the emitter
  15611. */
  15612. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15613. /**
  15614. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15615. * @param radius The radius of the hemisphere to emit from
  15616. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15617. * @returns the emitter
  15618. */
  15619. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15620. /**
  15621. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15622. * @param radius The radius of the sphere to emit from
  15623. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15624. * @returns the emitter
  15625. */
  15626. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15627. /**
  15628. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15629. * @param radius The radius of the sphere to emit from
  15630. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15631. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15632. * @returns the emitter
  15633. */
  15634. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15635. /**
  15636. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15637. * @param radius The radius of the emission cylinder
  15638. * @param height The height of the emission cylinder
  15639. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15640. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15641. * @returns the emitter
  15642. */
  15643. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15644. /**
  15645. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15646. * @param radius The radius of the cylinder to emit from
  15647. * @param height The height of the emission cylinder
  15648. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15651. * @returns the emitter
  15652. */
  15653. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15654. /**
  15655. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15656. * @param radius The radius of the cone to emit from
  15657. * @param angle The base angle of the cone
  15658. * @returns the emitter
  15659. */
  15660. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15661. /**
  15662. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15665. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15666. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15667. * @returns the emitter
  15668. */
  15669. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15670. /**
  15671. * Get hosting scene
  15672. * @returns the scene
  15673. */
  15674. getScene(): Scene;
  15675. }
  15676. }
  15677. declare module BABYLON {
  15678. /**
  15679. * Creates an instance based on a source mesh.
  15680. */
  15681. export class InstancedMesh extends AbstractMesh {
  15682. private _sourceMesh;
  15683. private _currentLOD;
  15684. /** @hidden */ indexInSourceMeshInstanceArray: number;
  15685. constructor(name: string, source: Mesh);
  15686. /**
  15687. * Returns the string "InstancedMesh".
  15688. */
  15689. getClassName(): string;
  15690. /**
  15691. * If the source mesh receives shadows
  15692. */
  15693. readonly receiveShadows: boolean;
  15694. /**
  15695. * The material of the source mesh
  15696. */
  15697. readonly material: Nullable<Material>;
  15698. /**
  15699. * Visibility of the source mesh
  15700. */
  15701. readonly visibility: number;
  15702. /**
  15703. * Skeleton of the source mesh
  15704. */
  15705. readonly skeleton: Nullable<Skeleton>;
  15706. /**
  15707. * Rendering ground id of the source mesh
  15708. */
  15709. renderingGroupId: number;
  15710. /**
  15711. * Returns the total number of vertices (integer).
  15712. */
  15713. getTotalVertices(): number;
  15714. /**
  15715. * Returns a positive integer : the total number of indices in this mesh geometry.
  15716. * @returns the numner of indices or zero if the mesh has no geometry.
  15717. */
  15718. getTotalIndices(): number;
  15719. /**
  15720. * The source mesh of the instance
  15721. */
  15722. readonly sourceMesh: Mesh;
  15723. /**
  15724. * Is this node ready to be used/rendered
  15725. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15726. * @return {boolean} is it ready
  15727. */
  15728. isReady(completeCheck?: boolean): boolean;
  15729. /**
  15730. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15731. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15732. * @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.
  15733. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15734. */
  15735. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15736. /**
  15737. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15738. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15739. * The `data` are either a numeric array either a Float32Array.
  15740. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15741. * 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).
  15742. * Note that a new underlying VertexBuffer object is created each call.
  15743. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15744. *
  15745. * Possible `kind` values :
  15746. * - VertexBuffer.PositionKind
  15747. * - VertexBuffer.UVKind
  15748. * - VertexBuffer.UV2Kind
  15749. * - VertexBuffer.UV3Kind
  15750. * - VertexBuffer.UV4Kind
  15751. * - VertexBuffer.UV5Kind
  15752. * - VertexBuffer.UV6Kind
  15753. * - VertexBuffer.ColorKind
  15754. * - VertexBuffer.MatricesIndicesKind
  15755. * - VertexBuffer.MatricesIndicesExtraKind
  15756. * - VertexBuffer.MatricesWeightsKind
  15757. * - VertexBuffer.MatricesWeightsExtraKind
  15758. *
  15759. * Returns the Mesh.
  15760. */
  15761. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  15762. /**
  15763. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15764. * If the mesh has no geometry, it is simply returned as it is.
  15765. * The `data` are either a numeric array either a Float32Array.
  15766. * No new underlying VertexBuffer object is created.
  15767. * 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.
  15768. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15769. *
  15770. * Possible `kind` values :
  15771. * - VertexBuffer.PositionKind
  15772. * - VertexBuffer.UVKind
  15773. * - VertexBuffer.UV2Kind
  15774. * - VertexBuffer.UV3Kind
  15775. * - VertexBuffer.UV4Kind
  15776. * - VertexBuffer.UV5Kind
  15777. * - VertexBuffer.UV6Kind
  15778. * - VertexBuffer.ColorKind
  15779. * - VertexBuffer.MatricesIndicesKind
  15780. * - VertexBuffer.MatricesIndicesExtraKind
  15781. * - VertexBuffer.MatricesWeightsKind
  15782. * - VertexBuffer.MatricesWeightsExtraKind
  15783. *
  15784. * Returns the Mesh.
  15785. */
  15786. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15787. /**
  15788. * Sets the mesh indices.
  15789. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15790. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15791. * This method creates a new index buffer each call.
  15792. * Returns the Mesh.
  15793. */
  15794. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15795. /**
  15796. * Boolean : True if the mesh owns the requested kind of data.
  15797. */
  15798. isVerticesDataPresent(kind: string): boolean;
  15799. /**
  15800. * Returns an array of indices (IndicesArray).
  15801. */
  15802. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  15803. /**
  15804. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15805. * This means the mesh underlying bounding box and sphere are recomputed.
  15806. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15807. * @returns the current mesh
  15808. */
  15809. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15810. /** @hidden */ preActivate(): InstancedMesh;
  15811. /** @hidden */ activate(renderId: number): InstancedMesh;
  15812. /**
  15813. * Returns the current associated LOD AbstractMesh.
  15814. */
  15815. getLOD(camera: Camera): AbstractMesh;
  15816. /** @hidden */ syncSubMeshes(): InstancedMesh;
  15817. /** @hidden */ generatePointsArray(): boolean;
  15818. /**
  15819. * Creates a new InstancedMesh from the current mesh.
  15820. * - name (string) : the cloned mesh name
  15821. * - newParent (optional Node) : the optional Node to parent the clone to.
  15822. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15823. *
  15824. * Returns the clone.
  15825. */
  15826. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  15827. /**
  15828. * Disposes the InstancedMesh.
  15829. * Returns nothing.
  15830. */
  15831. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15832. }
  15833. }
  15834. declare module BABYLON {
  15835. /**
  15836. * Defines the options associated with the creation of a shader material.
  15837. */
  15838. export interface IShaderMaterialOptions {
  15839. /**
  15840. * Does the material work in alpha blend mode
  15841. */
  15842. needAlphaBlending: boolean;
  15843. /**
  15844. * Does the material work in alpha test mode
  15845. */
  15846. needAlphaTesting: boolean;
  15847. /**
  15848. * The list of attribute names used in the shader
  15849. */
  15850. attributes: string[];
  15851. /**
  15852. * The list of unifrom names used in the shader
  15853. */
  15854. uniforms: string[];
  15855. /**
  15856. * The list of UBO names used in the shader
  15857. */
  15858. uniformBuffers: string[];
  15859. /**
  15860. * The list of sampler names used in the shader
  15861. */
  15862. samplers: string[];
  15863. /**
  15864. * The list of defines used in the shader
  15865. */
  15866. defines: string[];
  15867. }
  15868. /**
  15869. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15870. *
  15871. * This returned material effects how the mesh will look based on the code in the shaders.
  15872. *
  15873. * @see http://doc.babylonjs.com/how_to/shader_material
  15874. */
  15875. export class ShaderMaterial extends Material {
  15876. private _shaderPath;
  15877. private _options;
  15878. private _textures;
  15879. private _textureArrays;
  15880. private _floats;
  15881. private _ints;
  15882. private _floatsArrays;
  15883. private _colors3;
  15884. private _colors3Arrays;
  15885. private _colors4;
  15886. private _vectors2;
  15887. private _vectors3;
  15888. private _vectors4;
  15889. private _matrices;
  15890. private _matrices3x3;
  15891. private _matrices2x2;
  15892. private _vectors2Arrays;
  15893. private _vectors3Arrays;
  15894. private _cachedWorldViewMatrix;
  15895. private _renderId;
  15896. /**
  15897. * Instantiate a new shader material.
  15898. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15899. * This returned material effects how the mesh will look based on the code in the shaders.
  15900. * @see http://doc.babylonjs.com/how_to/shader_material
  15901. * @param name Define the name of the material in the scene
  15902. * @param scene Define the scene the material belongs to
  15903. * @param shaderPath Defines the route to the shader code in one of three ways:
  15904. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15905. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  15906. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15907. * @param options Define the options used to create the shader
  15908. */
  15909. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15910. /**
  15911. * Gets the current class name of the material e.g. "ShaderMaterial"
  15912. * Mainly use in serialization.
  15913. * @returns the class name
  15914. */
  15915. getClassName(): string;
  15916. /**
  15917. * Specifies if the material will require alpha blending
  15918. * @returns a boolean specifying if alpha blending is needed
  15919. */
  15920. needAlphaBlending(): boolean;
  15921. /**
  15922. * Specifies if this material should be rendered in alpha test mode
  15923. * @returns a boolean specifying if an alpha test is needed.
  15924. */
  15925. needAlphaTesting(): boolean;
  15926. private _checkUniform;
  15927. /**
  15928. * Set a texture in the shader.
  15929. * @param name Define the name of the uniform samplers as defined in the shader
  15930. * @param texture Define the texture to bind to this sampler
  15931. * @return the material itself allowing "fluent" like uniform updates
  15932. */
  15933. setTexture(name: string, texture: Texture): ShaderMaterial;
  15934. /**
  15935. * Set a texture array in the shader.
  15936. * @param name Define the name of the uniform sampler array as defined in the shader
  15937. * @param textures Define the list of textures to bind to this sampler
  15938. * @return the material itself allowing "fluent" like uniform updates
  15939. */
  15940. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15941. /**
  15942. * Set a float in the shader.
  15943. * @param name Define the name of the uniform as defined in the shader
  15944. * @param value Define the value to give to the uniform
  15945. * @return the material itself allowing "fluent" like uniform updates
  15946. */
  15947. setFloat(name: string, value: number): ShaderMaterial;
  15948. /**
  15949. * Set a int in the shader.
  15950. * @param name Define the name of the uniform as defined in the shader
  15951. * @param value Define the value to give to the uniform
  15952. * @return the material itself allowing "fluent" like uniform updates
  15953. */
  15954. setInt(name: string, value: number): ShaderMaterial;
  15955. /**
  15956. * Set an array of floats in the shader.
  15957. * @param name Define the name of the uniform as defined in the shader
  15958. * @param value Define the value to give to the uniform
  15959. * @return the material itself allowing "fluent" like uniform updates
  15960. */
  15961. setFloats(name: string, value: number[]): ShaderMaterial;
  15962. /**
  15963. * Set a vec3 in the shader from a Color3.
  15964. * @param name Define the name of the uniform as defined in the shader
  15965. * @param value Define the value to give to the uniform
  15966. * @return the material itself allowing "fluent" like uniform updates
  15967. */
  15968. setColor3(name: string, value: Color3): ShaderMaterial;
  15969. /**
  15970. * Set a vec3 array in the shader from a Color3 array.
  15971. * @param name Define the name of the uniform as defined in the shader
  15972. * @param value Define the value to give to the uniform
  15973. * @return the material itself allowing "fluent" like uniform updates
  15974. */
  15975. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15976. /**
  15977. * Set a vec4 in the shader from a Color4.
  15978. * @param name Define the name of the uniform as defined in the shader
  15979. * @param value Define the value to give to the uniform
  15980. * @return the material itself allowing "fluent" like uniform updates
  15981. */
  15982. setColor4(name: string, value: Color4): ShaderMaterial;
  15983. /**
  15984. * Set a vec2 in the shader from a Vector2.
  15985. * @param name Define the name of the uniform as defined in the shader
  15986. * @param value Define the value to give to the uniform
  15987. * @return the material itself allowing "fluent" like uniform updates
  15988. */
  15989. setVector2(name: string, value: Vector2): ShaderMaterial;
  15990. /**
  15991. * Set a vec3 in the shader from a Vector3.
  15992. * @param name Define the name of the uniform as defined in the shader
  15993. * @param value Define the value to give to the uniform
  15994. * @return the material itself allowing "fluent" like uniform updates
  15995. */
  15996. setVector3(name: string, value: Vector3): ShaderMaterial;
  15997. /**
  15998. * Set a vec4 in the shader from a Vector4.
  15999. * @param name Define the name of the uniform as defined in the shader
  16000. * @param value Define the value to give to the uniform
  16001. * @return the material itself allowing "fluent" like uniform updates
  16002. */
  16003. setVector4(name: string, value: Vector4): ShaderMaterial;
  16004. /**
  16005. * Set a mat4 in the shader from a Matrix.
  16006. * @param name Define the name of the uniform as defined in the shader
  16007. * @param value Define the value to give to the uniform
  16008. * @return the material itself allowing "fluent" like uniform updates
  16009. */
  16010. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16011. /**
  16012. * Set a mat3 in the shader from a Float32Array.
  16013. * @param name Define the name of the uniform as defined in the shader
  16014. * @param value Define the value to give to the uniform
  16015. * @return the material itself allowing "fluent" like uniform updates
  16016. */
  16017. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16018. /**
  16019. * Set a mat2 in the shader from a Float32Array.
  16020. * @param name Define the name of the uniform as defined in the shader
  16021. * @param value Define the value to give to the uniform
  16022. * @return the material itself allowing "fluent" like uniform updates
  16023. */
  16024. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16025. /**
  16026. * Set a vec2 array in the shader from a number array.
  16027. * @param name Define the name of the uniform as defined in the shader
  16028. * @param value Define the value to give to the uniform
  16029. * @return the material itself allowing "fluent" like uniform updates
  16030. */
  16031. setArray2(name: string, value: number[]): ShaderMaterial;
  16032. /**
  16033. * Set a vec3 array in the shader from a number array.
  16034. * @param name Define the name of the uniform as defined in the shader
  16035. * @param value Define the value to give to the uniform
  16036. * @return the material itself allowing "fluent" like uniform updates
  16037. */
  16038. setArray3(name: string, value: number[]): ShaderMaterial;
  16039. private _checkCache;
  16040. /**
  16041. * Checks if the material is ready to render the requested mesh
  16042. * @param mesh Define the mesh to render
  16043. * @param useInstances Define whether or not the material is used with instances
  16044. * @returns true if ready, otherwise false
  16045. */
  16046. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16047. /**
  16048. * Binds the world matrix to the material
  16049. * @param world defines the world transformation matrix
  16050. */
  16051. bindOnlyWorldMatrix(world: Matrix): void;
  16052. /**
  16053. * Binds the material to the mesh
  16054. * @param world defines the world transformation matrix
  16055. * @param mesh defines the mesh to bind the material to
  16056. */
  16057. bind(world: Matrix, mesh?: Mesh): void;
  16058. /**
  16059. * Gets the active textures from the material
  16060. * @returns an array of textures
  16061. */
  16062. getActiveTextures(): BaseTexture[];
  16063. /**
  16064. * Specifies if the material uses a texture
  16065. * @param texture defines the texture to check against the material
  16066. * @returns a boolean specifying if the material uses the texture
  16067. */
  16068. hasTexture(texture: BaseTexture): boolean;
  16069. /**
  16070. * Makes a duplicate of the material, and gives it a new name
  16071. * @param name defines the new name for the duplicated material
  16072. * @returns the cloned material
  16073. */
  16074. clone(name: string): ShaderMaterial;
  16075. /**
  16076. * Disposes the material
  16077. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16078. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16079. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16080. */
  16081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16082. /**
  16083. * Serializes this material in a JSON representation
  16084. * @returns the serialized material object
  16085. */
  16086. serialize(): any;
  16087. /**
  16088. * Creates a shader material from parsed shader material data
  16089. * @param source defines the JSON represnetation of the material
  16090. * @param scene defines the hosting scene
  16091. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16092. * @returns a new material
  16093. */
  16094. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16095. }
  16096. }
  16097. declare module BABYLON {
  16098. /** @hidden */
  16099. export var colorPixelShader: {
  16100. name: string;
  16101. shader: string;
  16102. };
  16103. }
  16104. declare module BABYLON {
  16105. /** @hidden */
  16106. export var colorVertexShader: {
  16107. name: string;
  16108. shader: string;
  16109. };
  16110. }
  16111. declare module BABYLON {
  16112. /**
  16113. * Line mesh
  16114. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16115. */
  16116. export class LinesMesh extends Mesh {
  16117. /**
  16118. * If vertex color should be applied to the mesh
  16119. */
  16120. useVertexColor?: boolean | undefined;
  16121. /**
  16122. * If vertex alpha should be applied to the mesh
  16123. */
  16124. useVertexAlpha?: boolean | undefined;
  16125. /**
  16126. * Color of the line (Default: White)
  16127. */
  16128. color: Color3;
  16129. /**
  16130. * Alpha of the line (Default: 1)
  16131. */
  16132. alpha: number;
  16133. /**
  16134. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16135. * This margin is expressed in world space coordinates, so its value may vary.
  16136. * Default value is 0.1
  16137. */
  16138. intersectionThreshold: number;
  16139. private _colorShader;
  16140. /**
  16141. * Creates a new LinesMesh
  16142. * @param name defines the name
  16143. * @param scene defines the hosting scene
  16144. * @param parent defines the parent mesh if any
  16145. * @param source defines the optional source LinesMesh used to clone data from
  16146. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16147. * When false, achieved by calling a clone(), also passing False.
  16148. * This will make creation of children, recursive.
  16149. * @param useVertexColor defines if this LinesMesh supports vertex color
  16150. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16151. */
  16152. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16153. /**
  16154. * If vertex color should be applied to the mesh
  16155. */
  16156. useVertexColor?: boolean | undefined,
  16157. /**
  16158. * If vertex alpha should be applied to the mesh
  16159. */
  16160. useVertexAlpha?: boolean | undefined);
  16161. /**
  16162. * Returns the string "LineMesh"
  16163. */
  16164. getClassName(): string;
  16165. /**
  16166. * @hidden
  16167. */
  16168. /**
  16169. * @hidden
  16170. */
  16171. material: Material;
  16172. /**
  16173. * @hidden
  16174. */
  16175. readonly checkCollisions: boolean;
  16176. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16177. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16178. /**
  16179. * Disposes of the line mesh
  16180. * @param doNotRecurse If children should be disposed
  16181. */
  16182. dispose(doNotRecurse?: boolean): void;
  16183. /**
  16184. * Returns a new LineMesh object cloned from the current one.
  16185. */
  16186. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16187. /**
  16188. * Creates a new InstancedLinesMesh object from the mesh model.
  16189. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16190. * @param name defines the name of the new instance
  16191. * @returns a new InstancedLinesMesh
  16192. */
  16193. createInstance(name: string): InstancedLinesMesh;
  16194. }
  16195. /**
  16196. * Creates an instance based on a source LinesMesh
  16197. */
  16198. export class InstancedLinesMesh extends InstancedMesh {
  16199. /**
  16200. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16201. * This margin is expressed in world space coordinates, so its value may vary.
  16202. * Initilized with the intersectionThreshold value of the source LinesMesh
  16203. */
  16204. intersectionThreshold: number;
  16205. constructor(name: string, source: LinesMesh);
  16206. /**
  16207. * Returns the string "InstancedLinesMesh".
  16208. */
  16209. getClassName(): string;
  16210. }
  16211. }
  16212. declare module BABYLON {
  16213. /** @hidden */
  16214. export var linePixelShader: {
  16215. name: string;
  16216. shader: string;
  16217. };
  16218. }
  16219. declare module BABYLON {
  16220. /** @hidden */
  16221. export var lineVertexShader: {
  16222. name: string;
  16223. shader: string;
  16224. };
  16225. }
  16226. declare module BABYLON {
  16227. interface AbstractMesh {
  16228. /**
  16229. * Disables the mesh edge rendering mode
  16230. * @returns the currentAbstractMesh
  16231. */
  16232. disableEdgesRendering(): AbstractMesh;
  16233. /**
  16234. * Enables the edge rendering mode on the mesh.
  16235. * This mode makes the mesh edges visible
  16236. * @param epsilon defines the maximal distance between two angles to detect a face
  16237. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16238. * @returns the currentAbstractMesh
  16239. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16240. */
  16241. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16242. /**
  16243. * Gets the edgesRenderer associated with the mesh
  16244. */
  16245. edgesRenderer: Nullable<EdgesRenderer>;
  16246. }
  16247. interface LinesMesh {
  16248. /**
  16249. * Enables the edge rendering mode on the mesh.
  16250. * This mode makes the mesh edges visible
  16251. * @param epsilon defines the maximal distance between two angles to detect a face
  16252. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16253. * @returns the currentAbstractMesh
  16254. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16255. */
  16256. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16257. }
  16258. interface InstancedLinesMesh {
  16259. /**
  16260. * Enables the edge rendering mode on the mesh.
  16261. * This mode makes the mesh edges visible
  16262. * @param epsilon defines the maximal distance between two angles to detect a face
  16263. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16264. * @returns the current InstancedLinesMesh
  16265. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16266. */
  16267. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16268. }
  16269. /**
  16270. * Defines the minimum contract an Edges renderer should follow.
  16271. */
  16272. export interface IEdgesRenderer extends IDisposable {
  16273. /**
  16274. * Gets or sets a boolean indicating if the edgesRenderer is active
  16275. */
  16276. isEnabled: boolean;
  16277. /**
  16278. * Renders the edges of the attached mesh,
  16279. */
  16280. render(): void;
  16281. /**
  16282. * Checks wether or not the edges renderer is ready to render.
  16283. * @return true if ready, otherwise false.
  16284. */
  16285. isReady(): boolean;
  16286. }
  16287. /**
  16288. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16289. */
  16290. export class EdgesRenderer implements IEdgesRenderer {
  16291. /**
  16292. * Define the size of the edges with an orthographic camera
  16293. */
  16294. edgesWidthScalerForOrthographic: number;
  16295. /**
  16296. * Define the size of the edges with a perspective camera
  16297. */
  16298. edgesWidthScalerForPerspective: number;
  16299. protected _source: AbstractMesh;
  16300. protected _linesPositions: number[];
  16301. protected _linesNormals: number[];
  16302. protected _linesIndices: number[];
  16303. protected _epsilon: number;
  16304. protected _indicesCount: number;
  16305. protected _lineShader: ShaderMaterial;
  16306. protected _ib: WebGLBuffer;
  16307. protected _buffers: {
  16308. [key: string]: Nullable<VertexBuffer>;
  16309. };
  16310. protected _checkVerticesInsteadOfIndices: boolean;
  16311. private _meshRebuildObserver;
  16312. private _meshDisposeObserver;
  16313. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16314. isEnabled: boolean;
  16315. /**
  16316. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16317. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16318. * @param source Mesh used to create edges
  16319. * @param epsilon sum of angles in adjacency to check for edge
  16320. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16321. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16322. */
  16323. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16324. protected _prepareRessources(): void;
  16325. /** @hidden */ rebuild(): void;
  16326. /**
  16327. * Releases the required resources for the edges renderer
  16328. */
  16329. dispose(): void;
  16330. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16331. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16332. /**
  16333. * Checks if the pair of p0 and p1 is en edge
  16334. * @param faceIndex
  16335. * @param edge
  16336. * @param faceNormals
  16337. * @param p0
  16338. * @param p1
  16339. * @private
  16340. */
  16341. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16342. /**
  16343. * push line into the position, normal and index buffer
  16344. * @protected
  16345. */
  16346. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16347. /**
  16348. * Generates lines edges from adjacencjes
  16349. * @private
  16350. */ generateEdgesLines(): void;
  16351. /**
  16352. * Checks wether or not the edges renderer is ready to render.
  16353. * @return true if ready, otherwise false.
  16354. */
  16355. isReady(): boolean;
  16356. /**
  16357. * Renders the edges of the attached mesh,
  16358. */
  16359. render(): void;
  16360. }
  16361. /**
  16362. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16363. */
  16364. export class LineEdgesRenderer extends EdgesRenderer {
  16365. /**
  16366. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16367. * @param source LineMesh used to generate edges
  16368. * @param epsilon not important (specified angle for edge detection)
  16369. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16370. */
  16371. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16372. /**
  16373. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16374. */ generateEdgesLines(): void;
  16375. }
  16376. }
  16377. declare module BABYLON {
  16378. /**
  16379. * This represents the object necessary to create a rendering group.
  16380. * This is exclusively used and created by the rendering manager.
  16381. * To modify the behavior, you use the available helpers in your scene or meshes.
  16382. * @hidden
  16383. */
  16384. export class RenderingGroup {
  16385. index: number;
  16386. private _scene;
  16387. private _opaqueSubMeshes;
  16388. private _transparentSubMeshes;
  16389. private _alphaTestSubMeshes;
  16390. private _depthOnlySubMeshes;
  16391. private _particleSystems;
  16392. private _spriteManagers;
  16393. private _opaqueSortCompareFn;
  16394. private _alphaTestSortCompareFn;
  16395. private _transparentSortCompareFn;
  16396. private _renderOpaque;
  16397. private _renderAlphaTest;
  16398. private _renderTransparent;
  16399. private _edgesRenderers;
  16400. onBeforeTransparentRendering: () => void;
  16401. /**
  16402. * Set the opaque sort comparison function.
  16403. * If null the sub meshes will be render in the order they were created
  16404. */
  16405. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16406. /**
  16407. * Set the alpha test sort comparison function.
  16408. * If null the sub meshes will be render in the order they were created
  16409. */
  16410. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16411. /**
  16412. * Set the transparent sort comparison function.
  16413. * If null the sub meshes will be render in the order they were created
  16414. */
  16415. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16416. /**
  16417. * Creates a new rendering group.
  16418. * @param index The rendering group index
  16419. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16420. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16421. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16422. */
  16423. 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>);
  16424. /**
  16425. * Render all the sub meshes contained in the group.
  16426. * @param customRenderFunction Used to override the default render behaviour of the group.
  16427. * @returns true if rendered some submeshes.
  16428. */
  16429. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16430. /**
  16431. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16432. * @param subMeshes The submeshes to render
  16433. */
  16434. private renderOpaqueSorted;
  16435. /**
  16436. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16437. * @param subMeshes The submeshes to render
  16438. */
  16439. private renderAlphaTestSorted;
  16440. /**
  16441. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16442. * @param subMeshes The submeshes to render
  16443. */
  16444. private renderTransparentSorted;
  16445. /**
  16446. * Renders the submeshes in a specified order.
  16447. * @param subMeshes The submeshes to sort before render
  16448. * @param sortCompareFn The comparison function use to sort
  16449. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16450. * @param transparent Specifies to activate blending if true
  16451. */
  16452. private static renderSorted;
  16453. /**
  16454. * Renders the submeshes in the order they were dispatched (no sort applied).
  16455. * @param subMeshes The submeshes to render
  16456. */
  16457. private static renderUnsorted;
  16458. /**
  16459. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16460. * are rendered back to front if in the same alpha index.
  16461. *
  16462. * @param a The first submesh
  16463. * @param b The second submesh
  16464. * @returns The result of the comparison
  16465. */
  16466. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16467. /**
  16468. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16469. * are rendered back to front.
  16470. *
  16471. * @param a The first submesh
  16472. * @param b The second submesh
  16473. * @returns The result of the comparison
  16474. */
  16475. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16476. /**
  16477. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16478. * are rendered front to back (prevent overdraw).
  16479. *
  16480. * @param a The first submesh
  16481. * @param b The second submesh
  16482. * @returns The result of the comparison
  16483. */
  16484. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16485. /**
  16486. * Resets the different lists of submeshes to prepare a new frame.
  16487. */
  16488. prepare(): void;
  16489. dispose(): void;
  16490. /**
  16491. * Inserts the submesh in its correct queue depending on its material.
  16492. * @param subMesh The submesh to dispatch
  16493. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16494. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16495. */
  16496. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16497. dispatchSprites(spriteManager: ISpriteManager): void;
  16498. dispatchParticles(particleSystem: IParticleSystem): void;
  16499. private _renderParticles;
  16500. private _renderSprites;
  16501. }
  16502. }
  16503. declare module BABYLON {
  16504. /**
  16505. * Interface describing the different options available in the rendering manager
  16506. * regarding Auto Clear between groups.
  16507. */
  16508. export interface IRenderingManagerAutoClearSetup {
  16509. /**
  16510. * Defines whether or not autoclear is enable.
  16511. */
  16512. autoClear: boolean;
  16513. /**
  16514. * Defines whether or not to autoclear the depth buffer.
  16515. */
  16516. depth: boolean;
  16517. /**
  16518. * Defines whether or not to autoclear the stencil buffer.
  16519. */
  16520. stencil: boolean;
  16521. }
  16522. /**
  16523. * This class is used by the onRenderingGroupObservable
  16524. */
  16525. export class RenderingGroupInfo {
  16526. /**
  16527. * The Scene that being rendered
  16528. */
  16529. scene: Scene;
  16530. /**
  16531. * The camera currently used for the rendering pass
  16532. */
  16533. camera: Nullable<Camera>;
  16534. /**
  16535. * The ID of the renderingGroup being processed
  16536. */
  16537. renderingGroupId: number;
  16538. }
  16539. /**
  16540. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16541. * It is enable to manage the different groups as well as the different necessary sort functions.
  16542. * This should not be used directly aside of the few static configurations
  16543. */
  16544. export class RenderingManager {
  16545. /**
  16546. * The max id used for rendering groups (not included)
  16547. */
  16548. static MAX_RENDERINGGROUPS: number;
  16549. /**
  16550. * The min id used for rendering groups (included)
  16551. */
  16552. static MIN_RENDERINGGROUPS: number;
  16553. /**
  16554. * Used to globally prevent autoclearing scenes.
  16555. */
  16556. static AUTOCLEAR: boolean;
  16557. /**
  16558. * @hidden
  16559. */ useSceneAutoClearSetup: boolean;
  16560. private _scene;
  16561. private _renderingGroups;
  16562. private _depthStencilBufferAlreadyCleaned;
  16563. private _autoClearDepthStencil;
  16564. private _customOpaqueSortCompareFn;
  16565. private _customAlphaTestSortCompareFn;
  16566. private _customTransparentSortCompareFn;
  16567. private _renderingGroupInfo;
  16568. /**
  16569. * Instantiates a new rendering group for a particular scene
  16570. * @param scene Defines the scene the groups belongs to
  16571. */
  16572. constructor(scene: Scene);
  16573. private _clearDepthStencilBuffer;
  16574. /**
  16575. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16576. * @hidden
  16577. */
  16578. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16579. /**
  16580. * Resets the different information of the group to prepare a new frame
  16581. * @hidden
  16582. */
  16583. reset(): void;
  16584. /**
  16585. * Dispose and release the group and its associated resources.
  16586. * @hidden
  16587. */
  16588. dispose(): void;
  16589. /**
  16590. * Clear the info related to rendering groups preventing retention points during dispose.
  16591. */
  16592. freeRenderingGroups(): void;
  16593. private _prepareRenderingGroup;
  16594. /**
  16595. * Add a sprite manager to the rendering manager in order to render it this frame.
  16596. * @param spriteManager Define the sprite manager to render
  16597. */
  16598. dispatchSprites(spriteManager: ISpriteManager): void;
  16599. /**
  16600. * Add a particle system to the rendering manager in order to render it this frame.
  16601. * @param particleSystem Define the particle system to render
  16602. */
  16603. dispatchParticles(particleSystem: IParticleSystem): void;
  16604. /**
  16605. * Add a submesh to the manager in order to render it this frame
  16606. * @param subMesh The submesh to dispatch
  16607. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16608. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16609. */
  16610. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16611. /**
  16612. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16613. * This allowed control for front to back rendering or reversly depending of the special needs.
  16614. *
  16615. * @param renderingGroupId The rendering group id corresponding to its index
  16616. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16617. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16618. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16619. */
  16620. 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;
  16621. /**
  16622. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16623. *
  16624. * @param renderingGroupId The rendering group id corresponding to its index
  16625. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16626. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16627. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16628. */
  16629. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16630. /**
  16631. * Gets the current auto clear configuration for one rendering group of the rendering
  16632. * manager.
  16633. * @param index the rendering group index to get the information for
  16634. * @returns The auto clear setup for the requested rendering group
  16635. */
  16636. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16637. }
  16638. }
  16639. declare module BABYLON {
  16640. /**
  16641. * This Helps creating a texture that will be created from a camera in your scene.
  16642. * It is basically a dynamic texture that could be used to create special effects for instance.
  16643. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  16644. */
  16645. export class RenderTargetTexture extends Texture {
  16646. isCube: boolean;
  16647. /**
  16648. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  16649. */
  16650. static readonly REFRESHRATE_RENDER_ONCE: number;
  16651. /**
  16652. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  16653. */
  16654. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  16655. /**
  16656. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  16657. * the central point of your effect and can save a lot of performances.
  16658. */
  16659. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  16660. /**
  16661. * Use this predicate to dynamically define the list of mesh you want to render.
  16662. * If set, the renderList property will be overwritten.
  16663. */
  16664. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  16665. private _renderList;
  16666. /**
  16667. * Use this list to define the list of mesh you want to render.
  16668. */
  16669. renderList: Nullable<Array<AbstractMesh>>;
  16670. private _hookArray;
  16671. /**
  16672. * Define if particles should be rendered in your texture.
  16673. */
  16674. renderParticles: boolean;
  16675. /**
  16676. * Define if sprites should be rendered in your texture.
  16677. */
  16678. renderSprites: boolean;
  16679. /**
  16680. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  16681. */
  16682. coordinatesMode: number;
  16683. /**
  16684. * Define the camera used to render the texture.
  16685. */
  16686. activeCamera: Nullable<Camera>;
  16687. /**
  16688. * Override the render function of the texture with your own one.
  16689. */
  16690. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  16691. /**
  16692. * Define if camera post processes should be use while rendering the texture.
  16693. */
  16694. useCameraPostProcesses: boolean;
  16695. /**
  16696. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  16697. */
  16698. ignoreCameraViewport: boolean;
  16699. private _postProcessManager;
  16700. private _postProcesses;
  16701. private _resizeObserver;
  16702. /**
  16703. * An event triggered when the texture is unbind.
  16704. */
  16705. onBeforeBindObservable: Observable<RenderTargetTexture>;
  16706. /**
  16707. * An event triggered when the texture is unbind.
  16708. */
  16709. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  16710. private _onAfterUnbindObserver;
  16711. /**
  16712. * Set a after unbind callback in the texture.
  16713. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  16714. */
  16715. onAfterUnbind: () => void;
  16716. /**
  16717. * An event triggered before rendering the texture
  16718. */
  16719. onBeforeRenderObservable: Observable<number>;
  16720. private _onBeforeRenderObserver;
  16721. /**
  16722. * Set a before render callback in the texture.
  16723. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  16724. */
  16725. onBeforeRender: (faceIndex: number) => void;
  16726. /**
  16727. * An event triggered after rendering the texture
  16728. */
  16729. onAfterRenderObservable: Observable<number>;
  16730. private _onAfterRenderObserver;
  16731. /**
  16732. * Set a after render callback in the texture.
  16733. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  16734. */
  16735. onAfterRender: (faceIndex: number) => void;
  16736. /**
  16737. * An event triggered after the texture clear
  16738. */
  16739. onClearObservable: Observable<Engine>;
  16740. private _onClearObserver;
  16741. /**
  16742. * Set a clear callback in the texture.
  16743. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  16744. */
  16745. onClear: (Engine: Engine) => void;
  16746. /**
  16747. * Define the clear color of the Render Target if it should be different from the scene.
  16748. */
  16749. clearColor: Color4;
  16750. protected _size: number | {
  16751. width: number;
  16752. height: number;
  16753. };
  16754. protected _initialSizeParameter: number | {
  16755. width: number;
  16756. height: number;
  16757. } | {
  16758. ratio: number;
  16759. };
  16760. protected _sizeRatio: Nullable<number>;
  16761. /** @hidden */ generateMipMaps: boolean;
  16762. protected _renderingManager: RenderingManager;
  16763. /** @hidden */ waitingRenderList: string[];
  16764. protected _doNotChangeAspectRatio: boolean;
  16765. protected _currentRefreshId: number;
  16766. protected _refreshRate: number;
  16767. protected _textureMatrix: Matrix;
  16768. protected _samples: number;
  16769. protected _renderTargetOptions: RenderTargetCreationOptions;
  16770. /**
  16771. * Gets render target creation options that were used.
  16772. */
  16773. readonly renderTargetOptions: RenderTargetCreationOptions;
  16774. protected _engine: Engine;
  16775. protected _onRatioRescale(): void;
  16776. /**
  16777. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  16778. * It must define where the camera used to render the texture is set
  16779. */
  16780. boundingBoxPosition: Vector3;
  16781. private _boundingBoxSize;
  16782. /**
  16783. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  16784. * When defined, the cubemap will switch to local mode
  16785. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  16786. * @example https://www.babylonjs-playground.com/#RNASML
  16787. */
  16788. boundingBoxSize: Vector3;
  16789. /**
  16790. * In case the RTT has been created with a depth texture, get the associated
  16791. * depth texture.
  16792. * Otherwise, return null.
  16793. */
  16794. depthStencilTexture: Nullable<InternalTexture>;
  16795. /**
  16796. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  16797. * or used a shadow, depth texture...
  16798. * @param name The friendly name of the texture
  16799. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  16800. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  16801. * @param generateMipMaps True if mip maps need to be generated after render.
  16802. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  16803. * @param type The type of the buffer in the RTT (int, half float, float...)
  16804. * @param isCube True if a cube texture needs to be created
  16805. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  16806. * @param generateDepthBuffer True to generate a depth buffer
  16807. * @param generateStencilBuffer True to generate a stencil buffer
  16808. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  16809. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  16810. * @param delayAllocation if the texture allocation should be delayed (default: false)
  16811. */
  16812. constructor(name: string, size: number | {
  16813. width: number;
  16814. height: number;
  16815. } | {
  16816. ratio: number;
  16817. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  16818. /**
  16819. * Creates a depth stencil texture.
  16820. * This is only available in WebGL 2 or with the depth texture extension available.
  16821. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  16822. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  16823. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  16824. */
  16825. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  16826. private _processSizeParameter;
  16827. /**
  16828. * Define the number of samples to use in case of MSAA.
  16829. * It defaults to one meaning no MSAA has been enabled.
  16830. */
  16831. samples: number;
  16832. /**
  16833. * Resets the refresh counter of the texture and start bak from scratch.
  16834. * Could be useful to regenerate the texture if it is setup to render only once.
  16835. */
  16836. resetRefreshCounter(): void;
  16837. /**
  16838. * Define the refresh rate of the texture or the rendering frequency.
  16839. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16840. */
  16841. refreshRate: number;
  16842. /**
  16843. * Adds a post process to the render target rendering passes.
  16844. * @param postProcess define the post process to add
  16845. */
  16846. addPostProcess(postProcess: PostProcess): void;
  16847. /**
  16848. * Clear all the post processes attached to the render target
  16849. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  16850. */
  16851. clearPostProcesses(dispose?: boolean): void;
  16852. /**
  16853. * Remove one of the post process from the list of attached post processes to the texture
  16854. * @param postProcess define the post process to remove from the list
  16855. */
  16856. removePostProcess(postProcess: PostProcess): void;
  16857. /** @hidden */ shouldRender(): boolean;
  16858. /**
  16859. * Gets the actual render size of the texture.
  16860. * @returns the width of the render size
  16861. */
  16862. getRenderSize(): number;
  16863. /**
  16864. * Gets the actual render width of the texture.
  16865. * @returns the width of the render size
  16866. */
  16867. getRenderWidth(): number;
  16868. /**
  16869. * Gets the actual render height of the texture.
  16870. * @returns the height of the render size
  16871. */
  16872. getRenderHeight(): number;
  16873. /**
  16874. * Get if the texture can be rescaled or not.
  16875. */
  16876. readonly canRescale: boolean;
  16877. /**
  16878. * Resize the texture using a ratio.
  16879. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  16880. */
  16881. scale(ratio: number): void;
  16882. /**
  16883. * Get the texture reflection matrix used to rotate/transform the reflection.
  16884. * @returns the reflection matrix
  16885. */
  16886. getReflectionTextureMatrix(): Matrix;
  16887. /**
  16888. * Resize the texture to a new desired size.
  16889. * Be carrefull as it will recreate all the data in the new texture.
  16890. * @param size Define the new size. It can be:
  16891. * - a number for squared texture,
  16892. * - an object containing { width: number, height: number }
  16893. * - or an object containing a ratio { ratio: number }
  16894. */
  16895. resize(size: number | {
  16896. width: number;
  16897. height: number;
  16898. } | {
  16899. ratio: number;
  16900. }): void;
  16901. /**
  16902. * Renders all the objects from the render list into the texture.
  16903. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  16904. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  16905. */
  16906. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  16907. private _bestReflectionRenderTargetDimension;
  16908. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  16909. private renderToTarget;
  16910. /**
  16911. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16912. * This allowed control for front to back rendering or reversly depending of the special needs.
  16913. *
  16914. * @param renderingGroupId The rendering group id corresponding to its index
  16915. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16916. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16917. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16918. */
  16919. 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;
  16920. /**
  16921. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16922. *
  16923. * @param renderingGroupId The rendering group id corresponding to its index
  16924. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16925. */
  16926. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  16927. /**
  16928. * Clones the texture.
  16929. * @returns the cloned texture
  16930. */
  16931. clone(): RenderTargetTexture;
  16932. /**
  16933. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16934. * @returns The JSON representation of the texture
  16935. */
  16936. serialize(): any;
  16937. /**
  16938. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  16939. */
  16940. disposeFramebufferObjects(): void;
  16941. /**
  16942. * Dispose the texture and release its associated resources.
  16943. */
  16944. dispose(): void;
  16945. /** @hidden */ rebuild(): void;
  16946. /**
  16947. * Clear the info related to rendering groups preventing retention point in material dispose.
  16948. */
  16949. freeRenderingGroups(): void;
  16950. }
  16951. }
  16952. declare module BABYLON {
  16953. /**
  16954. * Base class for the main features of a material in Babylon.js
  16955. */
  16956. export class Material implements IAnimatable {
  16957. /**
  16958. * Returns the triangle fill mode
  16959. */
  16960. static readonly TriangleFillMode: number;
  16961. /**
  16962. * Returns the wireframe mode
  16963. */
  16964. static readonly WireFrameFillMode: number;
  16965. /**
  16966. * Returns the point fill mode
  16967. */
  16968. static readonly PointFillMode: number;
  16969. /**
  16970. * Returns the point list draw mode
  16971. */
  16972. static readonly PointListDrawMode: number;
  16973. /**
  16974. * Returns the line list draw mode
  16975. */
  16976. static readonly LineListDrawMode: number;
  16977. /**
  16978. * Returns the line loop draw mode
  16979. */
  16980. static readonly LineLoopDrawMode: number;
  16981. /**
  16982. * Returns the line strip draw mode
  16983. */
  16984. static readonly LineStripDrawMode: number;
  16985. /**
  16986. * Returns the triangle strip draw mode
  16987. */
  16988. static readonly TriangleStripDrawMode: number;
  16989. /**
  16990. * Returns the triangle fan draw mode
  16991. */
  16992. static readonly TriangleFanDrawMode: number;
  16993. /**
  16994. * Stores the clock-wise side orientation
  16995. */
  16996. static readonly ClockWiseSideOrientation: number;
  16997. /**
  16998. * Stores the counter clock-wise side orientation
  16999. */
  17000. static readonly CounterClockWiseSideOrientation: number;
  17001. /**
  17002. * The dirty texture flag value
  17003. */
  17004. static readonly TextureDirtyFlag: number;
  17005. /**
  17006. * The dirty light flag value
  17007. */
  17008. static readonly LightDirtyFlag: number;
  17009. /**
  17010. * The dirty fresnel flag value
  17011. */
  17012. static readonly FresnelDirtyFlag: number;
  17013. /**
  17014. * The dirty attribute flag value
  17015. */
  17016. static readonly AttributesDirtyFlag: number;
  17017. /**
  17018. * The dirty misc flag value
  17019. */
  17020. static readonly MiscDirtyFlag: number;
  17021. /**
  17022. * The all dirty flag value
  17023. */
  17024. static readonly AllDirtyFlag: number;
  17025. /**
  17026. * The ID of the material
  17027. */
  17028. id: string;
  17029. /**
  17030. * Gets or sets the unique id of the material
  17031. */
  17032. uniqueId: number;
  17033. /**
  17034. * The name of the material
  17035. */
  17036. name: string;
  17037. /**
  17038. * Gets or sets user defined metadata
  17039. */
  17040. metadata: any;
  17041. /**
  17042. * For internal use only. Please do not use.
  17043. */
  17044. reservedDataStore: any;
  17045. /**
  17046. * Specifies if the ready state should be checked on each call
  17047. */
  17048. checkReadyOnEveryCall: boolean;
  17049. /**
  17050. * Specifies if the ready state should be checked once
  17051. */
  17052. checkReadyOnlyOnce: boolean;
  17053. /**
  17054. * The state of the material
  17055. */
  17056. state: string;
  17057. /**
  17058. * The alpha value of the material
  17059. */
  17060. protected _alpha: number;
  17061. /**
  17062. * Sets the alpha value of the material
  17063. */
  17064. /**
  17065. * Gets the alpha value of the material
  17066. */
  17067. alpha: number;
  17068. /**
  17069. * Specifies if back face culling is enabled
  17070. */
  17071. protected _backFaceCulling: boolean;
  17072. /**
  17073. * Sets the back-face culling state
  17074. */
  17075. /**
  17076. * Gets the back-face culling state
  17077. */
  17078. backFaceCulling: boolean;
  17079. /**
  17080. * Stores the value for side orientation
  17081. */
  17082. sideOrientation: number;
  17083. /**
  17084. * Callback triggered when the material is compiled
  17085. */
  17086. onCompiled: (effect: Effect) => void;
  17087. /**
  17088. * Callback triggered when an error occurs
  17089. */
  17090. onError: (effect: Effect, errors: string) => void;
  17091. /**
  17092. * Callback triggered to get the render target textures
  17093. */
  17094. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17095. /**
  17096. * Gets a boolean indicating that current material needs to register RTT
  17097. */
  17098. readonly hasRenderTargetTextures: boolean;
  17099. /**
  17100. * Specifies if the material should be serialized
  17101. */
  17102. doNotSerialize: boolean;
  17103. /**
  17104. * @hidden
  17105. */ storeEffectOnSubMeshes: boolean;
  17106. /**
  17107. * Stores the animations for the material
  17108. */
  17109. animations: Array<Animation>;
  17110. /**
  17111. * An event triggered when the material is disposed
  17112. */
  17113. onDisposeObservable: Observable<Material>;
  17114. /**
  17115. * An observer which watches for dispose events
  17116. */
  17117. private _onDisposeObserver;
  17118. private _onUnBindObservable;
  17119. /**
  17120. * Called during a dispose event
  17121. */
  17122. onDispose: () => void;
  17123. private _onBindObservable;
  17124. /**
  17125. * An event triggered when the material is bound
  17126. */
  17127. readonly onBindObservable: Observable<AbstractMesh>;
  17128. /**
  17129. * An observer which watches for bind events
  17130. */
  17131. private _onBindObserver;
  17132. /**
  17133. * Called during a bind event
  17134. */
  17135. onBind: (Mesh: AbstractMesh) => void;
  17136. /**
  17137. * An event triggered when the material is unbound
  17138. */
  17139. readonly onUnBindObservable: Observable<Material>;
  17140. /**
  17141. * Stores the value of the alpha mode
  17142. */
  17143. private _alphaMode;
  17144. /**
  17145. * Sets the value of the alpha mode.
  17146. *
  17147. * | Value | Type | Description |
  17148. * | --- | --- | --- |
  17149. * | 0 | ALPHA_DISABLE | |
  17150. * | 1 | ALPHA_ADD | |
  17151. * | 2 | ALPHA_COMBINE | |
  17152. * | 3 | ALPHA_SUBTRACT | |
  17153. * | 4 | ALPHA_MULTIPLY | |
  17154. * | 5 | ALPHA_MAXIMIZED | |
  17155. * | 6 | ALPHA_ONEONE | |
  17156. * | 7 | ALPHA_PREMULTIPLIED | |
  17157. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17158. * | 9 | ALPHA_INTERPOLATE | |
  17159. * | 10 | ALPHA_SCREENMODE | |
  17160. *
  17161. */
  17162. /**
  17163. * Gets the value of the alpha mode
  17164. */
  17165. alphaMode: number;
  17166. /**
  17167. * Stores the state of the need depth pre-pass value
  17168. */
  17169. private _needDepthPrePass;
  17170. /**
  17171. * Sets the need depth pre-pass value
  17172. */
  17173. /**
  17174. * Gets the depth pre-pass value
  17175. */
  17176. needDepthPrePass: boolean;
  17177. /**
  17178. * Specifies if depth writing should be disabled
  17179. */
  17180. disableDepthWrite: boolean;
  17181. /**
  17182. * Specifies if depth writing should be forced
  17183. */
  17184. forceDepthWrite: boolean;
  17185. /**
  17186. * Specifies if there should be a separate pass for culling
  17187. */
  17188. separateCullingPass: boolean;
  17189. /**
  17190. * Stores the state specifing if fog should be enabled
  17191. */
  17192. private _fogEnabled;
  17193. /**
  17194. * Sets the state for enabling fog
  17195. */
  17196. /**
  17197. * Gets the value of the fog enabled state
  17198. */
  17199. fogEnabled: boolean;
  17200. /**
  17201. * Stores the size of points
  17202. */
  17203. pointSize: number;
  17204. /**
  17205. * Stores the z offset value
  17206. */
  17207. zOffset: number;
  17208. /**
  17209. * Gets a value specifying if wireframe mode is enabled
  17210. */
  17211. /**
  17212. * Sets the state of wireframe mode
  17213. */
  17214. wireframe: boolean;
  17215. /**
  17216. * Gets the value specifying if point clouds are enabled
  17217. */
  17218. /**
  17219. * Sets the state of point cloud mode
  17220. */
  17221. pointsCloud: boolean;
  17222. /**
  17223. * Gets the material fill mode
  17224. */
  17225. /**
  17226. * Sets the material fill mode
  17227. */
  17228. fillMode: number;
  17229. /**
  17230. * @hidden
  17231. * Stores the effects for the material
  17232. */ effect: Nullable<Effect>;
  17233. /**
  17234. * @hidden
  17235. * Specifies if the material was previously ready
  17236. */ wasPreviouslyReady: boolean;
  17237. /**
  17238. * Specifies if uniform buffers should be used
  17239. */
  17240. private _useUBO;
  17241. /**
  17242. * Stores a reference to the scene
  17243. */
  17244. private _scene;
  17245. /**
  17246. * Stores the fill mode state
  17247. */
  17248. private _fillMode;
  17249. /**
  17250. * Specifies if the depth write state should be cached
  17251. */
  17252. private _cachedDepthWriteState;
  17253. /**
  17254. * Stores the uniform buffer
  17255. */
  17256. protected _uniformBuffer: UniformBuffer;
  17257. /** @hidden */ indexInSceneMaterialArray: number;
  17258. /** @hidden */
  17259. meshMap: Nullable<{
  17260. [id: string]: AbstractMesh | undefined;
  17261. }>;
  17262. /**
  17263. * Creates a material instance
  17264. * @param name defines the name of the material
  17265. * @param scene defines the scene to reference
  17266. * @param doNotAdd specifies if the material should be added to the scene
  17267. */
  17268. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17269. /**
  17270. * Returns a string representation of the current material
  17271. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17272. * @returns a string with material information
  17273. */
  17274. toString(fullDetails?: boolean): string;
  17275. /**
  17276. * Gets the class name of the material
  17277. * @returns a string with the class name of the material
  17278. */
  17279. getClassName(): string;
  17280. /**
  17281. * Specifies if updates for the material been locked
  17282. */
  17283. readonly isFrozen: boolean;
  17284. /**
  17285. * Locks updates for the material
  17286. */
  17287. freeze(): void;
  17288. /**
  17289. * Unlocks updates for the material
  17290. */
  17291. unfreeze(): void;
  17292. /**
  17293. * Specifies if the material is ready to be used
  17294. * @param mesh defines the mesh to check
  17295. * @param useInstances specifies if instances should be used
  17296. * @returns a boolean indicating if the material is ready to be used
  17297. */
  17298. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17299. /**
  17300. * Specifies that the submesh is ready to be used
  17301. * @param mesh defines the mesh to check
  17302. * @param subMesh defines which submesh to check
  17303. * @param useInstances specifies that instances should be used
  17304. * @returns a boolean indicating that the submesh is ready or not
  17305. */
  17306. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17307. /**
  17308. * Returns the material effect
  17309. * @returns the effect associated with the material
  17310. */
  17311. getEffect(): Nullable<Effect>;
  17312. /**
  17313. * Returns the current scene
  17314. * @returns a Scene
  17315. */
  17316. getScene(): Scene;
  17317. /**
  17318. * Specifies if the material will require alpha blending
  17319. * @returns a boolean specifying if alpha blending is needed
  17320. */
  17321. needAlphaBlending(): boolean;
  17322. /**
  17323. * Specifies if the mesh will require alpha blending
  17324. * @param mesh defines the mesh to check
  17325. * @returns a boolean specifying if alpha blending is needed for the mesh
  17326. */
  17327. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  17328. /**
  17329. * Specifies if this material should be rendered in alpha test mode
  17330. * @returns a boolean specifying if an alpha test is needed.
  17331. */
  17332. needAlphaTesting(): boolean;
  17333. /**
  17334. * Gets the texture used for the alpha test
  17335. * @returns the texture to use for alpha testing
  17336. */
  17337. getAlphaTestTexture(): Nullable<BaseTexture>;
  17338. /**
  17339. * Marks the material to indicate that it needs to be re-calculated
  17340. */
  17341. markDirty(): void;
  17342. /** @hidden */ preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  17343. /**
  17344. * Binds the material to the mesh
  17345. * @param world defines the world transformation matrix
  17346. * @param mesh defines the mesh to bind the material to
  17347. */
  17348. bind(world: Matrix, mesh?: Mesh): void;
  17349. /**
  17350. * Binds the submesh to the material
  17351. * @param world defines the world transformation matrix
  17352. * @param mesh defines the mesh containing the submesh
  17353. * @param subMesh defines the submesh to bind the material to
  17354. */
  17355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17356. /**
  17357. * Binds the world matrix to the material
  17358. * @param world defines the world transformation matrix
  17359. */
  17360. bindOnlyWorldMatrix(world: Matrix): void;
  17361. /**
  17362. * Binds the scene's uniform buffer to the effect.
  17363. * @param effect defines the effect to bind to the scene uniform buffer
  17364. * @param sceneUbo defines the uniform buffer storing scene data
  17365. */
  17366. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  17367. /**
  17368. * Binds the view matrix to the effect
  17369. * @param effect defines the effect to bind the view matrix to
  17370. */
  17371. bindView(effect: Effect): void;
  17372. /**
  17373. * Binds the view projection matrix to the effect
  17374. * @param effect defines the effect to bind the view projection matrix to
  17375. */
  17376. bindViewProjection(effect: Effect): void;
  17377. /**
  17378. * Specifies if material alpha testing should be turned on for the mesh
  17379. * @param mesh defines the mesh to check
  17380. */
  17381. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  17382. /**
  17383. * Processes to execute after binding the material to a mesh
  17384. * @param mesh defines the rendered mesh
  17385. */
  17386. protected _afterBind(mesh?: Mesh): void;
  17387. /**
  17388. * Unbinds the material from the mesh
  17389. */
  17390. unbind(): void;
  17391. /**
  17392. * Gets the active textures from the material
  17393. * @returns an array of textures
  17394. */
  17395. getActiveTextures(): BaseTexture[];
  17396. /**
  17397. * Specifies if the material uses a texture
  17398. * @param texture defines the texture to check against the material
  17399. * @returns a boolean specifying if the material uses the texture
  17400. */
  17401. hasTexture(texture: BaseTexture): boolean;
  17402. /**
  17403. * Makes a duplicate of the material, and gives it a new name
  17404. * @param name defines the new name for the duplicated material
  17405. * @returns the cloned material
  17406. */
  17407. clone(name: string): Nullable<Material>;
  17408. /**
  17409. * Gets the meshes bound to the material
  17410. * @returns an array of meshes bound to the material
  17411. */
  17412. getBindedMeshes(): AbstractMesh[];
  17413. /**
  17414. * Force shader compilation
  17415. * @param mesh defines the mesh associated with this material
  17416. * @param onCompiled defines a function to execute once the material is compiled
  17417. * @param options defines the options to configure the compilation
  17418. */
  17419. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  17420. clipPlane: boolean;
  17421. }>): void;
  17422. /**
  17423. * Force shader compilation
  17424. * @param mesh defines the mesh that will use this material
  17425. * @param options defines additional options for compiling the shaders
  17426. * @returns a promise that resolves when the compilation completes
  17427. */
  17428. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  17429. clipPlane: boolean;
  17430. }>): Promise<void>;
  17431. private static readonly _ImageProcessingDirtyCallBack;
  17432. private static readonly _TextureDirtyCallBack;
  17433. private static readonly _FresnelDirtyCallBack;
  17434. private static readonly _MiscDirtyCallBack;
  17435. private static readonly _LightsDirtyCallBack;
  17436. private static readonly _AttributeDirtyCallBack;
  17437. private static _FresnelAndMiscDirtyCallBack;
  17438. private static _TextureAndMiscDirtyCallBack;
  17439. private static readonly _DirtyCallbackArray;
  17440. private static readonly _RunDirtyCallBacks;
  17441. /**
  17442. * Marks a define in the material to indicate that it needs to be re-computed
  17443. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  17444. */
  17445. markAsDirty(flag: number): void;
  17446. /**
  17447. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  17448. * @param func defines a function which checks material defines against the submeshes
  17449. */
  17450. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  17451. /**
  17452. * Indicates that image processing needs to be re-calculated for all submeshes
  17453. */
  17454. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  17455. /**
  17456. * Indicates that textures need to be re-calculated for all submeshes
  17457. */
  17458. protected _markAllSubMeshesAsTexturesDirty(): void;
  17459. /**
  17460. * Indicates that fresnel needs to be re-calculated for all submeshes
  17461. */
  17462. protected _markAllSubMeshesAsFresnelDirty(): void;
  17463. /**
  17464. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  17465. */
  17466. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  17467. /**
  17468. * Indicates that lights need to be re-calculated for all submeshes
  17469. */
  17470. protected _markAllSubMeshesAsLightsDirty(): void;
  17471. /**
  17472. * Indicates that attributes need to be re-calculated for all submeshes
  17473. */
  17474. protected _markAllSubMeshesAsAttributesDirty(): void;
  17475. /**
  17476. * Indicates that misc needs to be re-calculated for all submeshes
  17477. */
  17478. protected _markAllSubMeshesAsMiscDirty(): void;
  17479. /**
  17480. * Indicates that textures and misc need to be re-calculated for all submeshes
  17481. */
  17482. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  17483. /**
  17484. * Disposes the material
  17485. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17486. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17487. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17488. */
  17489. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17490. /** @hidden */
  17491. private releaseVertexArrayObject;
  17492. /**
  17493. * Serializes this material
  17494. * @returns the serialized material object
  17495. */
  17496. serialize(): any;
  17497. /**
  17498. * Creates a material from parsed material data
  17499. * @param parsedMaterial defines parsed material data
  17500. * @param scene defines the hosting scene
  17501. * @param rootUrl defines the root URL to use to load textures
  17502. * @returns a new material
  17503. */
  17504. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  17505. }
  17506. }
  17507. declare module BABYLON {
  17508. /**
  17509. * Class used to represent data loading progression
  17510. */
  17511. export class SceneLoaderFlags {
  17512. private static _ForceFullSceneLoadingForIncremental;
  17513. private static _ShowLoadingScreen;
  17514. private static _CleanBoneMatrixWeights;
  17515. private static _loggingLevel;
  17516. /**
  17517. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  17518. */
  17519. static ForceFullSceneLoadingForIncremental: boolean;
  17520. /**
  17521. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  17522. */
  17523. static ShowLoadingScreen: boolean;
  17524. /**
  17525. * Defines the current logging level (while loading the scene)
  17526. * @ignorenaming
  17527. */
  17528. static loggingLevel: number;
  17529. /**
  17530. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  17531. */
  17532. static CleanBoneMatrixWeights: boolean;
  17533. }
  17534. }
  17535. declare module BABYLON {
  17536. /**
  17537. * Defines a target to use with MorphTargetManager
  17538. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17539. */
  17540. export class MorphTarget implements IAnimatable {
  17541. /** defines the name of the target */
  17542. name: string;
  17543. /**
  17544. * Gets or sets the list of animations
  17545. */
  17546. animations: Animation[];
  17547. private _scene;
  17548. private _positions;
  17549. private _normals;
  17550. private _tangents;
  17551. private _influence;
  17552. /**
  17553. * Observable raised when the influence changes
  17554. */
  17555. onInfluenceChanged: Observable<boolean>;
  17556. /** @hidden */ onDataLayoutChanged: Observable<void>;
  17557. /**
  17558. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  17559. */
  17560. influence: number;
  17561. /**
  17562. * Gets or sets the id of the morph Target
  17563. */
  17564. id: string;
  17565. private _animationPropertiesOverride;
  17566. /**
  17567. * Gets or sets the animation properties override
  17568. */
  17569. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  17570. /**
  17571. * Creates a new MorphTarget
  17572. * @param name defines the name of the target
  17573. * @param influence defines the influence to use
  17574. * @param scene defines the scene the morphtarget belongs to
  17575. */
  17576. constructor(
  17577. /** defines the name of the target */
  17578. name: string, influence?: number, scene?: Nullable<Scene>);
  17579. /**
  17580. * Gets a boolean defining if the target contains position data
  17581. */
  17582. readonly hasPositions: boolean;
  17583. /**
  17584. * Gets a boolean defining if the target contains normal data
  17585. */
  17586. readonly hasNormals: boolean;
  17587. /**
  17588. * Gets a boolean defining if the target contains tangent data
  17589. */
  17590. readonly hasTangents: boolean;
  17591. /**
  17592. * Affects position data to this target
  17593. * @param data defines the position data to use
  17594. */
  17595. setPositions(data: Nullable<FloatArray>): void;
  17596. /**
  17597. * Gets the position data stored in this target
  17598. * @returns a FloatArray containing the position data (or null if not present)
  17599. */
  17600. getPositions(): Nullable<FloatArray>;
  17601. /**
  17602. * Affects normal data to this target
  17603. * @param data defines the normal data to use
  17604. */
  17605. setNormals(data: Nullable<FloatArray>): void;
  17606. /**
  17607. * Gets the normal data stored in this target
  17608. * @returns a FloatArray containing the normal data (or null if not present)
  17609. */
  17610. getNormals(): Nullable<FloatArray>;
  17611. /**
  17612. * Affects tangent data to this target
  17613. * @param data defines the tangent data to use
  17614. */
  17615. setTangents(data: Nullable<FloatArray>): void;
  17616. /**
  17617. * Gets the tangent data stored in this target
  17618. * @returns a FloatArray containing the tangent data (or null if not present)
  17619. */
  17620. getTangents(): Nullable<FloatArray>;
  17621. /**
  17622. * Serializes the current target into a Serialization object
  17623. * @returns the serialized object
  17624. */
  17625. serialize(): any;
  17626. /**
  17627. * Returns the string "MorphTarget"
  17628. * @returns "MorphTarget"
  17629. */
  17630. getClassName(): string;
  17631. /**
  17632. * Creates a new target from serialized data
  17633. * @param serializationObject defines the serialized data to use
  17634. * @returns a new MorphTarget
  17635. */
  17636. static Parse(serializationObject: any): MorphTarget;
  17637. /**
  17638. * Creates a MorphTarget from mesh data
  17639. * @param mesh defines the source mesh
  17640. * @param name defines the name to use for the new target
  17641. * @param influence defines the influence to attach to the target
  17642. * @returns a new MorphTarget
  17643. */
  17644. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  17645. }
  17646. }
  17647. declare module BABYLON {
  17648. /**
  17649. * This class is used to deform meshes using morphing between different targets
  17650. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17651. */
  17652. export class MorphTargetManager {
  17653. private _targets;
  17654. private _targetInfluenceChangedObservers;
  17655. private _targetDataLayoutChangedObservers;
  17656. private _activeTargets;
  17657. private _scene;
  17658. private _influences;
  17659. private _supportsNormals;
  17660. private _supportsTangents;
  17661. private _vertexCount;
  17662. private _uniqueId;
  17663. private _tempInfluences;
  17664. /**
  17665. * Creates a new MorphTargetManager
  17666. * @param scene defines the current scene
  17667. */
  17668. constructor(scene?: Nullable<Scene>);
  17669. /**
  17670. * Gets the unique ID of this manager
  17671. */
  17672. readonly uniqueId: number;
  17673. /**
  17674. * Gets the number of vertices handled by this manager
  17675. */
  17676. readonly vertexCount: number;
  17677. /**
  17678. * Gets a boolean indicating if this manager supports morphing of normals
  17679. */
  17680. readonly supportsNormals: boolean;
  17681. /**
  17682. * Gets a boolean indicating if this manager supports morphing of tangents
  17683. */
  17684. readonly supportsTangents: boolean;
  17685. /**
  17686. * Gets the number of targets stored in this manager
  17687. */
  17688. readonly numTargets: number;
  17689. /**
  17690. * Gets the number of influencers (ie. the number of targets with influences > 0)
  17691. */
  17692. readonly numInfluencers: number;
  17693. /**
  17694. * Gets the list of influences (one per target)
  17695. */
  17696. readonly influences: Float32Array;
  17697. /**
  17698. * Gets the active target at specified index. An active target is a target with an influence > 0
  17699. * @param index defines the index to check
  17700. * @returns the requested target
  17701. */
  17702. getActiveTarget(index: number): MorphTarget;
  17703. /**
  17704. * Gets the target at specified index
  17705. * @param index defines the index to check
  17706. * @returns the requested target
  17707. */
  17708. getTarget(index: number): MorphTarget;
  17709. /**
  17710. * Add a new target to this manager
  17711. * @param target defines the target to add
  17712. */
  17713. addTarget(target: MorphTarget): void;
  17714. /**
  17715. * Removes a target from the manager
  17716. * @param target defines the target to remove
  17717. */
  17718. removeTarget(target: MorphTarget): void;
  17719. /**
  17720. * Serializes the current manager into a Serialization object
  17721. * @returns the serialized object
  17722. */
  17723. serialize(): any;
  17724. private _syncActiveTargets;
  17725. /**
  17726. * Syncrhonize the targets with all the meshes using this morph target manager
  17727. */
  17728. synchronize(): void;
  17729. /**
  17730. * Creates a new MorphTargetManager from serialized data
  17731. * @param serializationObject defines the serialized data
  17732. * @param scene defines the hosting scene
  17733. * @returns the new MorphTargetManager
  17734. */
  17735. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  17736. }
  17737. }
  17738. declare module BABYLON {
  17739. /**
  17740. * Interface for Physics-Joint data
  17741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17742. */
  17743. export interface PhysicsJointData {
  17744. /**
  17745. * The main pivot of the joint
  17746. */
  17747. mainPivot?: Vector3;
  17748. /**
  17749. * The connected pivot of the joint
  17750. */
  17751. connectedPivot?: Vector3;
  17752. /**
  17753. * The main axis of the joint
  17754. */
  17755. mainAxis?: Vector3;
  17756. /**
  17757. * The connected axis of the joint
  17758. */
  17759. connectedAxis?: Vector3;
  17760. /**
  17761. * The collision of the joint
  17762. */
  17763. collision?: boolean;
  17764. /**
  17765. * Native Oimo/Cannon/Energy data
  17766. */
  17767. nativeParams?: any;
  17768. }
  17769. /**
  17770. * This is a holder class for the physics joint created by the physics plugin
  17771. * It holds a set of functions to control the underlying joint
  17772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17773. */
  17774. export class PhysicsJoint {
  17775. /**
  17776. * The type of the physics joint
  17777. */
  17778. type: number;
  17779. /**
  17780. * The data for the physics joint
  17781. */
  17782. jointData: PhysicsJointData;
  17783. private _physicsJoint;
  17784. protected _physicsPlugin: IPhysicsEnginePlugin;
  17785. /**
  17786. * Initializes the physics joint
  17787. * @param type The type of the physics joint
  17788. * @param jointData The data for the physics joint
  17789. */
  17790. constructor(
  17791. /**
  17792. * The type of the physics joint
  17793. */
  17794. type: number,
  17795. /**
  17796. * The data for the physics joint
  17797. */
  17798. jointData: PhysicsJointData);
  17799. /**
  17800. * Gets the physics joint
  17801. */
  17802. /**
  17803. * Sets the physics joint
  17804. */
  17805. physicsJoint: any;
  17806. /**
  17807. * Sets the physics plugin
  17808. */
  17809. physicsPlugin: IPhysicsEnginePlugin;
  17810. /**
  17811. * Execute a function that is physics-plugin specific.
  17812. * @param {Function} func the function that will be executed.
  17813. * It accepts two parameters: the physics world and the physics joint
  17814. */
  17815. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  17816. /**
  17817. * Distance-Joint type
  17818. */
  17819. static DistanceJoint: number;
  17820. /**
  17821. * Hinge-Joint type
  17822. */
  17823. static HingeJoint: number;
  17824. /**
  17825. * Ball-and-Socket joint type
  17826. */
  17827. static BallAndSocketJoint: number;
  17828. /**
  17829. * Wheel-Joint type
  17830. */
  17831. static WheelJoint: number;
  17832. /**
  17833. * Slider-Joint type
  17834. */
  17835. static SliderJoint: number;
  17836. /**
  17837. * Prismatic-Joint type
  17838. */
  17839. static PrismaticJoint: number;
  17840. /**
  17841. * Universal-Joint type
  17842. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  17843. */
  17844. static UniversalJoint: number;
  17845. /**
  17846. * Hinge-Joint 2 type
  17847. */
  17848. static Hinge2Joint: number;
  17849. /**
  17850. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  17851. */
  17852. static PointToPointJoint: number;
  17853. /**
  17854. * Spring-Joint type
  17855. */
  17856. static SpringJoint: number;
  17857. /**
  17858. * Lock-Joint type
  17859. */
  17860. static LockJoint: number;
  17861. }
  17862. /**
  17863. * A class representing a physics distance joint
  17864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17865. */
  17866. export class DistanceJoint extends PhysicsJoint {
  17867. /**
  17868. *
  17869. * @param jointData The data for the Distance-Joint
  17870. */
  17871. constructor(jointData: DistanceJointData);
  17872. /**
  17873. * Update the predefined distance.
  17874. * @param maxDistance The maximum preferred distance
  17875. * @param minDistance The minimum preferred distance
  17876. */
  17877. updateDistance(maxDistance: number, minDistance?: number): void;
  17878. }
  17879. /**
  17880. * Represents a Motor-Enabled Joint
  17881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17882. */
  17883. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  17884. /**
  17885. * Initializes the Motor-Enabled Joint
  17886. * @param type The type of the joint
  17887. * @param jointData The physica joint data for the joint
  17888. */
  17889. constructor(type: number, jointData: PhysicsJointData);
  17890. /**
  17891. * Set the motor values.
  17892. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17893. * @param force the force to apply
  17894. * @param maxForce max force for this motor.
  17895. */
  17896. setMotor(force?: number, maxForce?: number): void;
  17897. /**
  17898. * Set the motor's limits.
  17899. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17900. * @param upperLimit The upper limit of the motor
  17901. * @param lowerLimit The lower limit of the motor
  17902. */
  17903. setLimit(upperLimit: number, lowerLimit?: number): void;
  17904. }
  17905. /**
  17906. * This class represents a single physics Hinge-Joint
  17907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17908. */
  17909. export class HingeJoint extends MotorEnabledJoint {
  17910. /**
  17911. * Initializes the Hinge-Joint
  17912. * @param jointData The joint data for the Hinge-Joint
  17913. */
  17914. constructor(jointData: PhysicsJointData);
  17915. /**
  17916. * Set the motor values.
  17917. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17918. * @param {number} force the force to apply
  17919. * @param {number} maxForce max force for this motor.
  17920. */
  17921. setMotor(force?: number, maxForce?: number): void;
  17922. /**
  17923. * Set the motor's limits.
  17924. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17925. * @param upperLimit The upper limit of the motor
  17926. * @param lowerLimit The lower limit of the motor
  17927. */
  17928. setLimit(upperLimit: number, lowerLimit?: number): void;
  17929. }
  17930. /**
  17931. * This class represents a dual hinge physics joint (same as wheel joint)
  17932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17933. */
  17934. export class Hinge2Joint extends MotorEnabledJoint {
  17935. /**
  17936. * Initializes the Hinge2-Joint
  17937. * @param jointData The joint data for the Hinge2-Joint
  17938. */
  17939. constructor(jointData: PhysicsJointData);
  17940. /**
  17941. * Set the motor values.
  17942. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17943. * @param {number} force the force to apply
  17944. * @param {number} maxForce max force for this motor.
  17945. * @param {motorIndex} the motor's index, 0 or 1.
  17946. */
  17947. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  17948. /**
  17949. * Set the motor limits.
  17950. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17951. * @param {number} upperLimit the upper limit
  17952. * @param {number} lowerLimit lower limit
  17953. * @param {motorIndex} the motor's index, 0 or 1.
  17954. */
  17955. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  17956. }
  17957. /**
  17958. * Interface for a motor enabled joint
  17959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17960. */
  17961. export interface IMotorEnabledJoint {
  17962. /**
  17963. * Physics joint
  17964. */
  17965. physicsJoint: any;
  17966. /**
  17967. * Sets the motor of the motor-enabled joint
  17968. * @param force The force of the motor
  17969. * @param maxForce The maximum force of the motor
  17970. * @param motorIndex The index of the motor
  17971. */
  17972. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  17973. /**
  17974. * Sets the limit of the motor
  17975. * @param upperLimit The upper limit of the motor
  17976. * @param lowerLimit The lower limit of the motor
  17977. * @param motorIndex The index of the motor
  17978. */
  17979. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  17980. }
  17981. /**
  17982. * Joint data for a Distance-Joint
  17983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17984. */
  17985. export interface DistanceJointData extends PhysicsJointData {
  17986. /**
  17987. * Max distance the 2 joint objects can be apart
  17988. */
  17989. maxDistance: number;
  17990. }
  17991. /**
  17992. * Joint data from a spring joint
  17993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17994. */
  17995. export interface SpringJointData extends PhysicsJointData {
  17996. /**
  17997. * Length of the spring
  17998. */
  17999. length: number;
  18000. /**
  18001. * Stiffness of the spring
  18002. */
  18003. stiffness: number;
  18004. /**
  18005. * Damping of the spring
  18006. */
  18007. damping: number;
  18008. /** this callback will be called when applying the force to the impostors. */
  18009. forceApplicationCallback: () => void;
  18010. }
  18011. }
  18012. declare module BABYLON {
  18013. /**
  18014. * Interface used to describe a physics joint
  18015. */
  18016. export interface PhysicsImpostorJoint {
  18017. /** Defines the main impostor to which the joint is linked */
  18018. mainImpostor: PhysicsImpostor;
  18019. /** Defines the impostor that is connected to the main impostor using this joint */
  18020. connectedImpostor: PhysicsImpostor;
  18021. /** Defines the joint itself */
  18022. joint: PhysicsJoint;
  18023. }
  18024. /** @hidden */
  18025. export interface IPhysicsEnginePlugin {
  18026. world: any;
  18027. name: string;
  18028. setGravity(gravity: Vector3): void;
  18029. setTimeStep(timeStep: number): void;
  18030. getTimeStep(): number;
  18031. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18032. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18033. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18034. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18035. removePhysicsBody(impostor: PhysicsImpostor): void;
  18036. generateJoint(joint: PhysicsImpostorJoint): void;
  18037. removeJoint(joint: PhysicsImpostorJoint): void;
  18038. isSupported(): boolean;
  18039. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18040. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18041. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18042. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18043. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18044. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18045. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18046. getBodyMass(impostor: PhysicsImpostor): number;
  18047. getBodyFriction(impostor: PhysicsImpostor): number;
  18048. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18049. getBodyRestitution(impostor: PhysicsImpostor): number;
  18050. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18051. sleepBody(impostor: PhysicsImpostor): void;
  18052. wakeUpBody(impostor: PhysicsImpostor): void;
  18053. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18054. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18055. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18056. getRadius(impostor: PhysicsImpostor): number;
  18057. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18058. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18059. dispose(): void;
  18060. }
  18061. /**
  18062. * Interface used to define a physics engine
  18063. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18064. */
  18065. export interface IPhysicsEngine {
  18066. /**
  18067. * Gets the gravity vector used by the simulation
  18068. */
  18069. gravity: Vector3;
  18070. /**
  18071. * Sets the gravity vector used by the simulation
  18072. * @param gravity defines the gravity vector to use
  18073. */
  18074. setGravity(gravity: Vector3): void;
  18075. /**
  18076. * Set the time step of the physics engine.
  18077. * Default is 1/60.
  18078. * To slow it down, enter 1/600 for example.
  18079. * To speed it up, 1/30
  18080. * @param newTimeStep the new timestep to apply to this world.
  18081. */
  18082. setTimeStep(newTimeStep: number): void;
  18083. /**
  18084. * Get the time step of the physics engine.
  18085. * @returns the current time step
  18086. */
  18087. getTimeStep(): number;
  18088. /**
  18089. * Release all resources
  18090. */
  18091. dispose(): void;
  18092. /**
  18093. * Gets the name of the current physics plugin
  18094. * @returns the name of the plugin
  18095. */
  18096. getPhysicsPluginName(): string;
  18097. /**
  18098. * Adding a new impostor for the impostor tracking.
  18099. * This will be done by the impostor itself.
  18100. * @param impostor the impostor to add
  18101. */
  18102. addImpostor(impostor: PhysicsImpostor): void;
  18103. /**
  18104. * Remove an impostor from the engine.
  18105. * This impostor and its mesh will not longer be updated by the physics engine.
  18106. * @param impostor the impostor to remove
  18107. */
  18108. removeImpostor(impostor: PhysicsImpostor): void;
  18109. /**
  18110. * Add a joint to the physics engine
  18111. * @param mainImpostor defines the main impostor to which the joint is added.
  18112. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  18113. * @param joint defines the joint that will connect both impostors.
  18114. */
  18115. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18116. /**
  18117. * Removes a joint from the simulation
  18118. * @param mainImpostor defines the impostor used with the joint
  18119. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  18120. * @param joint defines the joint to remove
  18121. */
  18122. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18123. /**
  18124. * Gets the current plugin used to run the simulation
  18125. * @returns current plugin
  18126. */
  18127. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18128. /**
  18129. * Gets the list of physic impostors
  18130. * @returns an array of PhysicsImpostor
  18131. */
  18132. getImpostors(): Array<PhysicsImpostor>;
  18133. /**
  18134. * Gets the impostor for a physics enabled object
  18135. * @param object defines the object impersonated by the impostor
  18136. * @returns the PhysicsImpostor or null if not found
  18137. */
  18138. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18139. /**
  18140. * Gets the impostor for a physics body object
  18141. * @param body defines physics body used by the impostor
  18142. * @returns the PhysicsImpostor or null if not found
  18143. */
  18144. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18145. /**
  18146. * Called by the scene. No need to call it.
  18147. * @param delta defines the timespam between frames
  18148. */ step(delta: number): void;
  18149. }
  18150. }
  18151. declare module BABYLON {
  18152. /**
  18153. * The interface for the physics imposter parameters
  18154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18155. */
  18156. export interface PhysicsImpostorParameters {
  18157. /**
  18158. * The mass of the physics imposter
  18159. */
  18160. mass: number;
  18161. /**
  18162. * The friction of the physics imposter
  18163. */
  18164. friction?: number;
  18165. /**
  18166. * The coefficient of restitution of the physics imposter
  18167. */
  18168. restitution?: number;
  18169. /**
  18170. * The native options of the physics imposter
  18171. */
  18172. nativeOptions?: any;
  18173. /**
  18174. * Specifies if the parent should be ignored
  18175. */
  18176. ignoreParent?: boolean;
  18177. /**
  18178. * Specifies if bi-directional transformations should be disabled
  18179. */
  18180. disableBidirectionalTransformation?: boolean;
  18181. }
  18182. /**
  18183. * Interface for a physics-enabled object
  18184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18185. */
  18186. export interface IPhysicsEnabledObject {
  18187. /**
  18188. * The position of the physics-enabled object
  18189. */
  18190. position: Vector3;
  18191. /**
  18192. * The rotation of the physics-enabled object
  18193. */
  18194. rotationQuaternion: Nullable<Quaternion>;
  18195. /**
  18196. * The scale of the physics-enabled object
  18197. */
  18198. scaling: Vector3;
  18199. /**
  18200. * The rotation of the physics-enabled object
  18201. */
  18202. rotation?: Vector3;
  18203. /**
  18204. * The parent of the physics-enabled object
  18205. */
  18206. parent?: any;
  18207. /**
  18208. * The bounding info of the physics-enabled object
  18209. * @returns The bounding info of the physics-enabled object
  18210. */
  18211. getBoundingInfo(): BoundingInfo;
  18212. /**
  18213. * Computes the world matrix
  18214. * @param force Specifies if the world matrix should be computed by force
  18215. * @returns A world matrix
  18216. */
  18217. computeWorldMatrix(force: boolean): Matrix;
  18218. /**
  18219. * Gets the world matrix
  18220. * @returns A world matrix
  18221. */
  18222. getWorldMatrix?(): Matrix;
  18223. /**
  18224. * Gets the child meshes
  18225. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  18226. * @returns An array of abstract meshes
  18227. */
  18228. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  18229. /**
  18230. * Gets the vertex data
  18231. * @param kind The type of vertex data
  18232. * @returns A nullable array of numbers, or a float32 array
  18233. */
  18234. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  18235. /**
  18236. * Gets the indices from the mesh
  18237. * @returns A nullable array of index arrays
  18238. */
  18239. getIndices?(): Nullable<IndicesArray>;
  18240. /**
  18241. * Gets the scene from the mesh
  18242. * @returns the indices array or null
  18243. */
  18244. getScene?(): Scene;
  18245. /**
  18246. * Gets the absolute position from the mesh
  18247. * @returns the absolute position
  18248. */
  18249. getAbsolutePosition(): Vector3;
  18250. /**
  18251. * Gets the absolute pivot point from the mesh
  18252. * @returns the absolute pivot point
  18253. */
  18254. getAbsolutePivotPoint(): Vector3;
  18255. /**
  18256. * Rotates the mesh
  18257. * @param axis The axis of rotation
  18258. * @param amount The amount of rotation
  18259. * @param space The space of the rotation
  18260. * @returns The rotation transform node
  18261. */
  18262. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18263. /**
  18264. * Translates the mesh
  18265. * @param axis The axis of translation
  18266. * @param distance The distance of translation
  18267. * @param space The space of the translation
  18268. * @returns The transform node
  18269. */
  18270. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18271. /**
  18272. * Sets the absolute position of the mesh
  18273. * @param absolutePosition The absolute position of the mesh
  18274. * @returns The transform node
  18275. */
  18276. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18277. /**
  18278. * Gets the class name of the mesh
  18279. * @returns The class name
  18280. */
  18281. getClassName(): string;
  18282. }
  18283. /**
  18284. * Represents a physics imposter
  18285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18286. */
  18287. export class PhysicsImpostor {
  18288. /**
  18289. * The physics-enabled object used as the physics imposter
  18290. */
  18291. object: IPhysicsEnabledObject;
  18292. /**
  18293. * The type of the physics imposter
  18294. */
  18295. type: number;
  18296. private _options;
  18297. private _scene?;
  18298. /**
  18299. * The default object size of the imposter
  18300. */
  18301. static DEFAULT_OBJECT_SIZE: Vector3;
  18302. /**
  18303. * The identity quaternion of the imposter
  18304. */
  18305. static IDENTITY_QUATERNION: Quaternion;
  18306. /** @hidden */ pluginData: any;
  18307. private _physicsEngine;
  18308. private _physicsBody;
  18309. private _bodyUpdateRequired;
  18310. private _onBeforePhysicsStepCallbacks;
  18311. private _onAfterPhysicsStepCallbacks;
  18312. /** @hidden */ onPhysicsCollideCallbacks: Array<{
  18313. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  18314. otherImpostors: Array<PhysicsImpostor>;
  18315. }>;
  18316. private _deltaPosition;
  18317. private _deltaRotation;
  18318. private _deltaRotationConjugated;
  18319. private _parent;
  18320. private _isDisposed;
  18321. private static _tmpVecs;
  18322. private static _tmpQuat;
  18323. /**
  18324. * Specifies if the physics imposter is disposed
  18325. */
  18326. readonly isDisposed: boolean;
  18327. /**
  18328. * Gets the mass of the physics imposter
  18329. */
  18330. mass: number;
  18331. /**
  18332. * Gets the coefficient of friction
  18333. */
  18334. /**
  18335. * Sets the coefficient of friction
  18336. */
  18337. friction: number;
  18338. /**
  18339. * Gets the coefficient of restitution
  18340. */
  18341. /**
  18342. * Sets the coefficient of restitution
  18343. */
  18344. restitution: number;
  18345. /**
  18346. * The unique id of the physics imposter
  18347. * set by the physics engine when adding this impostor to the array
  18348. */
  18349. uniqueId: number;
  18350. private _joints;
  18351. /**
  18352. * Initializes the physics imposter
  18353. * @param object The physics-enabled object used as the physics imposter
  18354. * @param type The type of the physics imposter
  18355. * @param _options The options for the physics imposter
  18356. * @param _scene The Babylon scene
  18357. */
  18358. constructor(
  18359. /**
  18360. * The physics-enabled object used as the physics imposter
  18361. */
  18362. object: IPhysicsEnabledObject,
  18363. /**
  18364. * The type of the physics imposter
  18365. */
  18366. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  18367. /**
  18368. * This function will completly initialize this impostor.
  18369. * It will create a new body - but only if this mesh has no parent.
  18370. * If it has, this impostor will not be used other than to define the impostor
  18371. * of the child mesh.
  18372. * @hidden
  18373. */ init(): void;
  18374. private _getPhysicsParent;
  18375. /**
  18376. * Should a new body be generated.
  18377. * @returns boolean specifying if body initialization is required
  18378. */
  18379. isBodyInitRequired(): boolean;
  18380. /**
  18381. * Sets the updated scaling
  18382. * @param updated Specifies if the scaling is updated
  18383. */
  18384. setScalingUpdated(): void;
  18385. /**
  18386. * Force a regeneration of this or the parent's impostor's body.
  18387. * Use under cautious - This will remove all joints already implemented.
  18388. */
  18389. forceUpdate(): void;
  18390. /**
  18391. * Gets the body that holds this impostor. Either its own, or its parent.
  18392. */
  18393. /**
  18394. * Set the physics body. Used mainly by the physics engine/plugin
  18395. */
  18396. physicsBody: any;
  18397. /**
  18398. * Get the parent of the physics imposter
  18399. * @returns Physics imposter or null
  18400. */
  18401. /**
  18402. * Sets the parent of the physics imposter
  18403. */
  18404. parent: Nullable<PhysicsImpostor>;
  18405. /**
  18406. * Resets the update flags
  18407. */
  18408. resetUpdateFlags(): void;
  18409. /**
  18410. * Gets the object extend size
  18411. * @returns the object extend size
  18412. */
  18413. getObjectExtendSize(): Vector3;
  18414. /**
  18415. * Gets the object center
  18416. * @returns The object center
  18417. */
  18418. getObjectCenter(): Vector3;
  18419. /**
  18420. * Get a specific parametes from the options parameter
  18421. * @param paramName The object parameter name
  18422. * @returns The object parameter
  18423. */
  18424. getParam(paramName: string): any;
  18425. /**
  18426. * Sets a specific parameter in the options given to the physics plugin
  18427. * @param paramName The parameter name
  18428. * @param value The value of the parameter
  18429. */
  18430. setParam(paramName: string, value: number): void;
  18431. /**
  18432. * Specifically change the body's mass option. Won't recreate the physics body object
  18433. * @param mass The mass of the physics imposter
  18434. */
  18435. setMass(mass: number): void;
  18436. /**
  18437. * Gets the linear velocity
  18438. * @returns linear velocity or null
  18439. */
  18440. getLinearVelocity(): Nullable<Vector3>;
  18441. /**
  18442. * Sets the linear velocity
  18443. * @param velocity linear velocity or null
  18444. */
  18445. setLinearVelocity(velocity: Nullable<Vector3>): void;
  18446. /**
  18447. * Gets the angular velocity
  18448. * @returns angular velocity or null
  18449. */
  18450. getAngularVelocity(): Nullable<Vector3>;
  18451. /**
  18452. * Sets the angular velocity
  18453. * @param velocity The velocity or null
  18454. */
  18455. setAngularVelocity(velocity: Nullable<Vector3>): void;
  18456. /**
  18457. * Execute a function with the physics plugin native code
  18458. * Provide a function the will have two variables - the world object and the physics body object
  18459. * @param func The function to execute with the physics plugin native code
  18460. */
  18461. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  18462. /**
  18463. * Register a function that will be executed before the physics world is stepping forward
  18464. * @param func The function to execute before the physics world is stepped forward
  18465. */
  18466. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18467. /**
  18468. * Unregister a function that will be executed before the physics world is stepping forward
  18469. * @param func The function to execute before the physics world is stepped forward
  18470. */
  18471. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18472. /**
  18473. * Register a function that will be executed after the physics step
  18474. * @param func The function to execute after physics step
  18475. */
  18476. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18477. /**
  18478. * Unregisters a function that will be executed after the physics step
  18479. * @param func The function to execute after physics step
  18480. */
  18481. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18482. /**
  18483. * register a function that will be executed when this impostor collides against a different body
  18484. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  18485. * @param func Callback that is executed on collision
  18486. */
  18487. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  18488. /**
  18489. * Unregisters the physics imposter on contact
  18490. * @param collideAgainst The physics object to collide against
  18491. * @param func Callback to execute on collision
  18492. */
  18493. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  18494. private _tmpQuat;
  18495. private _tmpQuat2;
  18496. /**
  18497. * Get the parent rotation
  18498. * @returns The parent rotation
  18499. */
  18500. getParentsRotation(): Quaternion;
  18501. /**
  18502. * this function is executed by the physics engine.
  18503. */
  18504. beforeStep: () => void;
  18505. /**
  18506. * this function is executed by the physics engine
  18507. */
  18508. afterStep: () => void;
  18509. /**
  18510. * Legacy collision detection event support
  18511. */
  18512. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  18513. /**
  18514. * event and body object due to cannon's event-based architecture.
  18515. */
  18516. onCollide: (e: {
  18517. body: any;
  18518. }) => void;
  18519. /**
  18520. * Apply a force
  18521. * @param force The force to apply
  18522. * @param contactPoint The contact point for the force
  18523. * @returns The physics imposter
  18524. */
  18525. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18526. /**
  18527. * Apply an impulse
  18528. * @param force The impulse force
  18529. * @param contactPoint The contact point for the impulse force
  18530. * @returns The physics imposter
  18531. */
  18532. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18533. /**
  18534. * A help function to create a joint
  18535. * @param otherImpostor A physics imposter used to create a joint
  18536. * @param jointType The type of joint
  18537. * @param jointData The data for the joint
  18538. * @returns The physics imposter
  18539. */
  18540. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  18541. /**
  18542. * Add a joint to this impostor with a different impostor
  18543. * @param otherImpostor A physics imposter used to add a joint
  18544. * @param joint The joint to add
  18545. * @returns The physics imposter
  18546. */
  18547. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  18548. /**
  18549. * Will keep this body still, in a sleep mode.
  18550. * @returns the physics imposter
  18551. */
  18552. sleep(): PhysicsImpostor;
  18553. /**
  18554. * Wake the body up.
  18555. * @returns The physics imposter
  18556. */
  18557. wakeUp(): PhysicsImpostor;
  18558. /**
  18559. * Clones the physics imposter
  18560. * @param newObject The physics imposter clones to this physics-enabled object
  18561. * @returns A nullable physics imposter
  18562. */
  18563. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18564. /**
  18565. * Disposes the physics imposter
  18566. */
  18567. dispose(): void;
  18568. /**
  18569. * Sets the delta position
  18570. * @param position The delta position amount
  18571. */
  18572. setDeltaPosition(position: Vector3): void;
  18573. /**
  18574. * Sets the delta rotation
  18575. * @param rotation The delta rotation amount
  18576. */
  18577. setDeltaRotation(rotation: Quaternion): void;
  18578. /**
  18579. * Gets the box size of the physics imposter and stores the result in the input parameter
  18580. * @param result Stores the box size
  18581. * @returns The physics imposter
  18582. */
  18583. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  18584. /**
  18585. * Gets the radius of the physics imposter
  18586. * @returns Radius of the physics imposter
  18587. */
  18588. getRadius(): number;
  18589. /**
  18590. * Sync a bone with this impostor
  18591. * @param bone The bone to sync to the impostor.
  18592. * @param boneMesh The mesh that the bone is influencing.
  18593. * @param jointPivot The pivot of the joint / bone in local space.
  18594. * @param distToJoint Optional distance from the impostor to the joint.
  18595. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18596. */
  18597. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  18598. /**
  18599. * Sync impostor to a bone
  18600. * @param bone The bone that the impostor will be synced to.
  18601. * @param boneMesh The mesh that the bone is influencing.
  18602. * @param jointPivot The pivot of the joint / bone in local space.
  18603. * @param distToJoint Optional distance from the impostor to the joint.
  18604. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18605. * @param boneAxis Optional vector3 axis the bone is aligned with
  18606. */
  18607. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  18608. /**
  18609. * No-Imposter type
  18610. */
  18611. static NoImpostor: number;
  18612. /**
  18613. * Sphere-Imposter type
  18614. */
  18615. static SphereImpostor: number;
  18616. /**
  18617. * Box-Imposter type
  18618. */
  18619. static BoxImpostor: number;
  18620. /**
  18621. * Plane-Imposter type
  18622. */
  18623. static PlaneImpostor: number;
  18624. /**
  18625. * Mesh-imposter type
  18626. */
  18627. static MeshImpostor: number;
  18628. /**
  18629. * Cylinder-Imposter type
  18630. */
  18631. static CylinderImpostor: number;
  18632. /**
  18633. * Particle-Imposter type
  18634. */
  18635. static ParticleImpostor: number;
  18636. /**
  18637. * Heightmap-Imposter type
  18638. */
  18639. static HeightmapImpostor: number;
  18640. }
  18641. }
  18642. declare module BABYLON {
  18643. /**
  18644. * Mesh representing the gorund
  18645. */
  18646. export class GroundMesh extends Mesh {
  18647. /** If octree should be generated */
  18648. generateOctree: boolean;
  18649. private _heightQuads;
  18650. /** @hidden */ subdivisionsX: number;
  18651. /** @hidden */ subdivisionsY: number;
  18652. /** @hidden */ width: number;
  18653. /** @hidden */ height: number;
  18654. /** @hidden */ minX: number;
  18655. /** @hidden */ maxX: number;
  18656. /** @hidden */ minZ: number;
  18657. /** @hidden */ maxZ: number;
  18658. constructor(name: string, scene: Scene);
  18659. /**
  18660. * "GroundMesh"
  18661. * @returns "GroundMesh"
  18662. */
  18663. getClassName(): string;
  18664. /**
  18665. * The minimum of x and y subdivisions
  18666. */
  18667. readonly subdivisions: number;
  18668. /**
  18669. * X subdivisions
  18670. */
  18671. readonly subdivisionsX: number;
  18672. /**
  18673. * Y subdivisions
  18674. */
  18675. readonly subdivisionsY: number;
  18676. /**
  18677. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18678. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18679. * @param chunksCount the number of subdivisions for x and y
  18680. * @param octreeBlocksSize (Default: 32)
  18681. */
  18682. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18683. /**
  18684. * Returns a height (y) value in the Worl system :
  18685. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18686. * @param x x coordinate
  18687. * @param z z coordinate
  18688. * @returns the ground y position if (x, z) are outside the ground surface.
  18689. */
  18690. getHeightAtCoordinates(x: number, z: number): number;
  18691. /**
  18692. * Returns a normalized vector (Vector3) orthogonal to the ground
  18693. * at the ground coordinates (x, z) expressed in the World system.
  18694. * @param x x coordinate
  18695. * @param z z coordinate
  18696. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18697. */
  18698. getNormalAtCoordinates(x: number, z: number): Vector3;
  18699. /**
  18700. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18701. * at the ground coordinates (x, z) expressed in the World system.
  18702. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18703. * @param x x coordinate
  18704. * @param z z coordinate
  18705. * @param ref vector to store the result
  18706. * @returns the GroundMesh.
  18707. */
  18708. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18709. /**
  18710. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18711. * if the ground has been updated.
  18712. * This can be used in the render loop.
  18713. * @returns the GroundMesh.
  18714. */
  18715. updateCoordinateHeights(): GroundMesh;
  18716. private _getFacetAt;
  18717. private _initHeightQuads;
  18718. private _computeHeightQuads;
  18719. /**
  18720. * Serializes this ground mesh
  18721. * @param serializationObject object to write serialization to
  18722. */
  18723. serialize(serializationObject: any): void;
  18724. /**
  18725. * Parses a serialized ground mesh
  18726. * @param parsedMesh the serialized mesh
  18727. * @param scene the scene to create the ground mesh in
  18728. * @returns the created ground mesh
  18729. */
  18730. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18731. }
  18732. }
  18733. declare module BABYLON {
  18734. /**
  18735. * Class used to represent a specific level of detail of a mesh
  18736. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  18737. */
  18738. export class MeshLODLevel {
  18739. /** Defines the distance where this level should star being displayed */
  18740. distance: number;
  18741. /** Defines the mesh to use to render this level */
  18742. mesh: Nullable<Mesh>;
  18743. /**
  18744. * Creates a new LOD level
  18745. * @param distance defines the distance where this level should star being displayed
  18746. * @param mesh defines the mesh to use to render this level
  18747. */
  18748. constructor(
  18749. /** Defines the distance where this level should star being displayed */
  18750. distance: number,
  18751. /** Defines the mesh to use to render this level */
  18752. mesh: Nullable<Mesh>);
  18753. }
  18754. /**
  18755. * @hidden
  18756. **/
  18757. export class _CreationDataStorage {
  18758. closePath?: boolean;
  18759. closeArray?: boolean;
  18760. idx: number[];
  18761. dashSize: number;
  18762. gapSize: number;
  18763. path3D: Path3D;
  18764. pathArray: Vector3[][];
  18765. arc: number;
  18766. radius: number;
  18767. cap: number;
  18768. tessellation: number;
  18769. }
  18770. /**
  18771. * @hidden
  18772. **/ private class _InstanceDataStorage {
  18773. visibleInstances: any;
  18774. renderIdForInstances: number[];
  18775. batchCache: _InstancesBatch;
  18776. instancesBufferSize: number;
  18777. instancesBuffer: Nullable<Buffer>;
  18778. instancesData: Float32Array;
  18779. overridenInstanceCount: number;
  18780. }
  18781. /**
  18782. * @hidden
  18783. **/
  18784. export class _InstancesBatch {
  18785. mustReturn: boolean;
  18786. visibleInstances: Nullable<InstancedMesh[]>[];
  18787. renderSelf: boolean[];
  18788. }
  18789. /**
  18790. * Class used to represent renderable models
  18791. */
  18792. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  18793. /**
  18794. * Mesh side orientation : usually the external or front surface
  18795. */
  18796. static readonly FRONTSIDE: number;
  18797. /**
  18798. * Mesh side orientation : usually the internal or back surface
  18799. */
  18800. static readonly BACKSIDE: number;
  18801. /**
  18802. * Mesh side orientation : both internal and external or front and back surfaces
  18803. */
  18804. static readonly DOUBLESIDE: number;
  18805. /**
  18806. * Mesh side orientation : by default, `FRONTSIDE`
  18807. */
  18808. static readonly DEFAULTSIDE: number;
  18809. /**
  18810. * Mesh cap setting : no cap
  18811. */
  18812. static readonly NO_CAP: number;
  18813. /**
  18814. * Mesh cap setting : one cap at the beginning of the mesh
  18815. */
  18816. static readonly CAP_START: number;
  18817. /**
  18818. * Mesh cap setting : one cap at the end of the mesh
  18819. */
  18820. static readonly CAP_END: number;
  18821. /**
  18822. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  18823. */
  18824. static readonly CAP_ALL: number;
  18825. /**
  18826. * Gets the default side orientation.
  18827. * @param orientation the orientation to value to attempt to get
  18828. * @returns the default orientation
  18829. * @hidden
  18830. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  18831. private _onBeforeRenderObservable;
  18832. private _onBeforeBindObservable;
  18833. private _onAfterRenderObservable;
  18834. private _onBeforeDrawObservable;
  18835. /**
  18836. * An event triggered before rendering the mesh
  18837. */
  18838. readonly onBeforeRenderObservable: Observable<Mesh>;
  18839. /**
  18840. * An event triggered before binding the mesh
  18841. */
  18842. readonly onBeforeBindObservable: Observable<Mesh>;
  18843. /**
  18844. * An event triggered after rendering the mesh
  18845. */
  18846. readonly onAfterRenderObservable: Observable<Mesh>;
  18847. /**
  18848. * An event triggered before drawing the mesh
  18849. */
  18850. readonly onBeforeDrawObservable: Observable<Mesh>;
  18851. private _onBeforeDrawObserver;
  18852. /**
  18853. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  18854. */
  18855. onBeforeDraw: () => void;
  18856. /**
  18857. * Gets the delay loading state of the mesh (when delay loading is turned on)
  18858. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  18859. */
  18860. delayLoadState: number;
  18861. /**
  18862. * Gets the list of instances created from this mesh
  18863. * it is not supposed to be modified manually.
  18864. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  18865. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18866. */
  18867. instances: InstancedMesh[];
  18868. /**
  18869. * Gets the file containing delay loading data for this mesh
  18870. */
  18871. delayLoadingFile: string;
  18872. /** @hidden */ binaryInfo: any;
  18873. private _LODLevels;
  18874. /**
  18875. * User defined function used to change how LOD level selection is done
  18876. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  18877. */
  18878. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  18879. private _morphTargetManager;
  18880. /**
  18881. * Gets or sets the morph target manager
  18882. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18883. */
  18884. morphTargetManager: Nullable<MorphTargetManager>;
  18885. /** @hidden */ creationDataStorage: Nullable<_CreationDataStorage>;
  18886. /** @hidden */ geometry: Nullable<Geometry>;
  18887. /** @hidden */ delayInfo: Array<string>;
  18888. /** @hidden */ delayLoadingFunction: (any: any, mesh: Mesh) => void;
  18889. /** @hidden */ instanceDataStorage: _InstanceDataStorage;
  18890. private _effectiveMaterial;
  18891. /** @hidden */ shouldGenerateFlatShading: boolean;
  18892. private _preActivateId;
  18893. /** @hidden */ originalBuilderSideOrientation: number;
  18894. /**
  18895. * Use this property to change the original side orientation defined at construction time
  18896. */
  18897. overrideMaterialSideOrientation: Nullable<number>;
  18898. private _areNormalsFrozen;
  18899. private _sourcePositions;
  18900. private _sourceNormals;
  18901. private _source;
  18902. private meshMap;
  18903. /**
  18904. * Gets the source mesh (the one used to clone this one from)
  18905. */
  18906. readonly source: Nullable<Mesh>;
  18907. /**
  18908. * Gets or sets a boolean indicating that this mesh does not use index buffer
  18909. */
  18910. isUnIndexed: boolean;
  18911. /**
  18912. * @constructor
  18913. * @param name The value used by scene.getMeshByName() to do a lookup.
  18914. * @param scene The scene to add this mesh to.
  18915. * @param parent The parent of this mesh, if it has one
  18916. * @param source An optional Mesh from which geometry is shared, cloned.
  18917. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18918. * When false, achieved by calling a clone(), also passing False.
  18919. * This will make creation of children, recursive.
  18920. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  18921. */
  18922. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  18923. /**
  18924. * Gets the class name
  18925. * @returns the string "Mesh".
  18926. */
  18927. getClassName(): string;
  18928. /** @hidden */ protected readonly _isMesh: boolean;
  18929. /**
  18930. * Returns a description of this mesh
  18931. * @param fullDetails define if full details about this mesh must be used
  18932. * @returns a descriptive string representing this mesh
  18933. */
  18934. toString(fullDetails?: boolean): string;
  18935. /** @hidden */ unBindEffect(): void;
  18936. /**
  18937. * Gets a boolean indicating if this mesh has LOD
  18938. */
  18939. readonly hasLODLevels: boolean;
  18940. /**
  18941. * Gets the list of MeshLODLevel associated with the current mesh
  18942. * @returns an array of MeshLODLevel
  18943. */
  18944. getLODLevels(): MeshLODLevel[];
  18945. private _sortLODLevels;
  18946. /**
  18947. * Add a mesh as LOD level triggered at the given distance.
  18948. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  18949. * @param distance The distance from the center of the object to show this level
  18950. * @param mesh The mesh to be added as LOD level (can be null)
  18951. * @return This mesh (for chaining)
  18952. */
  18953. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  18954. /**
  18955. * Returns the LOD level mesh at the passed distance or null if not found.
  18956. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  18957. * @param distance The distance from the center of the object to show this level
  18958. * @returns a Mesh or `null`
  18959. */
  18960. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  18961. /**
  18962. * Remove a mesh from the LOD array
  18963. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  18964. * @param mesh defines the mesh to be removed
  18965. * @return This mesh (for chaining)
  18966. */
  18967. removeLODLevel(mesh: Mesh): Mesh;
  18968. /**
  18969. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  18970. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  18971. * @param camera defines the camera to use to compute distance
  18972. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  18973. * @return This mesh (for chaining)
  18974. */
  18975. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  18976. /**
  18977. * Gets the mesh internal Geometry object
  18978. */
  18979. readonly geometry: Nullable<Geometry>;
  18980. /**
  18981. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  18982. * @returns the total number of vertices
  18983. */
  18984. getTotalVertices(): number;
  18985. /**
  18986. * Returns the content of an associated vertex buffer
  18987. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  18988. * - VertexBuffer.PositionKind
  18989. * - VertexBuffer.UVKind
  18990. * - VertexBuffer.UV2Kind
  18991. * - VertexBuffer.UV3Kind
  18992. * - VertexBuffer.UV4Kind
  18993. * - VertexBuffer.UV5Kind
  18994. * - VertexBuffer.UV6Kind
  18995. * - VertexBuffer.ColorKind
  18996. * - VertexBuffer.MatricesIndicesKind
  18997. * - VertexBuffer.MatricesIndicesExtraKind
  18998. * - VertexBuffer.MatricesWeightsKind
  18999. * - VertexBuffer.MatricesWeightsExtraKind
  19000. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  19001. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19002. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19003. */
  19004. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19005. /**
  19006. * Returns the mesh VertexBuffer object from the requested `kind`
  19007. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19008. * - VertexBuffer.PositionKind
  19009. * - VertexBuffer.UVKind
  19010. * - VertexBuffer.UV2Kind
  19011. * - VertexBuffer.UV3Kind
  19012. * - VertexBuffer.UV4Kind
  19013. * - VertexBuffer.UV5Kind
  19014. * - VertexBuffer.UV6Kind
  19015. * - VertexBuffer.ColorKind
  19016. * - VertexBuffer.MatricesIndicesKind
  19017. * - VertexBuffer.MatricesIndicesExtraKind
  19018. * - VertexBuffer.MatricesWeightsKind
  19019. * - VertexBuffer.MatricesWeightsExtraKind
  19020. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19021. */
  19022. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19023. /**
  19024. * Tests if a specific vertex buffer is associated with this mesh
  19025. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19026. * - VertexBuffer.PositionKind
  19027. * - VertexBuffer.UVKind
  19028. * - VertexBuffer.UV2Kind
  19029. * - VertexBuffer.UV3Kind
  19030. * - VertexBuffer.UV4Kind
  19031. * - VertexBuffer.UV5Kind
  19032. * - VertexBuffer.UV6Kind
  19033. * - VertexBuffer.ColorKind
  19034. * - VertexBuffer.MatricesIndicesKind
  19035. * - VertexBuffer.MatricesIndicesExtraKind
  19036. * - VertexBuffer.MatricesWeightsKind
  19037. * - VertexBuffer.MatricesWeightsExtraKind
  19038. * @returns a boolean
  19039. */
  19040. isVerticesDataPresent(kind: string): boolean;
  19041. /**
  19042. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19043. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19044. * - VertexBuffer.PositionKind
  19045. * - VertexBuffer.UVKind
  19046. * - VertexBuffer.UV2Kind
  19047. * - VertexBuffer.UV3Kind
  19048. * - VertexBuffer.UV4Kind
  19049. * - VertexBuffer.UV5Kind
  19050. * - VertexBuffer.UV6Kind
  19051. * - VertexBuffer.ColorKind
  19052. * - VertexBuffer.MatricesIndicesKind
  19053. * - VertexBuffer.MatricesIndicesExtraKind
  19054. * - VertexBuffer.MatricesWeightsKind
  19055. * - VertexBuffer.MatricesWeightsExtraKind
  19056. * @returns a boolean
  19057. */
  19058. isVertexBufferUpdatable(kind: string): boolean;
  19059. /**
  19060. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19061. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19062. * - VertexBuffer.PositionKind
  19063. * - VertexBuffer.UVKind
  19064. * - VertexBuffer.UV2Kind
  19065. * - VertexBuffer.UV3Kind
  19066. * - VertexBuffer.UV4Kind
  19067. * - VertexBuffer.UV5Kind
  19068. * - VertexBuffer.UV6Kind
  19069. * - VertexBuffer.ColorKind
  19070. * - VertexBuffer.MatricesIndicesKind
  19071. * - VertexBuffer.MatricesIndicesExtraKind
  19072. * - VertexBuffer.MatricesWeightsKind
  19073. * - VertexBuffer.MatricesWeightsExtraKind
  19074. * @returns an array of strings
  19075. */
  19076. getVerticesDataKinds(): string[];
  19077. /**
  19078. * Returns a positive integer : the total number of indices in this mesh geometry.
  19079. * @returns the numner of indices or zero if the mesh has no geometry.
  19080. */
  19081. getTotalIndices(): number;
  19082. /**
  19083. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19084. * @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.
  19085. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19086. * @returns the indices array or an empty array if the mesh has no geometry
  19087. */
  19088. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19089. readonly isBlocked: boolean;
  19090. /**
  19091. * Determine if the current mesh is ready to be rendered
  19092. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19093. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19094. * @returns true if all associated assets are ready (material, textures, shaders)
  19095. */
  19096. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19097. /**
  19098. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  19099. */
  19100. readonly areNormalsFrozen: boolean;
  19101. /**
  19102. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  19103. * @returns the current mesh
  19104. */
  19105. freezeNormals(): Mesh;
  19106. /**
  19107. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  19108. * @returns the current mesh
  19109. */
  19110. unfreezeNormals(): Mesh;
  19111. /**
  19112. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19113. */
  19114. overridenInstanceCount: number;
  19115. /** @hidden */ preActivate(): Mesh;
  19116. /** @hidden */ preActivateForIntermediateRendering(renderId: number): Mesh;
  19117. /** @hidden */ registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19118. /**
  19119. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19120. * This means the mesh underlying bounding box and sphere are recomputed.
  19121. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19122. * @returns the current mesh
  19123. */
  19124. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19125. /** @hidden */ createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19126. /**
  19127. * This function will subdivide the mesh into multiple submeshes
  19128. * @param count defines the expected number of submeshes
  19129. */
  19130. subdivide(count: number): void;
  19131. /**
  19132. * Copy a FloatArray into a specific associated vertex buffer
  19133. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19134. * - VertexBuffer.PositionKind
  19135. * - VertexBuffer.UVKind
  19136. * - VertexBuffer.UV2Kind
  19137. * - VertexBuffer.UV3Kind
  19138. * - VertexBuffer.UV4Kind
  19139. * - VertexBuffer.UV5Kind
  19140. * - VertexBuffer.UV6Kind
  19141. * - VertexBuffer.ColorKind
  19142. * - VertexBuffer.MatricesIndicesKind
  19143. * - VertexBuffer.MatricesIndicesExtraKind
  19144. * - VertexBuffer.MatricesWeightsKind
  19145. * - VertexBuffer.MatricesWeightsExtraKind
  19146. * @param data defines the data source
  19147. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19148. * @param stride defines the data stride size (can be null)
  19149. * @returns the current mesh
  19150. */
  19151. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19152. /**
  19153. * Flags an associated vertex buffer as updatable
  19154. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  19155. * - VertexBuffer.PositionKind
  19156. * - VertexBuffer.UVKind
  19157. * - VertexBuffer.UV2Kind
  19158. * - VertexBuffer.UV3Kind
  19159. * - VertexBuffer.UV4Kind
  19160. * - VertexBuffer.UV5Kind
  19161. * - VertexBuffer.UV6Kind
  19162. * - VertexBuffer.ColorKind
  19163. * - VertexBuffer.MatricesIndicesKind
  19164. * - VertexBuffer.MatricesIndicesExtraKind
  19165. * - VertexBuffer.MatricesWeightsKind
  19166. * - VertexBuffer.MatricesWeightsExtraKind
  19167. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19168. */
  19169. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  19170. /**
  19171. * Sets the mesh global Vertex Buffer
  19172. * @param buffer defines the buffer to use
  19173. * @returns the current mesh
  19174. */
  19175. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  19176. /**
  19177. * Update a specific associated vertex buffer
  19178. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19179. * - VertexBuffer.PositionKind
  19180. * - VertexBuffer.UVKind
  19181. * - VertexBuffer.UV2Kind
  19182. * - VertexBuffer.UV3Kind
  19183. * - VertexBuffer.UV4Kind
  19184. * - VertexBuffer.UV5Kind
  19185. * - VertexBuffer.UV6Kind
  19186. * - VertexBuffer.ColorKind
  19187. * - VertexBuffer.MatricesIndicesKind
  19188. * - VertexBuffer.MatricesIndicesExtraKind
  19189. * - VertexBuffer.MatricesWeightsKind
  19190. * - VertexBuffer.MatricesWeightsExtraKind
  19191. * @param data defines the data source
  19192. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  19193. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  19194. * @returns the current mesh
  19195. */
  19196. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19197. /**
  19198. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  19199. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  19200. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  19201. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  19202. * @returns the current mesh
  19203. */
  19204. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  19205. /**
  19206. * Creates a un-shared specific occurence of the geometry for the mesh.
  19207. * @returns the current mesh
  19208. */
  19209. makeGeometryUnique(): Mesh;
  19210. /**
  19211. * Set the index buffer of this mesh
  19212. * @param indices defines the source data
  19213. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  19214. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  19215. * @returns the current mesh
  19216. */
  19217. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  19218. /**
  19219. * Update the current index buffer
  19220. * @param indices defines the source data
  19221. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  19222. * @returns the current mesh
  19223. */
  19224. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  19225. /**
  19226. * Invert the geometry to move from a right handed system to a left handed one.
  19227. * @returns the current mesh
  19228. */
  19229. toLeftHanded(): Mesh;
  19230. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19231. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  19232. /**
  19233. * Registers for this mesh a javascript function called just before the rendering process
  19234. * @param func defines the function to call before rendering this mesh
  19235. * @returns the current mesh
  19236. */
  19237. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19238. /**
  19239. * Disposes a previously registered javascript function called before the rendering
  19240. * @param func defines the function to remove
  19241. * @returns the current mesh
  19242. */
  19243. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19244. /**
  19245. * Registers for this mesh a javascript function called just after the rendering is complete
  19246. * @param func defines the function to call after rendering this mesh
  19247. * @returns the current mesh
  19248. */
  19249. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19250. /**
  19251. * Disposes a previously registered javascript function called after the rendering.
  19252. * @param func defines the function to remove
  19253. * @returns the current mesh
  19254. */
  19255. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19256. /** @hidden */ getInstancesRenderList(subMeshId: number): _InstancesBatch;
  19257. /** @hidden */ renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  19258. /** @hidden */ processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  19259. /**
  19260. * 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
  19261. * @param subMesh defines the subMesh to render
  19262. * @param enableAlphaMode defines if alpha mode can be changed
  19263. * @returns the current mesh
  19264. */
  19265. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  19266. private _onBeforeDraw;
  19267. /**
  19268. * Renormalize the mesh and patch it up if there are no weights
  19269. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  19270. * However in the case of zero weights then we set just a single influence to 1.
  19271. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  19272. */
  19273. cleanMatrixWeights(): void;
  19274. private normalizeSkinFourWeights;
  19275. private normalizeSkinWeightsAndExtra;
  19276. /**
  19277. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  19278. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  19279. * the user know there was an issue with importing the mesh
  19280. * @returns a validation object with skinned, valid and report string
  19281. */
  19282. validateSkinning(): {
  19283. skinned: boolean;
  19284. valid: boolean;
  19285. report: string;
  19286. };
  19287. /** @hidden */ checkDelayState(): Mesh;
  19288. private _queueLoad;
  19289. /**
  19290. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19291. * A mesh is in the frustum if its bounding box intersects the frustum
  19292. * @param frustumPlanes defines the frustum to test
  19293. * @returns true if the mesh is in the frustum planes
  19294. */
  19295. isInFrustum(frustumPlanes: Plane[]): boolean;
  19296. /**
  19297. * Sets the mesh material by the material or multiMaterial `id` property
  19298. * @param id is a string identifying the material or the multiMaterial
  19299. * @returns the current mesh
  19300. */
  19301. setMaterialByID(id: string): Mesh;
  19302. /**
  19303. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  19304. * @returns an array of IAnimatable
  19305. */
  19306. getAnimatables(): IAnimatable[];
  19307. /**
  19308. * Modifies the mesh geometry according to the passed transformation matrix.
  19309. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  19310. * The mesh normals are modified using the same transformation.
  19311. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19312. * @param transform defines the transform matrix to use
  19313. * @see http://doc.babylonjs.com/resources/baking_transformations
  19314. * @returns the current mesh
  19315. */
  19316. bakeTransformIntoVertices(transform: Matrix): Mesh;
  19317. /**
  19318. * Modifies the mesh geometry according to its own current World Matrix.
  19319. * The mesh World Matrix is then reset.
  19320. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  19321. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19322. * @see http://doc.babylonjs.com/resources/baking_transformations
  19323. * @returns the current mesh
  19324. */
  19325. bakeCurrentTransformIntoVertices(): Mesh;
  19326. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  19327. /** @hidden */ resetPointsArrayCache(): Mesh;
  19328. /** @hidden */ generatePointsArray(): boolean;
  19329. /**
  19330. * Returns a new Mesh object generated from the current mesh properties.
  19331. * This method must not get confused with createInstance()
  19332. * @param name is a string, the name given to the new mesh
  19333. * @param newParent can be any Node object (default `null`)
  19334. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  19335. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  19336. * @returns a new mesh
  19337. */
  19338. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  19339. /**
  19340. * Releases resources associated with this mesh.
  19341. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19342. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19343. */
  19344. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19345. /**
  19346. * Modifies the mesh geometry according to a displacement map.
  19347. * 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.
  19348. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19349. * @param url is a string, the URL from the image file is to be downloaded.
  19350. * @param minHeight is the lower limit of the displacement.
  19351. * @param maxHeight is the upper limit of the displacement.
  19352. * @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.
  19353. * @param uvOffset is an optional vector2 used to offset UV.
  19354. * @param uvScale is an optional vector2 used to scale UV.
  19355. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  19356. * @returns the Mesh.
  19357. */
  19358. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19359. /**
  19360. * Modifies the mesh geometry according to a displacementMap buffer.
  19361. * 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.
  19362. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19363. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  19364. * @param heightMapWidth is the width of the buffer image.
  19365. * @param heightMapHeight is the height of the buffer image.
  19366. * @param minHeight is the lower limit of the displacement.
  19367. * @param maxHeight is the upper limit of the displacement.
  19368. * @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.
  19369. * @param uvOffset is an optional vector2 used to offset UV.
  19370. * @param uvScale is an optional vector2 used to scale UV.
  19371. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  19372. * @returns the Mesh.
  19373. */
  19374. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19375. /**
  19376. * Modify the mesh to get a flat shading rendering.
  19377. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  19378. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  19379. * @returns current mesh
  19380. */
  19381. convertToFlatShadedMesh(): Mesh;
  19382. /**
  19383. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  19384. * In other words, more vertices, no more indices and a single bigger VBO.
  19385. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  19386. * @returns current mesh
  19387. */
  19388. convertToUnIndexedMesh(): Mesh;
  19389. /**
  19390. * Inverses facet orientations.
  19391. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  19392. * @param flipNormals will also inverts the normals
  19393. * @returns current mesh
  19394. */
  19395. flipFaces(flipNormals?: boolean): Mesh;
  19396. /** @hidden */ private static _instancedMeshFactory: (name: string, mesh: Mesh) => InstancedMesh;
  19397. /**
  19398. * Creates a new InstancedMesh object from the mesh model.
  19399. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19400. * @param name defines the name of the new instance
  19401. * @returns a new InstancedMesh
  19402. */
  19403. createInstance(name: string): InstancedMesh;
  19404. /**
  19405. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  19406. * After this call, all the mesh instances have the same submeshes than the current mesh.
  19407. * @returns the current mesh
  19408. */
  19409. synchronizeInstances(): Mesh;
  19410. /**
  19411. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  19412. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  19413. * This should be used together with the simplification to avoid disappearing triangles.
  19414. * @param successCallback an optional success callback to be called after the optimization finished.
  19415. * @returns the current mesh
  19416. */
  19417. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  19418. /**
  19419. * Serialize current mesh
  19420. * @param serializationObject defines the object which will receive the serialization data
  19421. */
  19422. serialize(serializationObject: any): void;
  19423. /** @hidden */ syncGeometryWithMorphTargetManager(): void;
  19424. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  19425. /**
  19426. * Returns a new Mesh object parsed from the source provided.
  19427. * @param parsedMesh is the source
  19428. * @param scene defines the hosting scene
  19429. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  19430. * @returns a new Mesh
  19431. */
  19432. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  19433. /**
  19434. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  19435. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19436. * @param name defines the name of the mesh to create
  19437. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  19438. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  19439. * @param closePath creates a seam between the first and the last points of each path of the path array
  19440. * @param offset is taken in account only if the `pathArray` is containing a single path
  19441. * @param scene defines the hosting scene
  19442. * @param updatable defines if the mesh must be flagged as updatable
  19443. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19444. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  19445. * @returns a new Mesh
  19446. */
  19447. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19448. /**
  19449. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  19450. * @param name defines the name of the mesh to create
  19451. * @param radius sets the radius size (float) of the polygon (default 0.5)
  19452. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  19453. * @param scene defines the hosting scene
  19454. * @param updatable defines if the mesh must be flagged as updatable
  19455. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19456. * @returns a new Mesh
  19457. */
  19458. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19459. /**
  19460. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  19461. * @param name defines the name of the mesh to create
  19462. * @param size sets the size (float) of each box side (default 1)
  19463. * @param scene defines the hosting scene
  19464. * @param updatable defines if the mesh must be flagged as updatable
  19465. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19466. * @returns a new Mesh
  19467. */
  19468. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19469. /**
  19470. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  19471. * @param name defines the name of the mesh to create
  19472. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  19473. * @param diameter sets the diameter size (float) of the sphere (default 1)
  19474. * @param scene defines the hosting scene
  19475. * @param updatable defines if the mesh must be flagged as updatable
  19476. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19477. * @returns a new Mesh
  19478. */
  19479. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19480. /**
  19481. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  19482. * @param name defines the name of the mesh to create
  19483. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  19484. * @param diameterTop set the top cap diameter (floats, default 1)
  19485. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  19486. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  19487. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  19488. * @param scene defines the hosting scene
  19489. * @param updatable defines if the mesh must be flagged as updatable
  19490. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19491. * @returns a new Mesh
  19492. */
  19493. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  19494. /**
  19495. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  19496. * @param name defines the name of the mesh to create
  19497. * @param diameter sets the diameter size (float) of the torus (default 1)
  19498. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  19499. * @param tessellation sets the number of torus sides (postive integer, default 16)
  19500. * @param scene defines the hosting scene
  19501. * @param updatable defines if the mesh must be flagged as updatable
  19502. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19503. * @returns a new Mesh
  19504. */
  19505. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19506. /**
  19507. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  19508. * @param name defines the name of the mesh to create
  19509. * @param radius sets the global radius size (float) of the torus knot (default 2)
  19510. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  19511. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  19512. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  19513. * @param p the number of windings on X axis (positive integers, default 2)
  19514. * @param q the number of windings on Y axis (positive integers, default 3)
  19515. * @param scene defines the hosting scene
  19516. * @param updatable defines if the mesh must be flagged as updatable
  19517. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19518. * @returns a new Mesh
  19519. */
  19520. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19521. /**
  19522. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  19523. * @param name defines the name of the mesh to create
  19524. * @param points is an array successive Vector3
  19525. * @param scene defines the hosting scene
  19526. * @param updatable defines if the mesh must be flagged as updatable
  19527. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  19528. * @returns a new Mesh
  19529. */
  19530. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  19531. /**
  19532. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  19533. * @param name defines the name of the mesh to create
  19534. * @param points is an array successive Vector3
  19535. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  19536. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  19537. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  19538. * @param scene defines the hosting scene
  19539. * @param updatable defines if the mesh must be flagged as updatable
  19540. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  19541. * @returns a new Mesh
  19542. */
  19543. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  19544. /**
  19545. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  19546. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  19547. * 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.
  19548. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19549. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19550. * Remember you can only change the shape positions, not their number when updating a polygon.
  19551. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  19552. * @param name defines the name of the mesh to create
  19553. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  19554. * @param scene defines the hosting scene
  19555. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19556. * @param updatable defines if the mesh must be flagged as updatable
  19557. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19558. * @param earcutInjection can be used to inject your own earcut reference
  19559. * @returns a new Mesh
  19560. */
  19561. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  19562. /**
  19563. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  19564. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  19565. * @param name defines the name of the mesh to create
  19566. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  19567. * @param depth defines the height of extrusion
  19568. * @param scene defines the hosting scene
  19569. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19570. * @param updatable defines if the mesh must be flagged as updatable
  19571. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19572. * @param earcutInjection can be used to inject your own earcut reference
  19573. * @returns a new Mesh
  19574. */
  19575. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  19576. /**
  19577. * Creates an extruded shape mesh.
  19578. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  19579. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19580. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19581. * @param name defines the name of the mesh to create
  19582. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  19583. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19584. * @param scale is the value to scale the shape
  19585. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  19586. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  19587. * @param scene defines the hosting scene
  19588. * @param updatable defines if the mesh must be flagged as updatable
  19589. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19590. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  19591. * @returns a new Mesh
  19592. */
  19593. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19594. /**
  19595. * Creates an custom extruded shape mesh.
  19596. * The custom extrusion is a parametric shape.
  19597. * It has no predefined shape. Its final shape will depend on the input parameters.
  19598. * Please consider using the same method from the MeshBuilder class instead
  19599. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19600. * @param name defines the name of the mesh to create
  19601. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  19602. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19603. * @param scaleFunction is a custom Javascript function called on each path point
  19604. * @param rotationFunction is a custom Javascript function called on each path point
  19605. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  19606. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  19607. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  19608. * @param scene defines the hosting scene
  19609. * @param updatable defines if the mesh must be flagged as updatable
  19610. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19611. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  19612. * @returns a new Mesh
  19613. */
  19614. 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;
  19615. /**
  19616. * Creates lathe mesh.
  19617. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  19618. * Please consider using the same method from the MeshBuilder class instead
  19619. * @param name defines the name of the mesh to create
  19620. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  19621. * @param radius is the radius value of the lathe
  19622. * @param tessellation is the side number of the lathe.
  19623. * @param scene defines the hosting scene
  19624. * @param updatable defines if the mesh must be flagged as updatable
  19625. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19626. * @returns a new Mesh
  19627. */
  19628. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19629. /**
  19630. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  19631. * @param name defines the name of the mesh to create
  19632. * @param size sets the size (float) of both sides of the plane at once (default 1)
  19633. * @param scene defines the hosting scene
  19634. * @param updatable defines if the mesh must be flagged as updatable
  19635. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19636. * @returns a new Mesh
  19637. */
  19638. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19639. /**
  19640. * Creates a ground mesh.
  19641. * Please consider using the same method from the MeshBuilder class instead
  19642. * @param name defines the name of the mesh to create
  19643. * @param width set the width of the ground
  19644. * @param height set the height of the ground
  19645. * @param subdivisions sets the number of subdivisions per side
  19646. * @param scene defines the hosting scene
  19647. * @param updatable defines if the mesh must be flagged as updatable
  19648. * @returns a new Mesh
  19649. */
  19650. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  19651. /**
  19652. * Creates a tiled ground mesh.
  19653. * Please consider using the same method from the MeshBuilder class instead
  19654. * @param name defines the name of the mesh to create
  19655. * @param xmin set the ground minimum X coordinate
  19656. * @param zmin set the ground minimum Y coordinate
  19657. * @param xmax set the ground maximum X coordinate
  19658. * @param zmax set the ground maximum Z coordinate
  19659. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  19660. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  19661. * @param scene defines the hosting scene
  19662. * @param updatable defines if the mesh must be flagged as updatable
  19663. * @returns a new Mesh
  19664. */
  19665. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  19666. w: number;
  19667. h: number;
  19668. }, precision: {
  19669. w: number;
  19670. h: number;
  19671. }, scene: Scene, updatable?: boolean): Mesh;
  19672. /**
  19673. * Creates a ground mesh from a height map.
  19674. * Please consider using the same method from the MeshBuilder class instead
  19675. * @see http://doc.babylonjs.com/babylon101/height_map
  19676. * @param name defines the name of the mesh to create
  19677. * @param url sets the URL of the height map image resource
  19678. * @param width set the ground width size
  19679. * @param height set the ground height size
  19680. * @param subdivisions sets the number of subdivision per side
  19681. * @param minHeight is the minimum altitude on the ground
  19682. * @param maxHeight is the maximum altitude on the ground
  19683. * @param scene defines the hosting scene
  19684. * @param updatable defines if the mesh must be flagged as updatable
  19685. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  19686. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  19687. * @returns a new Mesh
  19688. */
  19689. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  19690. /**
  19691. * Creates a tube mesh.
  19692. * The tube is a parametric shape.
  19693. * It has no predefined shape. Its final shape will depend on the input parameters.
  19694. * Please consider using the same method from the MeshBuilder class instead
  19695. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19696. * @param name defines the name of the mesh to create
  19697. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  19698. * @param radius sets the tube radius size
  19699. * @param tessellation is the number of sides on the tubular surface
  19700. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  19701. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  19702. * @param scene defines the hosting scene
  19703. * @param updatable defines if the mesh must be flagged as updatable
  19704. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19705. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  19706. * @returns a new Mesh
  19707. */
  19708. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  19709. (i: number, distance: number): number;
  19710. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19711. /**
  19712. * Creates a polyhedron mesh.
  19713. * Please consider using the same method from the MeshBuilder class instead.
  19714. * * 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
  19715. * * The parameter `size` (positive float, default 1) sets the polygon size
  19716. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  19717. * * 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`
  19718. * * 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
  19719. * * 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)`)
  19720. * * 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 : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  19721. * * 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
  19722. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19723. * * 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
  19724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19725. * @param name defines the name of the mesh to create
  19726. * @param options defines the options used to create the mesh
  19727. * @param scene defines the hosting scene
  19728. * @returns a new Mesh
  19729. */
  19730. static CreatePolyhedron(name: string, options: {
  19731. type?: number;
  19732. size?: number;
  19733. sizeX?: number;
  19734. sizeY?: number;
  19735. sizeZ?: number;
  19736. custom?: any;
  19737. faceUV?: Vector4[];
  19738. faceColors?: Color4[];
  19739. updatable?: boolean;
  19740. sideOrientation?: number;
  19741. }, scene: Scene): Mesh;
  19742. /**
  19743. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  19744. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  19745. * * 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`)
  19746. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  19747. * * 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
  19748. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19749. * * 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
  19750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19751. * @param name defines the name of the mesh
  19752. * @param options defines the options used to create the mesh
  19753. * @param scene defines the hosting scene
  19754. * @returns a new Mesh
  19755. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  19756. */
  19757. static CreateIcoSphere(name: string, options: {
  19758. radius?: number;
  19759. flat?: boolean;
  19760. subdivisions?: number;
  19761. sideOrientation?: number;
  19762. updatable?: boolean;
  19763. }, scene: Scene): Mesh;
  19764. /**
  19765. * Creates a decal mesh.
  19766. * Please consider using the same method from the MeshBuilder class instead.
  19767. * A decal is a mesh usually applied as a model onto the surface of another mesh
  19768. * @param name defines the name of the mesh
  19769. * @param sourceMesh defines the mesh receiving the decal
  19770. * @param position sets the position of the decal in world coordinates
  19771. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  19772. * @param size sets the decal scaling
  19773. * @param angle sets the angle to rotate the decal
  19774. * @returns a new Mesh
  19775. */
  19776. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  19777. /**
  19778. * Prepare internal position array for software CPU skinning
  19779. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  19780. */
  19781. setPositionsForCPUSkinning(): Float32Array;
  19782. /**
  19783. * Prepare internal normal array for software CPU skinning
  19784. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  19785. */
  19786. setNormalsForCPUSkinning(): Float32Array;
  19787. /**
  19788. * Updates the vertex buffer by applying transformation from the bones
  19789. * @param skeleton defines the skeleton to apply to current mesh
  19790. * @returns the current mesh
  19791. */
  19792. applySkeleton(skeleton: Skeleton): Mesh;
  19793. /**
  19794. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  19795. * @param meshes defines the list of meshes to scan
  19796. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  19797. */
  19798. static MinMax(meshes: AbstractMesh[]): {
  19799. min: Vector3;
  19800. max: Vector3;
  19801. };
  19802. /**
  19803. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  19804. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  19805. * @returns a vector3
  19806. */
  19807. static Center(meshesOrMinMaxVector: {
  19808. min: Vector3;
  19809. max: Vector3;
  19810. } | AbstractMesh[]): Vector3;
  19811. /**
  19812. * Merge the array of meshes into a single mesh for performance reasons.
  19813. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  19814. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  19815. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  19816. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  19817. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  19818. * @returns a new mesh
  19819. */
  19820. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  19821. /** @hidden */
  19822. addInstance(instance: InstancedMesh): void;
  19823. /** @hidden */
  19824. removeInstance(instance: InstancedMesh): void;
  19825. }
  19826. }
  19827. declare module BABYLON {
  19828. /**
  19829. * Interface used to define Action
  19830. */
  19831. export interface IAction {
  19832. /**
  19833. * Trigger for the action
  19834. */
  19835. trigger: number;
  19836. /** the trigger, with or without parameters, for the action */
  19837. triggerOptions: any;
  19838. /**
  19839. * Gets the trigger parameters
  19840. * @returns the trigger parameters
  19841. */
  19842. getTriggerParameter(): any;
  19843. /**
  19844. * Internal only - executes current action event
  19845. * @hidden
  19846. */ executeCurrent(evt?: ActionEvent): void;
  19847. /**
  19848. * Serialize placeholder for child classes
  19849. * @param parent of child
  19850. * @returns the serialized object
  19851. */
  19852. serialize(parent: any): any;
  19853. }
  19854. /**
  19855. * The action to be carried out following a trigger
  19856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  19857. */
  19858. export class Action implements IAction {
  19859. /** the trigger, with or without parameters, for the action */
  19860. triggerOptions: any;
  19861. /**
  19862. * Trigger for the action
  19863. */
  19864. trigger: number;
  19865. /**
  19866. * Internal only - manager for action
  19867. * @hidden
  19868. */ actionManager: ActionManager;
  19869. private _nextActiveAction;
  19870. private _child;
  19871. private _condition?;
  19872. private _triggerParameter;
  19873. /**
  19874. * An event triggered prior to action being executed.
  19875. */
  19876. onBeforeExecuteObservable: Observable<Action>;
  19877. /**
  19878. * Creates a new Action
  19879. * @param triggerOptions the trigger, with or without parameters, for the action
  19880. * @param condition an optional determinant of action
  19881. */
  19882. constructor(
  19883. /** the trigger, with or without parameters, for the action */
  19884. triggerOptions: any, condition?: Condition);
  19885. /**
  19886. * Internal only
  19887. * @hidden
  19888. */ prepare(): void;
  19889. /**
  19890. * Gets the trigger parameters
  19891. * @returns the trigger parameters
  19892. */
  19893. getTriggerParameter(): any;
  19894. /**
  19895. * Internal only - executes current action event
  19896. * @hidden
  19897. */ executeCurrent(evt?: ActionEvent): void;
  19898. /**
  19899. * Execute placeholder for child classes
  19900. * @param evt optional action event
  19901. */
  19902. execute(evt?: ActionEvent): void;
  19903. /**
  19904. * Skips to next active action
  19905. */
  19906. skipToNextActiveAction(): void;
  19907. /**
  19908. * Adds action to chain of actions, may be a DoNothingAction
  19909. * @param action defines the next action to execute
  19910. * @returns The action passed in
  19911. * @see https://www.babylonjs-playground.com/#1T30HR#0
  19912. */
  19913. then(action: Action): Action;
  19914. /**
  19915. * Internal only
  19916. * @hidden
  19917. */ getProperty(propertyPath: string): string;
  19918. /**
  19919. * Internal only
  19920. * @hidden
  19921. */ getEffectiveTarget(target: any, propertyPath: string): any;
  19922. /**
  19923. * Serialize placeholder for child classes
  19924. * @param parent of child
  19925. * @returns the serialized object
  19926. */
  19927. serialize(parent: any): any;
  19928. /**
  19929. * Internal only called by serialize
  19930. * @hidden
  19931. */
  19932. protected _serialize(serializedAction: any, parent?: any): any;
  19933. /**
  19934. * Internal only
  19935. * @hidden
  19936. */ private static _SerializeValueAsString: (value: any) => string;
  19937. /**
  19938. * Internal only
  19939. * @hidden
  19940. */ private static _GetTargetProperty: (target: Scene | Node) => {
  19941. name: string;
  19942. targetType: string;
  19943. value: string;
  19944. };
  19945. }
  19946. }
  19947. declare module BABYLON {
  19948. /**
  19949. * A Condition applied to an Action
  19950. */
  19951. export class Condition {
  19952. /**
  19953. * Internal only - manager for action
  19954. * @hidden
  19955. */ actionManager: ActionManager;
  19956. /**
  19957. * Internal only
  19958. * @hidden
  19959. */ evaluationId: number;
  19960. /**
  19961. * Internal only
  19962. * @hidden
  19963. */ currentResult: boolean;
  19964. /**
  19965. * Creates a new Condition
  19966. * @param actionManager the manager of the action the condition is applied to
  19967. */
  19968. constructor(actionManager: ActionManager);
  19969. /**
  19970. * Check if the current condition is valid
  19971. * @returns a boolean
  19972. */
  19973. isValid(): boolean;
  19974. /**
  19975. * Internal only
  19976. * @hidden
  19977. */ getProperty(propertyPath: string): string;
  19978. /**
  19979. * Internal only
  19980. * @hidden
  19981. */ getEffectiveTarget(target: any, propertyPath: string): any;
  19982. /**
  19983. * Serialize placeholder for child classes
  19984. * @returns the serialized object
  19985. */
  19986. serialize(): any;
  19987. /**
  19988. * Internal only
  19989. * @hidden
  19990. */
  19991. protected _serialize(serializedCondition: any): any;
  19992. }
  19993. /**
  19994. * Defines specific conditional operators as extensions of Condition
  19995. */
  19996. export class ValueCondition extends Condition {
  19997. /** path to specify the property of the target the conditional operator uses */
  19998. propertyPath: string;
  19999. /** the value compared by the conditional operator against the current value of the property */
  20000. value: any;
  20001. /** the conditional operator, default ValueCondition.IsEqual */
  20002. operator: number;
  20003. /**
  20004. * Internal only
  20005. * @hidden
  20006. */
  20007. private static _IsEqual;
  20008. /**
  20009. * Internal only
  20010. * @hidden
  20011. */
  20012. private static _IsDifferent;
  20013. /**
  20014. * Internal only
  20015. * @hidden
  20016. */
  20017. private static _IsGreater;
  20018. /**
  20019. * Internal only
  20020. * @hidden
  20021. */
  20022. private static _IsLesser;
  20023. /**
  20024. * returns the number for IsEqual
  20025. */
  20026. static readonly IsEqual: number;
  20027. /**
  20028. * Returns the number for IsDifferent
  20029. */
  20030. static readonly IsDifferent: number;
  20031. /**
  20032. * Returns the number for IsGreater
  20033. */
  20034. static readonly IsGreater: number;
  20035. /**
  20036. * Returns the number for IsLesser
  20037. */
  20038. static readonly IsLesser: number;
  20039. /**
  20040. * Internal only The action manager for the condition
  20041. * @hidden
  20042. */ actionManager: ActionManager;
  20043. /**
  20044. * Internal only
  20045. * @hidden
  20046. */
  20047. private _target;
  20048. /**
  20049. * Internal only
  20050. * @hidden
  20051. */
  20052. private _effectiveTarget;
  20053. /**
  20054. * Internal only
  20055. * @hidden
  20056. */
  20057. private _property;
  20058. /**
  20059. * Creates a new ValueCondition
  20060. * @param actionManager manager for the action the condition applies to
  20061. * @param target for the action
  20062. * @param propertyPath path to specify the property of the target the conditional operator uses
  20063. * @param value the value compared by the conditional operator against the current value of the property
  20064. * @param operator the conditional operator, default ValueCondition.IsEqual
  20065. */
  20066. constructor(actionManager: ActionManager, target: any,
  20067. /** path to specify the property of the target the conditional operator uses */
  20068. propertyPath: string,
  20069. /** the value compared by the conditional operator against the current value of the property */
  20070. value: any,
  20071. /** the conditional operator, default ValueCondition.IsEqual */
  20072. operator?: number);
  20073. /**
  20074. * Compares the given value with the property value for the specified conditional operator
  20075. * @returns the result of the comparison
  20076. */
  20077. isValid(): boolean;
  20078. /**
  20079. * Serialize the ValueCondition into a JSON compatible object
  20080. * @returns serialization object
  20081. */
  20082. serialize(): any;
  20083. /**
  20084. * Gets the name of the conditional operator for the ValueCondition
  20085. * @param operator the conditional operator
  20086. * @returns the name
  20087. */
  20088. static GetOperatorName(operator: number): string;
  20089. }
  20090. /**
  20091. * Defines a predicate condition as an extension of Condition
  20092. */
  20093. export class PredicateCondition extends Condition {
  20094. /** defines the predicate function used to validate the condition */
  20095. predicate: () => boolean;
  20096. /**
  20097. * Internal only - manager for action
  20098. * @hidden
  20099. */ actionManager: ActionManager;
  20100. /**
  20101. * Creates a new PredicateCondition
  20102. * @param actionManager manager for the action the condition applies to
  20103. * @param predicate defines the predicate function used to validate the condition
  20104. */
  20105. constructor(actionManager: ActionManager,
  20106. /** defines the predicate function used to validate the condition */
  20107. predicate: () => boolean);
  20108. /**
  20109. * @returns the validity of the predicate condition
  20110. */
  20111. isValid(): boolean;
  20112. }
  20113. /**
  20114. * Defines a state condition as an extension of Condition
  20115. */
  20116. export class StateCondition extends Condition {
  20117. /** Value to compare with target state */
  20118. value: string;
  20119. /**
  20120. * Internal only - manager for action
  20121. * @hidden
  20122. */ actionManager: ActionManager;
  20123. /**
  20124. * Internal only
  20125. * @hidden
  20126. */
  20127. private _target;
  20128. /**
  20129. * Creates a new StateCondition
  20130. * @param actionManager manager for the action the condition applies to
  20131. * @param target of the condition
  20132. * @param value to compare with target state
  20133. */
  20134. constructor(actionManager: ActionManager, target: any,
  20135. /** Value to compare with target state */
  20136. value: string);
  20137. /**
  20138. * Gets a boolean indicating if the current condition is met
  20139. * @returns the validity of the state
  20140. */
  20141. isValid(): boolean;
  20142. /**
  20143. * Serialize the StateCondition into a JSON compatible object
  20144. * @returns serialization object
  20145. */
  20146. serialize(): any;
  20147. }
  20148. }
  20149. declare module BABYLON {
  20150. /**
  20151. * This defines an action responsible to toggle a boolean once triggered.
  20152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20153. */
  20154. export class SwitchBooleanAction extends Action {
  20155. /**
  20156. * The path to the boolean property in the target object
  20157. */
  20158. propertyPath: string;
  20159. private _target;
  20160. private _effectiveTarget;
  20161. private _property;
  20162. /**
  20163. * Instantiate the action
  20164. * @param triggerOptions defines the trigger options
  20165. * @param target defines the object containing the boolean
  20166. * @param propertyPath defines the path to the boolean property in the target object
  20167. * @param condition defines the trigger related conditions
  20168. */
  20169. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  20170. /** @hidden */ prepare(): void;
  20171. /**
  20172. * Execute the action toggle the boolean value.
  20173. */
  20174. execute(): void;
  20175. /**
  20176. * Serializes the actions and its related information.
  20177. * @param parent defines the object to serialize in
  20178. * @returns the serialized object
  20179. */
  20180. serialize(parent: any): any;
  20181. }
  20182. /**
  20183. * This defines an action responsible to set a the state field of the target
  20184. * to a desired value once triggered.
  20185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20186. */
  20187. export class SetStateAction extends Action {
  20188. /**
  20189. * The value to store in the state field.
  20190. */
  20191. value: string;
  20192. private _target;
  20193. /**
  20194. * Instantiate the action
  20195. * @param triggerOptions defines the trigger options
  20196. * @param target defines the object containing the state property
  20197. * @param value defines the value to store in the state field
  20198. * @param condition defines the trigger related conditions
  20199. */
  20200. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  20201. /**
  20202. * Execute the action and store the value on the target state property.
  20203. */
  20204. execute(): void;
  20205. /**
  20206. * Serializes the actions and its related information.
  20207. * @param parent defines the object to serialize in
  20208. * @returns the serialized object
  20209. */
  20210. serialize(parent: any): any;
  20211. }
  20212. /**
  20213. * This defines an action responsible to set a property of the target
  20214. * to a desired value once triggered.
  20215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20216. */
  20217. export class SetValueAction extends Action {
  20218. /**
  20219. * The path of the property to set in the target.
  20220. */
  20221. propertyPath: string;
  20222. /**
  20223. * The value to set in the property
  20224. */
  20225. value: any;
  20226. private _target;
  20227. private _effectiveTarget;
  20228. private _property;
  20229. /**
  20230. * Instantiate the action
  20231. * @param triggerOptions defines the trigger options
  20232. * @param target defines the object containing the property
  20233. * @param propertyPath defines the path of the property to set in the target
  20234. * @param value defines the value to set in the property
  20235. * @param condition defines the trigger related conditions
  20236. */
  20237. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  20238. /** @hidden */ prepare(): void;
  20239. /**
  20240. * Execute the action and set the targetted property to the desired value.
  20241. */
  20242. execute(): void;
  20243. /**
  20244. * Serializes the actions and its related information.
  20245. * @param parent defines the object to serialize in
  20246. * @returns the serialized object
  20247. */
  20248. serialize(parent: any): any;
  20249. }
  20250. /**
  20251. * This defines an action responsible to increment the target value
  20252. * to a desired value once triggered.
  20253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20254. */
  20255. export class IncrementValueAction extends Action {
  20256. /**
  20257. * The path of the property to increment in the target.
  20258. */
  20259. propertyPath: string;
  20260. /**
  20261. * The value we should increment the property by.
  20262. */
  20263. value: any;
  20264. private _target;
  20265. private _effectiveTarget;
  20266. private _property;
  20267. /**
  20268. * Instantiate the action
  20269. * @param triggerOptions defines the trigger options
  20270. * @param target defines the object containing the property
  20271. * @param propertyPath defines the path of the property to increment in the target
  20272. * @param value defines the value value we should increment the property by
  20273. * @param condition defines the trigger related conditions
  20274. */
  20275. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  20276. /** @hidden */ prepare(): void;
  20277. /**
  20278. * Execute the action and increment the target of the value amount.
  20279. */
  20280. execute(): void;
  20281. /**
  20282. * Serializes the actions and its related information.
  20283. * @param parent defines the object to serialize in
  20284. * @returns the serialized object
  20285. */
  20286. serialize(parent: any): any;
  20287. }
  20288. /**
  20289. * This defines an action responsible to start an animation once triggered.
  20290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20291. */
  20292. export class PlayAnimationAction extends Action {
  20293. /**
  20294. * Where the animation should start (animation frame)
  20295. */
  20296. from: number;
  20297. /**
  20298. * Where the animation should stop (animation frame)
  20299. */
  20300. to: number;
  20301. /**
  20302. * Define if the animation should loop or stop after the first play.
  20303. */
  20304. loop?: boolean;
  20305. private _target;
  20306. /**
  20307. * Instantiate the action
  20308. * @param triggerOptions defines the trigger options
  20309. * @param target defines the target animation or animation name
  20310. * @param from defines from where the animation should start (animation frame)
  20311. * @param end defines where the animation should stop (animation frame)
  20312. * @param loop defines if the animation should loop or stop after the first play
  20313. * @param condition defines the trigger related conditions
  20314. */
  20315. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  20316. /** @hidden */ prepare(): void;
  20317. /**
  20318. * Execute the action and play the animation.
  20319. */
  20320. execute(): void;
  20321. /**
  20322. * Serializes the actions and its related information.
  20323. * @param parent defines the object to serialize in
  20324. * @returns the serialized object
  20325. */
  20326. serialize(parent: any): any;
  20327. }
  20328. /**
  20329. * This defines an action responsible to stop an animation once triggered.
  20330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20331. */
  20332. export class StopAnimationAction extends Action {
  20333. private _target;
  20334. /**
  20335. * Instantiate the action
  20336. * @param triggerOptions defines the trigger options
  20337. * @param target defines the target animation or animation name
  20338. * @param condition defines the trigger related conditions
  20339. */
  20340. constructor(triggerOptions: any, target: any, condition?: Condition);
  20341. /** @hidden */ prepare(): void;
  20342. /**
  20343. * Execute the action and stop the animation.
  20344. */
  20345. execute(): void;
  20346. /**
  20347. * Serializes the actions and its related information.
  20348. * @param parent defines the object to serialize in
  20349. * @returns the serialized object
  20350. */
  20351. serialize(parent: any): any;
  20352. }
  20353. /**
  20354. * This defines an action responsible that does nothing once triggered.
  20355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20356. */
  20357. export class DoNothingAction extends Action {
  20358. /**
  20359. * Instantiate the action
  20360. * @param triggerOptions defines the trigger options
  20361. * @param condition defines the trigger related conditions
  20362. */
  20363. constructor(triggerOptions?: any, condition?: Condition);
  20364. /**
  20365. * Execute the action and do nothing.
  20366. */
  20367. execute(): void;
  20368. /**
  20369. * Serializes the actions and its related information.
  20370. * @param parent defines the object to serialize in
  20371. * @returns the serialized object
  20372. */
  20373. serialize(parent: any): any;
  20374. }
  20375. /**
  20376. * This defines an action responsible to trigger several actions once triggered.
  20377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20378. */
  20379. export class CombineAction extends Action {
  20380. /**
  20381. * The list of aggregated animations to run.
  20382. */
  20383. children: Action[];
  20384. /**
  20385. * Instantiate the action
  20386. * @param triggerOptions defines the trigger options
  20387. * @param children defines the list of aggregated animations to run
  20388. * @param condition defines the trigger related conditions
  20389. */
  20390. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  20391. /** @hidden */ prepare(): void;
  20392. /**
  20393. * Execute the action and executes all the aggregated actions.
  20394. */
  20395. execute(evt: ActionEvent): void;
  20396. /**
  20397. * Serializes the actions and its related information.
  20398. * @param parent defines the object to serialize in
  20399. * @returns the serialized object
  20400. */
  20401. serialize(parent: any): any;
  20402. }
  20403. /**
  20404. * This defines an action responsible to run code (external event) once triggered.
  20405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20406. */
  20407. export class ExecuteCodeAction extends Action {
  20408. /**
  20409. * The callback function to run.
  20410. */
  20411. func: (evt: ActionEvent) => void;
  20412. /**
  20413. * Instantiate the action
  20414. * @param triggerOptions defines the trigger options
  20415. * @param func defines the callback function to run
  20416. * @param condition defines the trigger related conditions
  20417. */
  20418. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  20419. /**
  20420. * Execute the action and run the attached code.
  20421. */
  20422. execute(evt: ActionEvent): void;
  20423. }
  20424. /**
  20425. * This defines an action responsible to set the parent property of the target once triggered.
  20426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20427. */
  20428. export class SetParentAction extends Action {
  20429. private _parent;
  20430. private _target;
  20431. /**
  20432. * Instantiate the action
  20433. * @param triggerOptions defines the trigger options
  20434. * @param target defines the target containing the parent property
  20435. * @param parent defines from where the animation should start (animation frame)
  20436. * @param condition defines the trigger related conditions
  20437. */
  20438. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  20439. /** @hidden */ prepare(): void;
  20440. /**
  20441. * Execute the action and set the parent property.
  20442. */
  20443. execute(): void;
  20444. /**
  20445. * Serializes the actions and its related information.
  20446. * @param parent defines the object to serialize in
  20447. * @returns the serialized object
  20448. */
  20449. serialize(parent: any): any;
  20450. }
  20451. }
  20452. declare module BABYLON {
  20453. /**
  20454. * Abstract class used to decouple action Manager from scene and meshes.
  20455. * Do not instantiate.
  20456. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20457. */
  20458. export abstract class AbstractActionManager implements IDisposable {
  20459. /** Gets the list of active triggers */
  20460. static Triggers: {
  20461. [key: string]: number;
  20462. };
  20463. /** Gets the cursor to use when hovering items */
  20464. hoverCursor: string;
  20465. /** Gets the list of actions */
  20466. actions: IAction[];
  20467. /**
  20468. * Releases all associated resources
  20469. */
  20470. abstract dispose(): void;
  20471. /**
  20472. * Does this action manager has pointer triggers
  20473. */
  20474. abstract readonly hasPointerTriggers: boolean;
  20475. /**
  20476. * Does this action manager has pick triggers
  20477. */
  20478. abstract readonly hasPickTriggers: boolean;
  20479. /**
  20480. * Process a specific trigger
  20481. * @param trigger defines the trigger to process
  20482. * @param evt defines the event details to be processed
  20483. */
  20484. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  20485. /**
  20486. * Does this action manager handles actions of any of the given triggers
  20487. * @param triggers defines the triggers to be tested
  20488. * @return a boolean indicating whether one (or more) of the triggers is handled
  20489. */
  20490. abstract hasSpecificTriggers(triggers: number[]): boolean;
  20491. /**
  20492. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  20493. * speed.
  20494. * @param triggerA defines the trigger to be tested
  20495. * @param triggerB defines the trigger to be tested
  20496. * @return a boolean indicating whether one (or more) of the triggers is handled
  20497. */
  20498. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  20499. /**
  20500. * Does this action manager handles actions of a given trigger
  20501. * @param trigger defines the trigger to be tested
  20502. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  20503. * @return whether the trigger is handled
  20504. */
  20505. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  20506. /**
  20507. * Serialize this manager to a JSON object
  20508. * @param name defines the property name to store this manager
  20509. * @returns a JSON representation of this manager
  20510. */
  20511. abstract serialize(name: string): any;
  20512. /**
  20513. * Does exist one action manager with at least one trigger
  20514. **/
  20515. static readonly HasTriggers: boolean;
  20516. /**
  20517. * Does exist one action manager with at least one pick trigger
  20518. **/
  20519. static readonly HasPickTriggers: boolean;
  20520. /**
  20521. * Does exist one action manager that handles actions of a given trigger
  20522. * @param trigger defines the trigger to be tested
  20523. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  20524. **/
  20525. static HasSpecificTrigger(trigger: number): boolean;
  20526. }
  20527. }
  20528. declare module BABYLON {
  20529. /**
  20530. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  20531. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  20532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20533. */
  20534. export class ActionManager extends AbstractActionManager {
  20535. /**
  20536. * Nothing
  20537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20538. */
  20539. static readonly NothingTrigger: number;
  20540. /**
  20541. * On pick
  20542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20543. */
  20544. static readonly OnPickTrigger: number;
  20545. /**
  20546. * On left pick
  20547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20548. */
  20549. static readonly OnLeftPickTrigger: number;
  20550. /**
  20551. * On right pick
  20552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20553. */
  20554. static readonly OnRightPickTrigger: number;
  20555. /**
  20556. * On center pick
  20557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20558. */
  20559. static readonly OnCenterPickTrigger: number;
  20560. /**
  20561. * On pick down
  20562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20563. */
  20564. static readonly OnPickDownTrigger: number;
  20565. /**
  20566. * On double pick
  20567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20568. */
  20569. static readonly OnDoublePickTrigger: number;
  20570. /**
  20571. * On pick up
  20572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20573. */
  20574. static readonly OnPickUpTrigger: number;
  20575. /**
  20576. * On pick out.
  20577. * This trigger will only be raised if you also declared a OnPickDown
  20578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20579. */
  20580. static readonly OnPickOutTrigger: number;
  20581. /**
  20582. * On long press
  20583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20584. */
  20585. static readonly OnLongPressTrigger: number;
  20586. /**
  20587. * On pointer over
  20588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20589. */
  20590. static readonly OnPointerOverTrigger: number;
  20591. /**
  20592. * On pointer out
  20593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20594. */
  20595. static readonly OnPointerOutTrigger: number;
  20596. /**
  20597. * On every frame
  20598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20599. */
  20600. static readonly OnEveryFrameTrigger: number;
  20601. /**
  20602. * On intersection enter
  20603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20604. */
  20605. static readonly OnIntersectionEnterTrigger: number;
  20606. /**
  20607. * On intersection exit
  20608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20609. */
  20610. static readonly OnIntersectionExitTrigger: number;
  20611. /**
  20612. * On key down
  20613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20614. */
  20615. static readonly OnKeyDownTrigger: number;
  20616. /**
  20617. * On key up
  20618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20619. */
  20620. static readonly OnKeyUpTrigger: number;
  20621. private _scene;
  20622. /**
  20623. * Creates a new action manager
  20624. * @param scene defines the hosting scene
  20625. */
  20626. constructor(scene: Scene);
  20627. /**
  20628. * Releases all associated resources
  20629. */
  20630. dispose(): void;
  20631. /**
  20632. * Gets hosting scene
  20633. * @returns the hosting scene
  20634. */
  20635. getScene(): Scene;
  20636. /**
  20637. * Does this action manager handles actions of any of the given triggers
  20638. * @param triggers defines the triggers to be tested
  20639. * @return a boolean indicating whether one (or more) of the triggers is handled
  20640. */
  20641. hasSpecificTriggers(triggers: number[]): boolean;
  20642. /**
  20643. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  20644. * speed.
  20645. * @param triggerA defines the trigger to be tested
  20646. * @param triggerB defines the trigger to be tested
  20647. * @return a boolean indicating whether one (or more) of the triggers is handled
  20648. */
  20649. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  20650. /**
  20651. * Does this action manager handles actions of a given trigger
  20652. * @param trigger defines the trigger to be tested
  20653. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  20654. * @return whether the trigger is handled
  20655. */
  20656. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  20657. /**
  20658. * Does this action manager has pointer triggers
  20659. */
  20660. readonly hasPointerTriggers: boolean;
  20661. /**
  20662. * Does this action manager has pick triggers
  20663. */
  20664. readonly hasPickTriggers: boolean;
  20665. /**
  20666. * Registers an action to this action manager
  20667. * @param action defines the action to be registered
  20668. * @return the action amended (prepared) after registration
  20669. */
  20670. registerAction(action: Action): Nullable<Action>;
  20671. /**
  20672. * Unregisters an action to this action manager
  20673. * @param action defines the action to be unregistered
  20674. * @return a boolean indicating whether the action has been unregistered
  20675. */
  20676. unregisterAction(action: Action): Boolean;
  20677. /**
  20678. * Process a specific trigger
  20679. * @param trigger defines the trigger to process
  20680. * @param evt defines the event details to be processed
  20681. */
  20682. processTrigger(trigger: number, evt?: IActionEvent): void;
  20683. /** @hidden */ getEffectiveTarget(target: any, propertyPath: string): any;
  20684. /** @hidden */ getProperty(propertyPath: string): string;
  20685. /**
  20686. * Serialize this manager to a JSON object
  20687. * @param name defines the property name to store this manager
  20688. * @returns a JSON representation of this manager
  20689. */
  20690. serialize(name: string): any;
  20691. /**
  20692. * Creates a new ActionManager from a JSON data
  20693. * @param parsedActions defines the JSON data to read from
  20694. * @param object defines the hosting mesh
  20695. * @param scene defines the hosting scene
  20696. */
  20697. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  20698. /**
  20699. * Get a trigger name by index
  20700. * @param trigger defines the trigger index
  20701. * @returns a trigger name
  20702. */
  20703. static GetTriggerName(trigger: number): string;
  20704. }
  20705. }
  20706. declare module BABYLON {
  20707. /**
  20708. * Class used to represent a sprite
  20709. * @see http://doc.babylonjs.com/babylon101/sprites
  20710. */
  20711. export class Sprite {
  20712. /** defines the name */
  20713. name: string;
  20714. /** Gets or sets the current world position */
  20715. position: Vector3;
  20716. /** Gets or sets the main color */
  20717. color: Color4;
  20718. /** Gets or sets the width */
  20719. width: number;
  20720. /** Gets or sets the height */
  20721. height: number;
  20722. /** Gets or sets rotation angle */
  20723. angle: number;
  20724. /** Gets or sets the cell index in the sprite sheet */
  20725. cellIndex: number;
  20726. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  20727. invertU: number;
  20728. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  20729. invertV: number;
  20730. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  20731. disposeWhenFinishedAnimating: boolean;
  20732. /** Gets the list of attached animations */
  20733. animations: Animation[];
  20734. /** Gets or sets a boolean indicating if the sprite can be picked */
  20735. isPickable: boolean;
  20736. /**
  20737. * Gets or sets the associated action manager
  20738. */
  20739. actionManager: Nullable<ActionManager>;
  20740. private _animationStarted;
  20741. private _loopAnimation;
  20742. private _fromIndex;
  20743. private _toIndex;
  20744. private _delay;
  20745. private _direction;
  20746. private _manager;
  20747. private _time;
  20748. private _onAnimationEnd;
  20749. /**
  20750. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  20751. */
  20752. isVisible: boolean;
  20753. /**
  20754. * Gets or sets the sprite size
  20755. */
  20756. size: number;
  20757. /**
  20758. * Creates a new Sprite
  20759. * @param name defines the name
  20760. * @param manager defines the manager
  20761. */
  20762. constructor(
  20763. /** defines the name */
  20764. name: string, manager: ISpriteManager);
  20765. /**
  20766. * Starts an animation
  20767. * @param from defines the initial key
  20768. * @param to defines the end key
  20769. * @param loop defines if the animation must loop
  20770. * @param delay defines the start delay (in ms)
  20771. * @param onAnimationEnd defines a callback to call when animation ends
  20772. */
  20773. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  20774. /** Stops current animation (if any) */
  20775. stopAnimation(): void;
  20776. /** @hidden */ animate(deltaTime: number): void;
  20777. /** Release associated resources */
  20778. dispose(): void;
  20779. }
  20780. }
  20781. declare module BABYLON {
  20782. /**
  20783. * Information about the result of picking within a scene
  20784. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  20785. */
  20786. export class PickingInfo {
  20787. /**
  20788. * If the pick collided with an object
  20789. */
  20790. hit: boolean;
  20791. /**
  20792. * Distance away where the pick collided
  20793. */
  20794. distance: number;
  20795. /**
  20796. * The location of pick collision
  20797. */
  20798. pickedPoint: Nullable<Vector3>;
  20799. /**
  20800. * The mesh corresponding the the pick collision
  20801. */
  20802. pickedMesh: Nullable<AbstractMesh>;
  20803. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  20804. bu: number;
  20805. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  20806. bv: number;
  20807. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  20808. faceId: number;
  20809. /** Id of the the submesh that was picked */
  20810. subMeshId: number;
  20811. /** If a sprite was picked, this will be the sprite the pick collided with */
  20812. pickedSprite: Nullable<Sprite>;
  20813. /**
  20814. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  20815. */
  20816. originMesh: Nullable<AbstractMesh>;
  20817. /**
  20818. * The ray that was used to perform the picking.
  20819. */
  20820. ray: Nullable<Ray>;
  20821. /**
  20822. * Gets the normal correspodning to the face the pick collided with
  20823. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  20824. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  20825. * @returns The normal correspodning to the face the pick collided with
  20826. */
  20827. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  20828. /**
  20829. * Gets the texture coordinates of where the pick occured
  20830. * @returns the vector containing the coordnates of the texture
  20831. */
  20832. getTextureCoordinates(): Nullable<Vector2>;
  20833. }
  20834. }
  20835. declare module BABYLON {
  20836. /**
  20837. * Class representing a ray with position and direction
  20838. */
  20839. export class Ray {
  20840. /** origin point */
  20841. origin: Vector3;
  20842. /** direction */
  20843. direction: Vector3;
  20844. /** length of the ray */
  20845. length: number;
  20846. private static readonly TmpVector3;
  20847. private _tmpRay;
  20848. /**
  20849. * Creates a new ray
  20850. * @param origin origin point
  20851. * @param direction direction
  20852. * @param length length of the ray
  20853. */
  20854. constructor(
  20855. /** origin point */
  20856. origin: Vector3,
  20857. /** direction */
  20858. direction: Vector3,
  20859. /** length of the ray */
  20860. length?: number);
  20861. /**
  20862. * Checks if the ray intersects a box
  20863. * @param minimum bound of the box
  20864. * @param maximum bound of the box
  20865. * @param intersectionTreshold extra extend to be added to the box in all direction
  20866. * @returns if the box was hit
  20867. */
  20868. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  20869. /**
  20870. * Checks if the ray intersects a box
  20871. * @param box the bounding box to check
  20872. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  20873. * @returns if the box was hit
  20874. */
  20875. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  20876. /**
  20877. * If the ray hits a sphere
  20878. * @param sphere the bounding sphere to check
  20879. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  20880. * @returns true if it hits the sphere
  20881. */
  20882. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  20883. /**
  20884. * If the ray hits a triange
  20885. * @param vertex0 triangle vertex
  20886. * @param vertex1 triangle vertex
  20887. * @param vertex2 triangle vertex
  20888. * @returns intersection information if hit
  20889. */
  20890. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  20891. /**
  20892. * Checks if ray intersects a plane
  20893. * @param plane the plane to check
  20894. * @returns the distance away it was hit
  20895. */
  20896. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  20897. /**
  20898. * Checks if ray intersects a mesh
  20899. * @param mesh the mesh to check
  20900. * @param fastCheck if only the bounding box should checked
  20901. * @returns picking info of the intersecton
  20902. */
  20903. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  20904. /**
  20905. * Checks if ray intersects a mesh
  20906. * @param meshes the meshes to check
  20907. * @param fastCheck if only the bounding box should checked
  20908. * @param results array to store result in
  20909. * @returns Array of picking infos
  20910. */
  20911. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  20912. private _comparePickingInfo;
  20913. private static smallnum;
  20914. private static rayl;
  20915. /**
  20916. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  20917. * @param sega the first point of the segment to test the intersection against
  20918. * @param segb the second point of the segment to test the intersection against
  20919. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  20920. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  20921. */
  20922. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  20923. /**
  20924. * Update the ray from viewport position
  20925. * @param x position
  20926. * @param y y position
  20927. * @param viewportWidth viewport width
  20928. * @param viewportHeight viewport height
  20929. * @param world world matrix
  20930. * @param view view matrix
  20931. * @param projection projection matrix
  20932. * @returns this ray updated
  20933. */
  20934. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  20935. /**
  20936. * Creates a ray with origin and direction of 0,0,0
  20937. * @returns the new ray
  20938. */
  20939. static Zero(): Ray;
  20940. /**
  20941. * Creates a new ray from screen space and viewport
  20942. * @param x position
  20943. * @param y y position
  20944. * @param viewportWidth viewport width
  20945. * @param viewportHeight viewport height
  20946. * @param world world matrix
  20947. * @param view view matrix
  20948. * @param projection projection matrix
  20949. * @returns new ray
  20950. */
  20951. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  20952. /**
  20953. * 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
  20954. * transformed to the given world matrix.
  20955. * @param origin The origin point
  20956. * @param end The end point
  20957. * @param world a matrix to transform the ray to. Default is the identity matrix.
  20958. * @returns the new ray
  20959. */
  20960. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  20961. /**
  20962. * Transforms a ray by a matrix
  20963. * @param ray ray to transform
  20964. * @param matrix matrix to apply
  20965. * @returns the resulting new ray
  20966. */
  20967. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  20968. /**
  20969. * Transforms a ray by a matrix
  20970. * @param ray ray to transform
  20971. * @param matrix matrix to apply
  20972. * @param result ray to store result in
  20973. */
  20974. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  20975. /**
  20976. * Unproject a ray from screen space to object space
  20977. * @param sourceX defines the screen space x coordinate to use
  20978. * @param sourceY defines the screen space y coordinate to use
  20979. * @param viewportWidth defines the current width of the viewport
  20980. * @param viewportHeight defines the current height of the viewport
  20981. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  20982. * @param view defines the view matrix to use
  20983. * @param projection defines the projection matrix to use
  20984. */
  20985. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  20986. }
  20987. }
  20988. declare module BABYLON {
  20989. /**
  20990. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20991. * separate meshes. This can be use to improve performances.
  20992. * @see http://doc.babylonjs.com/how_to/multi_materials
  20993. */
  20994. export class MultiMaterial extends Material {
  20995. private _subMaterials;
  20996. /**
  20997. * Gets or Sets the list of Materials used within the multi material.
  20998. * They need to be ordered according to the submeshes order in the associated mesh
  20999. */
  21000. subMaterials: Nullable<Material>[];
  21001. /**
  21002. * Function used to align with Node.getChildren()
  21003. * @returns the list of Materials used within the multi material
  21004. */
  21005. getChildren(): Nullable<Material>[];
  21006. /**
  21007. * Instantiates a new Multi Material
  21008. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21009. * separate meshes. This can be use to improve performances.
  21010. * @see http://doc.babylonjs.com/how_to/multi_materials
  21011. * @param name Define the name in the scene
  21012. * @param scene Define the scene the material belongs to
  21013. */
  21014. constructor(name: string, scene: Scene);
  21015. private _hookArray;
  21016. /**
  21017. * Get one of the submaterial by its index in the submaterials array
  21018. * @param index The index to look the sub material at
  21019. * @returns The Material if the index has been defined
  21020. */
  21021. getSubMaterial(index: number): Nullable<Material>;
  21022. /**
  21023. * Get the list of active textures for the whole sub materials list.
  21024. * @returns All the textures that will be used during the rendering
  21025. */
  21026. getActiveTextures(): BaseTexture[];
  21027. /**
  21028. * Gets the current class name of the material e.g. "MultiMaterial"
  21029. * Mainly use in serialization.
  21030. * @returns the class name
  21031. */
  21032. getClassName(): string;
  21033. /**
  21034. * Checks if the material is ready to render the requested sub mesh
  21035. * @param mesh Define the mesh the submesh belongs to
  21036. * @param subMesh Define the sub mesh to look readyness for
  21037. * @param useInstances Define whether or not the material is used with instances
  21038. * @returns true if ready, otherwise false
  21039. */
  21040. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21041. /**
  21042. * Clones the current material and its related sub materials
  21043. * @param name Define the name of the newly cloned material
  21044. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21045. * @returns the cloned material
  21046. */
  21047. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21048. /**
  21049. * Serializes the materials into a JSON representation.
  21050. * @returns the JSON representation
  21051. */
  21052. serialize(): any;
  21053. /**
  21054. * Dispose the material and release its associated resources
  21055. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  21056. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  21057. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21058. */
  21059. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21060. /**
  21061. * Creates a MultiMaterial from parsed MultiMaterial data.
  21062. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21063. * @param scene defines the hosting scene
  21064. * @returns a new MultiMaterial
  21065. */
  21066. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21067. }
  21068. }
  21069. declare module BABYLON {
  21070. /**
  21071. * Base class for submeshes
  21072. */
  21073. export class BaseSubMesh {
  21074. /** @hidden */ materialDefines: Nullable<MaterialDefines>;
  21075. /** @hidden */ materialEffect: Nullable<Effect>;
  21076. /**
  21077. * Gets associated effect
  21078. */
  21079. readonly effect: Nullable<Effect>;
  21080. /**
  21081. * Sets associated effect (effect used to render this submesh)
  21082. * @param effect defines the effect to associate with
  21083. * @param defines defines the set of defines used to compile this effect
  21084. */
  21085. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21086. }
  21087. /**
  21088. * Defines a subdivision inside a mesh
  21089. */
  21090. export class SubMesh extends BaseSubMesh implements ICullable {
  21091. /** the material index to use */
  21092. materialIndex: number;
  21093. /** vertex index start */
  21094. verticesStart: number;
  21095. /** vertices count */
  21096. verticesCount: number;
  21097. /** index start */
  21098. indexStart: number;
  21099. /** indices count */
  21100. indexCount: number;
  21101. /** @hidden */ linesIndexCount: number;
  21102. private _mesh;
  21103. private _renderingMesh;
  21104. private _boundingInfo;
  21105. private _linesIndexBuffer;
  21106. /** @hidden */ lastColliderWorldVertices: Nullable<Vector3[]>;
  21107. /** @hidden */ trianglePlanes: Plane[];
  21108. /** @hidden */ lastColliderTransformMatrix: Matrix;
  21109. /** @hidden */ renderId: number;
  21110. /** @hidden */ alphaIndex: number;
  21111. /** @hidden */ distanceToCamera: number;
  21112. /** @hidden */ id: number;
  21113. private _currentMaterial;
  21114. /**
  21115. * Add a new submesh to a mesh
  21116. * @param materialIndex defines the material index to use
  21117. * @param verticesStart defines vertex index start
  21118. * @param verticesCount defines vertices count
  21119. * @param indexStart defines index start
  21120. * @param indexCount defines indices count
  21121. * @param mesh defines the parent mesh
  21122. * @param renderingMesh defines an optional rendering mesh
  21123. * @param createBoundingBox defines if bounding box should be created for this submesh
  21124. * @returns the new submesh
  21125. */
  21126. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21127. /**
  21128. * Creates a new submesh
  21129. * @param materialIndex defines the material index to use
  21130. * @param verticesStart defines vertex index start
  21131. * @param verticesCount defines vertices count
  21132. * @param indexStart defines index start
  21133. * @param indexCount defines indices count
  21134. * @param mesh defines the parent mesh
  21135. * @param renderingMesh defines an optional rendering mesh
  21136. * @param createBoundingBox defines if bounding box should be created for this submesh
  21137. */
  21138. constructor(
  21139. /** the material index to use */
  21140. materialIndex: number,
  21141. /** vertex index start */
  21142. verticesStart: number,
  21143. /** vertices count */
  21144. verticesCount: number,
  21145. /** index start */
  21146. indexStart: number,
  21147. /** indices count */
  21148. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21149. /**
  21150. * Returns true if this submesh covers the entire parent mesh
  21151. * @ignorenaming
  21152. */
  21153. readonly IsGlobal: boolean;
  21154. /**
  21155. * Returns the submesh BoudingInfo object
  21156. * @returns current bounding info (or mesh's one if the submesh is global)
  21157. */
  21158. getBoundingInfo(): BoundingInfo;
  21159. /**
  21160. * Sets the submesh BoundingInfo
  21161. * @param boundingInfo defines the new bounding info to use
  21162. * @returns the SubMesh
  21163. */
  21164. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21165. /**
  21166. * Returns the mesh of the current submesh
  21167. * @return the parent mesh
  21168. */
  21169. getMesh(): AbstractMesh;
  21170. /**
  21171. * Returns the rendering mesh of the submesh
  21172. * @returns the rendering mesh (could be different from parent mesh)
  21173. */
  21174. getRenderingMesh(): Mesh;
  21175. /**
  21176. * Returns the submesh material
  21177. * @returns null or the current material
  21178. */
  21179. getMaterial(): Nullable<Material>;
  21180. /**
  21181. * Sets a new updated BoundingInfo object to the submesh
  21182. * @returns the SubMesh
  21183. */
  21184. refreshBoundingInfo(): SubMesh;
  21185. /** @hidden */ checkCollision(collider: Collider): boolean;
  21186. /**
  21187. * Updates the submesh BoundingInfo
  21188. * @param world defines the world matrix to use to update the bounding info
  21189. * @returns the submesh
  21190. */
  21191. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21192. /**
  21193. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21194. * @param frustumPlanes defines the frustum planes
  21195. * @returns true if the submesh is intersecting with the frustum
  21196. */
  21197. isInFrustum(frustumPlanes: Plane[]): boolean;
  21198. /**
  21199. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21200. * @param frustumPlanes defines the frustum planes
  21201. * @returns true if the submesh is inside the frustum
  21202. */
  21203. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21204. /**
  21205. * Renders the submesh
  21206. * @param enableAlphaMode defines if alpha needs to be used
  21207. * @returns the submesh
  21208. */
  21209. render(enableAlphaMode: boolean): SubMesh;
  21210. /**
  21211. * @hidden
  21212. */ getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21213. /**
  21214. * Checks if the submesh intersects with a ray
  21215. * @param ray defines the ray to test
  21216. * @returns true is the passed ray intersects the submesh bounding box
  21217. */
  21218. canIntersects(ray: Ray): boolean;
  21219. /**
  21220. * Intersects current submesh with a ray
  21221. * @param ray defines the ray to test
  21222. * @param positions defines mesh's positions array
  21223. * @param indices defines mesh's indices array
  21224. * @param fastCheck defines if only bounding info should be used
  21225. * @returns intersection info or null if no intersection
  21226. */
  21227. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  21228. /** @hidden */
  21229. private _intersectLines;
  21230. /** @hidden */
  21231. private _intersectTriangles;
  21232. /** @hidden */ rebuild(): void;
  21233. /**
  21234. * Creates a new submesh from the passed mesh
  21235. * @param newMesh defines the new hosting mesh
  21236. * @param newRenderingMesh defines an optional rendering mesh
  21237. * @returns the new submesh
  21238. */
  21239. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21240. /**
  21241. * Release associated resources
  21242. */
  21243. dispose(): void;
  21244. /**
  21245. * Gets the class name
  21246. * @returns the string "SubMesh".
  21247. */
  21248. getClassName(): string;
  21249. /**
  21250. * Creates a new submesh from indices data
  21251. * @param materialIndex the index of the main mesh material
  21252. * @param startIndex the index where to start the copy in the mesh indices array
  21253. * @param indexCount the number of indices to copy then from the startIndex
  21254. * @param mesh the main mesh to create the submesh from
  21255. * @param renderingMesh the optional rendering mesh
  21256. * @returns a new submesh
  21257. */
  21258. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21259. }
  21260. }
  21261. declare module BABYLON {
  21262. /**
  21263. * Class used to store geometry data (vertex buffers + index buffer)
  21264. */
  21265. export class Geometry implements IGetSetVerticesData {
  21266. /**
  21267. * Gets or sets the ID of the geometry
  21268. */
  21269. id: string;
  21270. /**
  21271. * Gets or sets the unique ID of the geometry
  21272. */
  21273. uniqueId: number;
  21274. /**
  21275. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21276. */
  21277. delayLoadState: number;
  21278. /**
  21279. * Gets the file containing the data to load when running in delay load state
  21280. */
  21281. delayLoadingFile: Nullable<string>;
  21282. /**
  21283. * Callback called when the geometry is updated
  21284. */
  21285. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21286. private _scene;
  21287. private _engine;
  21288. private _meshes;
  21289. private _totalVertices;
  21290. /** @hidden */ indices: IndicesArray;
  21291. /** @hidden */ vertexBuffers: {
  21292. [key: string]: VertexBuffer;
  21293. };
  21294. private _isDisposed;
  21295. private _extend;
  21296. private _boundingBias;
  21297. /** @hidden */ delayInfo: Array<string>;
  21298. private _indexBuffer;
  21299. private _indexBufferIsUpdatable;
  21300. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  21301. /** @hidden */ delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21302. /** @hidden */ softwareSkinningFrameId: number;
  21303. private _vertexArrayObjects;
  21304. private _updatable;
  21305. /** @hidden */ positions: Nullable<Vector3[]>;
  21306. /**
  21307. * 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
  21308. */
  21309. /**
  21310. * 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
  21311. */
  21312. boundingBias: Vector2;
  21313. /**
  21314. * Static function used to attach a new empty geometry to a mesh
  21315. * @param mesh defines the mesh to attach the geometry to
  21316. * @returns the new Geometry
  21317. */
  21318. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21319. /**
  21320. * Creates a new geometry
  21321. * @param id defines the unique ID
  21322. * @param scene defines the hosting scene
  21323. * @param vertexData defines the VertexData used to get geometry data
  21324. * @param updatable defines if geometry must be updatable (false by default)
  21325. * @param mesh defines the mesh that will be associated with the geometry
  21326. */
  21327. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21328. /**
  21329. * Gets the current extend of the geometry
  21330. */
  21331. readonly extend: {
  21332. minimum: Vector3;
  21333. maximum: Vector3;
  21334. };
  21335. /**
  21336. * Gets the hosting scene
  21337. * @returns the hosting Scene
  21338. */
  21339. getScene(): Scene;
  21340. /**
  21341. * Gets the hosting engine
  21342. * @returns the hosting Engine
  21343. */
  21344. getEngine(): Engine;
  21345. /**
  21346. * Defines if the geometry is ready to use
  21347. * @returns true if the geometry is ready to be used
  21348. */
  21349. isReady(): boolean;
  21350. /**
  21351. * Gets a value indicating that the geometry should not be serialized
  21352. */
  21353. readonly doNotSerialize: boolean;
  21354. /** @hidden */ rebuild(): void;
  21355. /**
  21356. * Affects all geometry data in one call
  21357. * @param vertexData defines the geometry data
  21358. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21359. */
  21360. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21361. /**
  21362. * Set specific vertex data
  21363. * @param kind defines the data kind (Position, normal, etc...)
  21364. * @param data defines the vertex data to use
  21365. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21366. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21367. */
  21368. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21369. /**
  21370. * Removes a specific vertex data
  21371. * @param kind defines the data kind (Position, normal, etc...)
  21372. */
  21373. removeVerticesData(kind: string): void;
  21374. /**
  21375. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21376. * @param buffer defines the vertex buffer to use
  21377. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21378. */
  21379. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21380. /**
  21381. * Update a specific vertex buffer
  21382. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21383. * It will do nothing if the buffer is not updatable
  21384. * @param kind defines the data kind (Position, normal, etc...)
  21385. * @param data defines the data to use
  21386. * @param offset defines the offset in the target buffer where to store the data
  21387. * @param useBytes set to true if the offset is in bytes
  21388. */
  21389. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21390. /**
  21391. * Update a specific vertex buffer
  21392. * This function will create a new buffer if the current one is not updatable
  21393. * @param kind defines the data kind (Position, normal, etc...)
  21394. * @param data defines the data to use
  21395. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21396. */
  21397. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21398. private _updateBoundingInfo;
  21399. /** @hidden */ bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  21400. /**
  21401. * Gets total number of vertices
  21402. * @returns the total number of vertices
  21403. */
  21404. getTotalVertices(): number;
  21405. /**
  21406. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21407. * @param kind defines the data kind (Position, normal, etc...)
  21408. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21409. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21410. * @returns a float array containing vertex data
  21411. */
  21412. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21413. /**
  21414. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21415. * @param kind defines the data kind (Position, normal, etc...)
  21416. * @returns true if the vertex buffer with the specified kind is updatable
  21417. */
  21418. isVertexBufferUpdatable(kind: string): boolean;
  21419. /**
  21420. * Gets a specific vertex buffer
  21421. * @param kind defines the data kind (Position, normal, etc...)
  21422. * @returns a VertexBuffer
  21423. */
  21424. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21425. /**
  21426. * Returns all vertex buffers
  21427. * @return an object holding all vertex buffers indexed by kind
  21428. */
  21429. getVertexBuffers(): Nullable<{
  21430. [key: string]: VertexBuffer;
  21431. }>;
  21432. /**
  21433. * Gets a boolean indicating if specific vertex buffer is present
  21434. * @param kind defines the data kind (Position, normal, etc...)
  21435. * @returns true if data is present
  21436. */
  21437. isVerticesDataPresent(kind: string): boolean;
  21438. /**
  21439. * Gets a list of all attached data kinds (Position, normal, etc...)
  21440. * @returns a list of string containing all kinds
  21441. */
  21442. getVerticesDataKinds(): string[];
  21443. /**
  21444. * Update index buffer
  21445. * @param indices defines the indices to store in the index buffer
  21446. * @param offset defines the offset in the target buffer where to store the data
  21447. */
  21448. updateIndices(indices: IndicesArray, offset?: number): void;
  21449. /**
  21450. * Creates a new index buffer
  21451. * @param indices defines the indices to store in the index buffer
  21452. * @param totalVertices defines the total number of vertices (could be null)
  21453. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21454. */
  21455. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21456. /**
  21457. * Return the total number of indices
  21458. * @returns the total number of indices
  21459. */
  21460. getTotalIndices(): number;
  21461. /**
  21462. * Gets the index buffer array
  21463. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21464. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21465. * @returns the index buffer array
  21466. */
  21467. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21468. /**
  21469. * Gets the index buffer
  21470. * @return the index buffer
  21471. */
  21472. getIndexBuffer(): Nullable<WebGLBuffer>;
  21473. /** @hidden */ releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21474. /**
  21475. * Release the associated resources for a specific mesh
  21476. * @param mesh defines the source mesh
  21477. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21478. */
  21479. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21480. /**
  21481. * Apply current geometry to a given mesh
  21482. * @param mesh defines the mesh to apply geometry to
  21483. */
  21484. applyToMesh(mesh: Mesh): void;
  21485. private _updateExtend;
  21486. private _applyToMesh;
  21487. private notifyUpdate;
  21488. /**
  21489. * Load the geometry if it was flagged as delay loaded
  21490. * @param scene defines the hosting scene
  21491. * @param onLoaded defines a callback called when the geometry is loaded
  21492. */
  21493. load(scene: Scene, onLoaded?: () => void): void;
  21494. private _queueLoad;
  21495. /**
  21496. * Invert the geometry to move from a right handed system to a left handed one.
  21497. */
  21498. toLeftHanded(): void;
  21499. /** @hidden */ resetPointsArrayCache(): void;
  21500. /** @hidden */ generatePointsArray(): boolean;
  21501. /**
  21502. * Gets a value indicating if the geometry is disposed
  21503. * @returns true if the geometry was disposed
  21504. */
  21505. isDisposed(): boolean;
  21506. private _disposeVertexArrayObjects;
  21507. /**
  21508. * Free all associated resources
  21509. */
  21510. dispose(): void;
  21511. /**
  21512. * Clone the current geometry into a new geometry
  21513. * @param id defines the unique ID of the new geometry
  21514. * @returns a new geometry object
  21515. */
  21516. copy(id: string): Geometry;
  21517. /**
  21518. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21519. * @return a JSON representation of the current geometry data (without the vertices data)
  21520. */
  21521. serialize(): any;
  21522. private toNumberArray;
  21523. /**
  21524. * Serialize all vertices data into a JSON oject
  21525. * @returns a JSON representation of the current geometry data
  21526. */
  21527. serializeVerticeData(): any;
  21528. /**
  21529. * Extracts a clone of a mesh geometry
  21530. * @param mesh defines the source mesh
  21531. * @param id defines the unique ID of the new geometry object
  21532. * @returns the new geometry object
  21533. */
  21534. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21535. /**
  21536. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21537. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21538. * Be aware Math.random() could cause collisions, but:
  21539. * "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"
  21540. * @returns a string containing a new GUID
  21541. */
  21542. static RandomId(): string;
  21543. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21544. private static _CleanMatricesWeights;
  21545. /**
  21546. * Create a new geometry from persisted data (Using .babylon file format)
  21547. * @param parsedVertexData defines the persisted data
  21548. * @param scene defines the hosting scene
  21549. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21550. * @returns the new geometry object
  21551. */
  21552. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21553. }
  21554. }
  21555. declare module BABYLON {
  21556. /**
  21557. * Define an interface for all classes that will get and set the data on vertices
  21558. */
  21559. export interface IGetSetVerticesData {
  21560. /**
  21561. * Gets a boolean indicating if specific vertex data is present
  21562. * @param kind defines the vertex data kind to use
  21563. * @returns true is data kind is present
  21564. */
  21565. isVerticesDataPresent(kind: string): boolean;
  21566. /**
  21567. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21568. * @param kind defines the data kind (Position, normal, etc...)
  21569. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21570. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21571. * @returns a float array containing vertex data
  21572. */
  21573. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21574. /**
  21575. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21576. * @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.
  21577. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21578. * @returns the indices array or an empty array if the mesh has no geometry
  21579. */
  21580. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21581. /**
  21582. * Set specific vertex data
  21583. * @param kind defines the data kind (Position, normal, etc...)
  21584. * @param data defines the vertex data to use
  21585. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21586. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21587. */
  21588. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21589. /**
  21590. * Update a specific associated vertex buffer
  21591. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21592. * - VertexBuffer.PositionKind
  21593. * - VertexBuffer.UVKind
  21594. * - VertexBuffer.UV2Kind
  21595. * - VertexBuffer.UV3Kind
  21596. * - VertexBuffer.UV4Kind
  21597. * - VertexBuffer.UV5Kind
  21598. * - VertexBuffer.UV6Kind
  21599. * - VertexBuffer.ColorKind
  21600. * - VertexBuffer.MatricesIndicesKind
  21601. * - VertexBuffer.MatricesIndicesExtraKind
  21602. * - VertexBuffer.MatricesWeightsKind
  21603. * - VertexBuffer.MatricesWeightsExtraKind
  21604. * @param data defines the data source
  21605. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21606. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  21607. */
  21608. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21609. /**
  21610. * Creates a new index buffer
  21611. * @param indices defines the indices to store in the index buffer
  21612. * @param totalVertices defines the total number of vertices (could be null)
  21613. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21614. */
  21615. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21616. }
  21617. /**
  21618. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21619. */
  21620. export class VertexData {
  21621. /**
  21622. * Mesh side orientation : usually the external or front surface
  21623. */
  21624. static readonly FRONTSIDE: number;
  21625. /**
  21626. * Mesh side orientation : usually the internal or back surface
  21627. */
  21628. static readonly BACKSIDE: number;
  21629. /**
  21630. * Mesh side orientation : both internal and external or front and back surfaces
  21631. */
  21632. static readonly DOUBLESIDE: number;
  21633. /**
  21634. * Mesh side orientation : by default, `FRONTSIDE`
  21635. */
  21636. static readonly DEFAULTSIDE: number;
  21637. /**
  21638. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21639. */
  21640. positions: Nullable<FloatArray>;
  21641. /**
  21642. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21643. */
  21644. normals: Nullable<FloatArray>;
  21645. /**
  21646. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21647. */
  21648. tangents: Nullable<FloatArray>;
  21649. /**
  21650. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21651. */
  21652. uvs: Nullable<FloatArray>;
  21653. /**
  21654. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21655. */
  21656. uvs2: Nullable<FloatArray>;
  21657. /**
  21658. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21659. */
  21660. uvs3: Nullable<FloatArray>;
  21661. /**
  21662. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21663. */
  21664. uvs4: Nullable<FloatArray>;
  21665. /**
  21666. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21667. */
  21668. uvs5: Nullable<FloatArray>;
  21669. /**
  21670. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21671. */
  21672. uvs6: Nullable<FloatArray>;
  21673. /**
  21674. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21675. */
  21676. colors: Nullable<FloatArray>;
  21677. /**
  21678. * 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).
  21679. */
  21680. matricesIndices: Nullable<FloatArray>;
  21681. /**
  21682. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21683. */
  21684. matricesWeights: Nullable<FloatArray>;
  21685. /**
  21686. * An array extending the number of possible indices
  21687. */
  21688. matricesIndicesExtra: Nullable<FloatArray>;
  21689. /**
  21690. * An array extending the number of possible weights when the number of indices is extended
  21691. */
  21692. matricesWeightsExtra: Nullable<FloatArray>;
  21693. /**
  21694. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21695. */
  21696. indices: Nullable<IndicesArray>;
  21697. /**
  21698. * Uses the passed data array to set the set the values for the specified kind of data
  21699. * @param data a linear array of floating numbers
  21700. * @param kind the type of data that is being set, eg positions, colors etc
  21701. */
  21702. set(data: FloatArray, kind: string): void;
  21703. /**
  21704. * Associates the vertexData to the passed Mesh.
  21705. * Sets it as updatable or not (default `false`)
  21706. * @param mesh the mesh the vertexData is applied to
  21707. * @param updatable when used and having the value true allows new data to update the vertexData
  21708. * @returns the VertexData
  21709. */
  21710. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21711. /**
  21712. * Associates the vertexData to the passed Geometry.
  21713. * Sets it as updatable or not (default `false`)
  21714. * @param geometry the geometry the vertexData is applied to
  21715. * @param updatable when used and having the value true allows new data to update the vertexData
  21716. * @returns VertexData
  21717. */
  21718. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21719. /**
  21720. * Updates the associated mesh
  21721. * @param mesh the mesh to be updated
  21722. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21723. * @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
  21724. * @returns VertexData
  21725. */
  21726. updateMesh(mesh: Mesh): VertexData;
  21727. /**
  21728. * Updates the associated geometry
  21729. * @param geometry the geometry to be updated
  21730. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21731. * @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
  21732. * @returns VertexData.
  21733. */
  21734. updateGeometry(geometry: Geometry): VertexData;
  21735. private _applyTo;
  21736. private _update;
  21737. /**
  21738. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21739. * @param matrix the transforming matrix
  21740. * @returns the VertexData
  21741. */
  21742. transform(matrix: Matrix): VertexData;
  21743. /**
  21744. * Merges the passed VertexData into the current one
  21745. * @param other the VertexData to be merged into the current one
  21746. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21747. * @returns the modified VertexData
  21748. */
  21749. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21750. private _mergeElement;
  21751. private _validate;
  21752. /**
  21753. * Serializes the VertexData
  21754. * @returns a serialized object
  21755. */
  21756. serialize(): any;
  21757. /**
  21758. * Extracts the vertexData from a mesh
  21759. * @param mesh the mesh from which to extract the VertexData
  21760. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21761. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21762. * @returns the object VertexData associated to the passed mesh
  21763. */
  21764. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21765. /**
  21766. * Extracts the vertexData from the geometry
  21767. * @param geometry the geometry from which to extract the VertexData
  21768. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21769. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21770. * @returns the object VertexData associated to the passed mesh
  21771. */
  21772. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21773. private static _ExtractFrom;
  21774. /**
  21775. * Creates the VertexData for a Ribbon
  21776. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21777. * * pathArray array of paths, each of which an array of successive Vector3
  21778. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21779. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21780. * * 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
  21781. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21782. * * 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)
  21783. * * 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)
  21784. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21785. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21786. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21787. * @returns the VertexData of the ribbon
  21788. */
  21789. static CreateRibbon(options: {
  21790. pathArray: Vector3[][];
  21791. closeArray?: boolean;
  21792. closePath?: boolean;
  21793. offset?: number;
  21794. sideOrientation?: number;
  21795. frontUVs?: Vector4;
  21796. backUVs?: Vector4;
  21797. invertUV?: boolean;
  21798. uvs?: Vector2[];
  21799. colors?: Color4[];
  21800. }): VertexData;
  21801. /**
  21802. * Creates the VertexData for a box
  21803. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21804. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21805. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21806. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21807. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21808. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21809. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21810. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21811. * * 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)
  21812. * * 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)
  21813. * @returns the VertexData of the box
  21814. */
  21815. static CreateBox(options: {
  21816. size?: number;
  21817. width?: number;
  21818. height?: number;
  21819. depth?: number;
  21820. faceUV?: Vector4[];
  21821. faceColors?: Color4[];
  21822. sideOrientation?: number;
  21823. frontUVs?: Vector4;
  21824. backUVs?: Vector4;
  21825. }): VertexData;
  21826. /**
  21827. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21828. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21829. * * segments sets the number of horizontal strips optional, default 32
  21830. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21831. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21832. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21833. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21834. * * 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
  21835. * * 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
  21836. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21837. * * 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)
  21838. * * 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)
  21839. * @returns the VertexData of the ellipsoid
  21840. */
  21841. static CreateSphere(options: {
  21842. segments?: number;
  21843. diameter?: number;
  21844. diameterX?: number;
  21845. diameterY?: number;
  21846. diameterZ?: number;
  21847. arc?: number;
  21848. slice?: number;
  21849. sideOrientation?: number;
  21850. frontUVs?: Vector4;
  21851. backUVs?: Vector4;
  21852. }): VertexData;
  21853. /**
  21854. * Creates the VertexData for a cylinder, cone or prism
  21855. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21856. * * height sets the height (y direction) of the cylinder, optional, default 2
  21857. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21858. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21859. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21860. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21861. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21862. * * 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
  21863. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21864. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21865. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21866. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21868. * * 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)
  21869. * * 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)
  21870. * @returns the VertexData of the cylinder, cone or prism
  21871. */
  21872. static CreateCylinder(options: {
  21873. height?: number;
  21874. diameterTop?: number;
  21875. diameterBottom?: number;
  21876. diameter?: number;
  21877. tessellation?: number;
  21878. subdivisions?: number;
  21879. arc?: number;
  21880. faceColors?: Color4[];
  21881. faceUV?: Vector4[];
  21882. hasRings?: boolean;
  21883. enclose?: boolean;
  21884. sideOrientation?: number;
  21885. frontUVs?: Vector4;
  21886. backUVs?: Vector4;
  21887. }): VertexData;
  21888. /**
  21889. * Creates the VertexData for a torus
  21890. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21891. * * diameter the diameter of the torus, optional default 1
  21892. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21893. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21894. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21895. * * 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)
  21896. * * 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)
  21897. * @returns the VertexData of the torus
  21898. */
  21899. static CreateTorus(options: {
  21900. diameter?: number;
  21901. thickness?: number;
  21902. tessellation?: number;
  21903. sideOrientation?: number;
  21904. frontUVs?: Vector4;
  21905. backUVs?: Vector4;
  21906. }): VertexData;
  21907. /**
  21908. * Creates the VertexData of the LineSystem
  21909. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21910. * - lines an array of lines, each line being an array of successive Vector3
  21911. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21912. * @returns the VertexData of the LineSystem
  21913. */
  21914. static CreateLineSystem(options: {
  21915. lines: Vector3[][];
  21916. colors?: Nullable<Color4[][]>;
  21917. }): VertexData;
  21918. /**
  21919. * Create the VertexData for a DashedLines
  21920. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21921. * - points an array successive Vector3
  21922. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21923. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21924. * - dashNb the intended total number of dashes, optional, default 200
  21925. * @returns the VertexData for the DashedLines
  21926. */
  21927. static CreateDashedLines(options: {
  21928. points: Vector3[];
  21929. dashSize?: number;
  21930. gapSize?: number;
  21931. dashNb?: number;
  21932. }): VertexData;
  21933. /**
  21934. * Creates the VertexData for a Ground
  21935. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21936. * - width the width (x direction) of the ground, optional, default 1
  21937. * - height the height (z direction) of the ground, optional, default 1
  21938. * - subdivisions the number of subdivisions per side, optional, default 1
  21939. * @returns the VertexData of the Ground
  21940. */
  21941. static CreateGround(options: {
  21942. width?: number;
  21943. height?: number;
  21944. subdivisions?: number;
  21945. subdivisionsX?: number;
  21946. subdivisionsY?: number;
  21947. }): VertexData;
  21948. /**
  21949. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21950. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21951. * * xmin the ground minimum X coordinate, optional, default -1
  21952. * * zmin the ground minimum Z coordinate, optional, default -1
  21953. * * xmax the ground maximum X coordinate, optional, default 1
  21954. * * zmax the ground maximum Z coordinate, optional, default 1
  21955. * * 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}
  21956. * * 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}
  21957. * @returns the VertexData of the TiledGround
  21958. */
  21959. static CreateTiledGround(options: {
  21960. xmin: number;
  21961. zmin: number;
  21962. xmax: number;
  21963. zmax: number;
  21964. subdivisions?: {
  21965. w: number;
  21966. h: number;
  21967. };
  21968. precision?: {
  21969. w: number;
  21970. h: number;
  21971. };
  21972. }): VertexData;
  21973. /**
  21974. * Creates the VertexData of the Ground designed from a heightmap
  21975. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21976. * * width the width (x direction) of the ground
  21977. * * height the height (z direction) of the ground
  21978. * * subdivisions the number of subdivisions per side
  21979. * * minHeight the minimum altitude on the ground, optional, default 0
  21980. * * maxHeight the maximum altitude on the ground, optional default 1
  21981. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21982. * * buffer the array holding the image color data
  21983. * * bufferWidth the width of image
  21984. * * bufferHeight the height of image
  21985. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21986. * @returns the VertexData of the Ground designed from a heightmap
  21987. */
  21988. static CreateGroundFromHeightMap(options: {
  21989. width: number;
  21990. height: number;
  21991. subdivisions: number;
  21992. minHeight: number;
  21993. maxHeight: number;
  21994. colorFilter: Color3;
  21995. buffer: Uint8Array;
  21996. bufferWidth: number;
  21997. bufferHeight: number;
  21998. alphaFilter: number;
  21999. }): VertexData;
  22000. /**
  22001. * Creates the VertexData for a Plane
  22002. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22003. * * size sets the width and height of the plane to the value of size, optional default 1
  22004. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22005. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22006. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22007. * * 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)
  22008. * * 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)
  22009. * @returns the VertexData of the box
  22010. */
  22011. static CreatePlane(options: {
  22012. size?: number;
  22013. width?: number;
  22014. height?: number;
  22015. sideOrientation?: number;
  22016. frontUVs?: Vector4;
  22017. backUVs?: Vector4;
  22018. }): VertexData;
  22019. /**
  22020. * Creates the VertexData of the Disc or regular Polygon
  22021. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22022. * * radius the radius of the disc, optional default 0.5
  22023. * * tessellation the number of polygon sides, optional, default 64
  22024. * * 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
  22025. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22026. * * 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)
  22027. * * 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)
  22028. * @returns the VertexData of the box
  22029. */
  22030. static CreateDisc(options: {
  22031. radius?: number;
  22032. tessellation?: number;
  22033. arc?: number;
  22034. sideOrientation?: number;
  22035. frontUVs?: Vector4;
  22036. backUVs?: Vector4;
  22037. }): VertexData;
  22038. /**
  22039. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22040. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22041. * @param polygon a mesh built from polygonTriangulation.build()
  22042. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22043. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22044. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22045. * @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)
  22046. * @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)
  22047. * @returns the VertexData of the Polygon
  22048. */
  22049. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22050. /**
  22051. * Creates the VertexData of the IcoSphere
  22052. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22053. * * radius the radius of the IcoSphere, optional default 1
  22054. * * radiusX allows stretching in the x direction, optional, default radius
  22055. * * radiusY allows stretching in the y direction, optional, default radius
  22056. * * radiusZ allows stretching in the z direction, optional, default radius
  22057. * * flat when true creates a flat shaded mesh, optional, default true
  22058. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22059. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22060. * * 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)
  22061. * * 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)
  22062. * @returns the VertexData of the IcoSphere
  22063. */
  22064. static CreateIcoSphere(options: {
  22065. radius?: number;
  22066. radiusX?: number;
  22067. radiusY?: number;
  22068. radiusZ?: number;
  22069. flat?: boolean;
  22070. subdivisions?: number;
  22071. sideOrientation?: number;
  22072. frontUVs?: Vector4;
  22073. backUVs?: Vector4;
  22074. }): VertexData;
  22075. /**
  22076. * Creates the VertexData for a Polyhedron
  22077. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22078. * * type provided types are:
  22079. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22080. * * 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)
  22081. * * size the size of the IcoSphere, optional default 1
  22082. * * sizeX allows stretching in the x direction, optional, default size
  22083. * * sizeY allows stretching in the y direction, optional, default size
  22084. * * sizeZ allows stretching in the z direction, optional, default size
  22085. * * 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
  22086. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22087. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22088. * * flat when true creates a flat shaded mesh, optional, default true
  22089. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22090. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22091. * * 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)
  22092. * * 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)
  22093. * @returns the VertexData of the Polyhedron
  22094. */
  22095. static CreatePolyhedron(options: {
  22096. type?: number;
  22097. size?: number;
  22098. sizeX?: number;
  22099. sizeY?: number;
  22100. sizeZ?: number;
  22101. custom?: any;
  22102. faceUV?: Vector4[];
  22103. faceColors?: Color4[];
  22104. flat?: boolean;
  22105. sideOrientation?: number;
  22106. frontUVs?: Vector4;
  22107. backUVs?: Vector4;
  22108. }): VertexData;
  22109. /**
  22110. * Creates the VertexData for a TorusKnot
  22111. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22112. * * radius the radius of the torus knot, optional, default 2
  22113. * * tube the thickness of the tube, optional, default 0.5
  22114. * * radialSegments the number of sides on each tube segments, optional, default 32
  22115. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22116. * * p the number of windings around the z axis, optional, default 2
  22117. * * q the number of windings around the x axis, optional, default 3
  22118. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22119. * * 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)
  22120. * * 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)
  22121. * @returns the VertexData of the Torus Knot
  22122. */
  22123. static CreateTorusKnot(options: {
  22124. radius?: number;
  22125. tube?: number;
  22126. radialSegments?: number;
  22127. tubularSegments?: number;
  22128. p?: number;
  22129. q?: number;
  22130. sideOrientation?: number;
  22131. frontUVs?: Vector4;
  22132. backUVs?: Vector4;
  22133. }): VertexData;
  22134. /**
  22135. * Compute normals for given positions and indices
  22136. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22137. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22138. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22139. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22140. * * facetNormals : optional array of facet normals (vector3)
  22141. * * facetPositions : optional array of facet positions (vector3)
  22142. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22143. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22144. * * bInfo : optional bounding info, required for facetPartitioning computation
  22145. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22146. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22147. * * useRightHandedSystem: optional boolean to for right handed system computation
  22148. * * depthSort : optional boolean to enable the facet depth sort computation
  22149. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22150. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22151. */
  22152. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22153. facetNormals?: any;
  22154. facetPositions?: any;
  22155. facetPartitioning?: any;
  22156. ratio?: number;
  22157. bInfo?: any;
  22158. bbSize?: Vector3;
  22159. subDiv?: any;
  22160. useRightHandedSystem?: boolean;
  22161. depthSort?: boolean;
  22162. distanceTo?: Vector3;
  22163. depthSortedFacets?: any;
  22164. }): void;
  22165. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22166. /**
  22167. * Applies VertexData created from the imported parameters to the geometry
  22168. * @param parsedVertexData the parsed data from an imported file
  22169. * @param geometry the geometry to apply the VertexData to
  22170. */
  22171. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22172. }
  22173. }
  22174. declare module BABYLON {
  22175. /**
  22176. * Class containing static functions to help procedurally build meshes
  22177. */
  22178. export class DiscBuilder {
  22179. /**
  22180. * Creates a plane polygonal mesh. By default, this is a disc
  22181. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22182. * * 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
  22183. * * 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
  22184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22185. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22187. * @param name defines the name of the mesh
  22188. * @param options defines the options used to create the mesh
  22189. * @param scene defines the hosting scene
  22190. * @returns the plane polygonal mesh
  22191. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22192. */
  22193. static CreateDisc(name: string, options: {
  22194. radius?: number;
  22195. tessellation?: number;
  22196. arc?: number;
  22197. updatable?: boolean;
  22198. sideOrientation?: number;
  22199. frontUVs?: Vector4;
  22200. backUVs?: Vector4;
  22201. }, scene?: Nullable<Scene>): Mesh;
  22202. }
  22203. }
  22204. declare module BABYLON {
  22205. /**
  22206. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  22207. *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.
  22208. * The SPS is also a particle system. It provides some methods to manage the particles.
  22209. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  22210. *
  22211. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  22212. */
  22213. export class SolidParticleSystem implements IDisposable {
  22214. /**
  22215. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  22216. * Example : var p = SPS.particles[i];
  22217. */
  22218. particles: SolidParticle[];
  22219. /**
  22220. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  22221. */
  22222. nbParticles: number;
  22223. /**
  22224. * If the particles must ever face the camera (default false). Useful for planar particles.
  22225. */
  22226. billboard: boolean;
  22227. /**
  22228. * Recompute normals when adding a shape
  22229. */
  22230. recomputeNormals: boolean;
  22231. /**
  22232. * This a counter ofr your own usage. It's not set by any SPS functions.
  22233. */
  22234. counter: number;
  22235. /**
  22236. * The SPS name. This name is also given to the underlying mesh.
  22237. */
  22238. name: string;
  22239. /**
  22240. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  22241. */
  22242. mesh: Mesh;
  22243. /**
  22244. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  22245. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  22246. */
  22247. vars: any;
  22248. /**
  22249. * This array is populated when the SPS is set as 'pickable'.
  22250. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  22251. * Each element of this array is an object `{idx: int, faceId: int}`.
  22252. * `idx` is the picked particle index in the `SPS.particles` array
  22253. * `faceId` is the picked face index counted within this particle.
  22254. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  22255. */
  22256. pickedParticles: {
  22257. idx: number;
  22258. faceId: number;
  22259. }[];
  22260. /**
  22261. * This array is populated when `enableDepthSort` is set to true.
  22262. * Each element of this array is an instance of the class DepthSortedParticle.
  22263. */
  22264. depthSortedParticles: DepthSortedParticle[];
  22265. /**
  22266. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  22267. * @hidden
  22268. */ bSphereOnly: boolean;
  22269. /**
  22270. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  22271. * @hidden
  22272. */ bSphereRadiusFactor: number;
  22273. private _scene;
  22274. private _positions;
  22275. private _indices;
  22276. private _normals;
  22277. private _colors;
  22278. private _uvs;
  22279. private _indices32;
  22280. private _positions32;
  22281. private _normals32;
  22282. private _fixedNormal32;
  22283. private _colors32;
  22284. private _uvs32;
  22285. private _index;
  22286. private _updatable;
  22287. private _pickable;
  22288. private _isVisibilityBoxLocked;
  22289. private _alwaysVisible;
  22290. private _depthSort;
  22291. private _shapeCounter;
  22292. private _copy;
  22293. private _color;
  22294. private _computeParticleColor;
  22295. private _computeParticleTexture;
  22296. private _computeParticleRotation;
  22297. private _computeParticleVertex;
  22298. private _computeBoundingBox;
  22299. private _depthSortParticles;
  22300. private _camera;
  22301. private _mustUnrotateFixedNormals;
  22302. private _particlesIntersect;
  22303. private _needs32Bits;
  22304. /**
  22305. * Creates a SPS (Solid Particle System) object.
  22306. * @param name (String) is the SPS name, this will be the underlying mesh name.
  22307. * @param scene (Scene) is the scene in which the SPS is added.
  22308. * @param options defines the options of the sps e.g.
  22309. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  22310. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  22311. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  22312. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  22313. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  22314. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  22315. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  22316. */
  22317. constructor(name: string, scene: Scene, options?: {
  22318. updatable?: boolean;
  22319. isPickable?: boolean;
  22320. enableDepthSort?: boolean;
  22321. particleIntersection?: boolean;
  22322. boundingSphereOnly?: boolean;
  22323. bSphereRadiusFactor?: number;
  22324. });
  22325. /**
  22326. * Builds the SPS underlying mesh. Returns a standard Mesh.
  22327. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  22328. * @returns the created mesh
  22329. */
  22330. buildMesh(): Mesh;
  22331. /**
  22332. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  22333. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  22334. * Thus the particles generated from `digest()` have their property `position` set yet.
  22335. * @param mesh ( Mesh ) is the mesh to be digested
  22336. * @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
  22337. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  22338. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  22339. * @returns the current SPS
  22340. */
  22341. digest(mesh: Mesh, options?: {
  22342. facetNb?: number;
  22343. number?: number;
  22344. delta?: number;
  22345. }): SolidParticleSystem;
  22346. private _unrotateFixedNormals;
  22347. private _resetCopy;
  22348. private _meshBuilder;
  22349. private _posToShape;
  22350. private _uvsToShapeUV;
  22351. private _addParticle;
  22352. /**
  22353. * Adds some particles to the SPS from the model shape. Returns the shape id.
  22354. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  22355. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  22356. * @param nb (positive integer) the number of particles to be created from this model
  22357. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  22358. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  22359. * @returns the number of shapes in the system
  22360. */
  22361. addShape(mesh: Mesh, nb: number, options?: {
  22362. positionFunction?: any;
  22363. vertexFunction?: any;
  22364. }): number;
  22365. private _rebuildParticle;
  22366. /**
  22367. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  22368. * @returns the SPS.
  22369. */
  22370. rebuildMesh(): SolidParticleSystem;
  22371. /**
  22372. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  22373. * This method calls `updateParticle()` for each particle of the SPS.
  22374. * For an animated SPS, it is usually called within the render loop.
  22375. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  22376. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  22377. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  22378. * @returns the SPS.
  22379. */
  22380. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  22381. /**
  22382. * Disposes the SPS.
  22383. */
  22384. dispose(): void;
  22385. /**
  22386. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  22387. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22388. * @returns the SPS.
  22389. */
  22390. refreshVisibleSize(): SolidParticleSystem;
  22391. /**
  22392. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  22393. * @param size the size (float) of the visibility box
  22394. * note : this doesn't lock the SPS mesh bounding box.
  22395. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22396. */
  22397. setVisibilityBox(size: number): void;
  22398. /**
  22399. * Gets whether the SPS as always visible or not
  22400. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22401. */
  22402. /**
  22403. * Sets the SPS as always visible or not
  22404. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22405. */
  22406. isAlwaysVisible: boolean;
  22407. /**
  22408. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22409. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22410. */
  22411. /**
  22412. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22413. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22414. */
  22415. isVisibilityBoxLocked: boolean;
  22416. /**
  22417. * Tells to `setParticles()` to compute the particle rotations or not.
  22418. * Default value : true. The SPS is faster when it's set to false.
  22419. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22420. */
  22421. /**
  22422. * Gets if `setParticles()` computes the particle rotations or not.
  22423. * Default value : true. The SPS is faster when it's set to false.
  22424. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22425. */
  22426. computeParticleRotation: boolean;
  22427. /**
  22428. * Tells to `setParticles()` to compute the particle colors or not.
  22429. * Default value : true. The SPS is faster when it's set to false.
  22430. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22431. */
  22432. /**
  22433. * Gets if `setParticles()` computes the particle colors or not.
  22434. * Default value : true. The SPS is faster when it's set to false.
  22435. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22436. */
  22437. computeParticleColor: boolean;
  22438. /**
  22439. * Gets if `setParticles()` computes the particle textures or not.
  22440. * Default value : true. The SPS is faster when it's set to false.
  22441. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  22442. */
  22443. computeParticleTexture: boolean;
  22444. /**
  22445. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  22446. * Default value : false. The SPS is faster when it's set to false.
  22447. * Note : the particle custom vertex positions aren't stored values.
  22448. */
  22449. /**
  22450. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  22451. * Default value : false. The SPS is faster when it's set to false.
  22452. * Note : the particle custom vertex positions aren't stored values.
  22453. */
  22454. computeParticleVertex: boolean;
  22455. /**
  22456. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  22457. */
  22458. /**
  22459. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  22460. */
  22461. computeBoundingBox: boolean;
  22462. /**
  22463. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  22464. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22465. * Default : `true`
  22466. */
  22467. /**
  22468. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  22469. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22470. * Default : `true`
  22471. */
  22472. depthSortParticles: boolean;
  22473. /**
  22474. * This function does nothing. It may be overwritten to set all the particle first values.
  22475. * The SPS doesn't call this function, you may have to call it by your own.
  22476. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22477. */
  22478. initParticles(): void;
  22479. /**
  22480. * This function does nothing. It may be overwritten to recycle a particle.
  22481. * The SPS doesn't call this function, you may have to call it by your own.
  22482. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22483. * @param particle The particle to recycle
  22484. * @returns the recycled particle
  22485. */
  22486. recycleParticle(particle: SolidParticle): SolidParticle;
  22487. /**
  22488. * Updates a particle : this function should be overwritten by the user.
  22489. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  22490. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22491. * @example : just set a particle position or velocity and recycle conditions
  22492. * @param particle The particle to update
  22493. * @returns the updated particle
  22494. */
  22495. updateParticle(particle: SolidParticle): SolidParticle;
  22496. /**
  22497. * Updates a vertex of a particle : it can be overwritten by the user.
  22498. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  22499. * @param particle the current particle
  22500. * @param vertex the current index of the current particle
  22501. * @param pt the index of the current vertex in the particle shape
  22502. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  22503. * @example : just set a vertex particle position
  22504. * @returns the updated vertex
  22505. */
  22506. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  22507. /**
  22508. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  22509. * This does nothing and may be overwritten by the user.
  22510. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22511. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22512. * @param update the boolean update value actually passed to setParticles()
  22513. */
  22514. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22515. /**
  22516. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  22517. * This will be passed three parameters.
  22518. * This does nothing and may be overwritten by the user.
  22519. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22520. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22521. * @param update the boolean update value actually passed to setParticles()
  22522. */
  22523. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22524. }
  22525. }
  22526. declare module BABYLON {
  22527. /**
  22528. * Represents one particle of a solid particle system.
  22529. */
  22530. export class SolidParticle {
  22531. /**
  22532. * particle global index
  22533. */
  22534. idx: number;
  22535. /**
  22536. * The color of the particle
  22537. */
  22538. color: Nullable<Color4>;
  22539. /**
  22540. * The world space position of the particle.
  22541. */
  22542. position: Vector3;
  22543. /**
  22544. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  22545. */
  22546. rotation: Vector3;
  22547. /**
  22548. * The world space rotation quaternion of the particle.
  22549. */
  22550. rotationQuaternion: Nullable<Quaternion>;
  22551. /**
  22552. * The scaling of the particle.
  22553. */
  22554. scaling: Vector3;
  22555. /**
  22556. * The uvs of the particle.
  22557. */
  22558. uvs: Vector4;
  22559. /**
  22560. * The current speed of the particle.
  22561. */
  22562. velocity: Vector3;
  22563. /**
  22564. * The pivot point in the particle local space.
  22565. */
  22566. pivot: Vector3;
  22567. /**
  22568. * Must the particle be translated from its pivot point in its local space ?
  22569. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  22570. * Default : false
  22571. */
  22572. translateFromPivot: boolean;
  22573. /**
  22574. * Is the particle active or not ?
  22575. */
  22576. alive: boolean;
  22577. /**
  22578. * Is the particle visible or not ?
  22579. */
  22580. isVisible: boolean;
  22581. /**
  22582. * Index of this particle in the global "positions" array (Internal use)
  22583. * @hidden
  22584. */ pos: number;
  22585. /**
  22586. * @hidden Index of this particle in the global "indices" array (Internal use)
  22587. */ ind: number;
  22588. /**
  22589. * @hidden ModelShape of this particle (Internal use)
  22590. */ model: ModelShape;
  22591. /**
  22592. * ModelShape id of this particle
  22593. */
  22594. shapeId: number;
  22595. /**
  22596. * Index of the particle in its shape id (Internal use)
  22597. */
  22598. idxInShape: number;
  22599. /**
  22600. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  22601. */ modelBoundingInfo: BoundingInfo;
  22602. /**
  22603. * @hidden Particle BoundingInfo object (Internal use)
  22604. */ boundingInfo: BoundingInfo;
  22605. /**
  22606. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  22607. */ sps: SolidParticleSystem;
  22608. /**
  22609. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  22610. */ stillInvisible: boolean;
  22611. /**
  22612. * @hidden Last computed particle rotation matrix
  22613. */ rotationMatrix: number[];
  22614. /**
  22615. * Parent particle Id, if any.
  22616. * Default null.
  22617. */
  22618. parentId: Nullable<number>;
  22619. /**
  22620. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  22621. * The possible values are :
  22622. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22623. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22624. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22625. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22626. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22627. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  22628. * */
  22629. cullingStrategy: number;
  22630. /**
  22631. * @hidden Internal global position in the SPS.
  22632. */ globalPosition: Vector3;
  22633. /**
  22634. * Creates a Solid Particle object.
  22635. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  22636. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  22637. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  22638. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  22639. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  22640. * @param shapeId (integer) is the model shape identifier in the SPS.
  22641. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  22642. * @param sps defines the sps it is associated to
  22643. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  22644. */
  22645. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  22646. /**
  22647. * Legacy support, changed scale to scaling
  22648. */
  22649. /**
  22650. * Legacy support, changed scale to scaling
  22651. */
  22652. scale: Vector3;
  22653. /**
  22654. * Legacy support, changed quaternion to rotationQuaternion
  22655. */
  22656. /**
  22657. * Legacy support, changed quaternion to rotationQuaternion
  22658. */
  22659. quaternion: Nullable<Quaternion>;
  22660. /**
  22661. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  22662. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  22663. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  22664. * @returns true if it intersects
  22665. */
  22666. intersectsMesh(target: Mesh | SolidParticle): boolean;
  22667. /**
  22668. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  22669. * A particle is in the frustum if its bounding box intersects the frustum
  22670. * @param frustumPlanes defines the frustum to test
  22671. * @returns true if the particle is in the frustum planes
  22672. */
  22673. isInFrustum(frustumPlanes: Plane[]): boolean;
  22674. /**
  22675. * get the rotation matrix of the particle
  22676. * @hidden
  22677. */
  22678. getRotationMatrix(m: Matrix): void;
  22679. }
  22680. /**
  22681. * Represents the shape of the model used by one particle of a solid particle system.
  22682. * SPS internal tool, don't use it manually.
  22683. */
  22684. export class ModelShape {
  22685. /**
  22686. * The shape id
  22687. * @hidden
  22688. */
  22689. shapeID: number;
  22690. /**
  22691. * flat array of model positions (internal use)
  22692. * @hidden
  22693. */ shape: Vector3[];
  22694. /**
  22695. * flat array of model UVs (internal use)
  22696. * @hidden
  22697. */ shapeUV: number[];
  22698. /**
  22699. * length of the shape in the model indices array (internal use)
  22700. * @hidden
  22701. */ indicesLength: number;
  22702. /**
  22703. * Custom position function (internal use)
  22704. * @hidden
  22705. */ positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  22706. /**
  22707. * Custom vertex function (internal use)
  22708. * @hidden
  22709. */ vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  22710. /**
  22711. * 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.
  22712. * SPS internal tool, don't use it manually.
  22713. * @hidden
  22714. */
  22715. 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>);
  22716. }
  22717. /**
  22718. * Represents a Depth Sorted Particle in the solid particle system.
  22719. */
  22720. export class DepthSortedParticle {
  22721. /**
  22722. * Index of the particle in the "indices" array
  22723. */
  22724. ind: number;
  22725. /**
  22726. * Length of the particle shape in the "indices" array
  22727. */
  22728. indicesLength: number;
  22729. /**
  22730. * Squared distance from the particle to the camera
  22731. */
  22732. sqDistance: number;
  22733. }
  22734. }
  22735. declare module BABYLON {
  22736. /**
  22737. * Class used to store all common mesh properties
  22738. */
  22739. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  22740. /** No occlusion */
  22741. static OCCLUSION_TYPE_NONE: number;
  22742. /** Occlusion set to optimisitic */
  22743. static OCCLUSION_TYPE_OPTIMISTIC: number;
  22744. /** Occlusion set to strict */
  22745. static OCCLUSION_TYPE_STRICT: number;
  22746. /** Use an accurante occlusion algorithm */
  22747. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  22748. /** Use a conservative occlusion algorithm */
  22749. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  22750. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  22751. * Test order :
  22752. * Is the bounding sphere outside the frustum ?
  22753. * If not, are the bounding box vertices outside the frustum ?
  22754. * It not, then the cullable object is in the frustum.
  22755. */
  22756. static readonly CULLINGSTRATEGY_STANDARD: number;
  22757. /** Culling strategy : Bounding Sphere Only.
  22758. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  22759. * It's also less accurate than the standard because some not visible objects can still be selected.
  22760. * Test : is the bounding sphere outside the frustum ?
  22761. * If not, then the cullable object is in the frustum.
  22762. */
  22763. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  22764. /** Culling strategy : Optimistic Inclusion.
  22765. * This in an inclusion test first, then the standard exclusion test.
  22766. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  22767. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  22768. * Anyway, it's as accurate as the standard strategy.
  22769. * Test :
  22770. * Is the cullable object bounding sphere center in the frustum ?
  22771. * If not, apply the default culling strategy.
  22772. */
  22773. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  22774. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  22775. * This in an inclusion test first, then the bounding sphere only exclusion test.
  22776. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  22777. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  22778. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  22779. * Test :
  22780. * Is the cullable object bounding sphere center in the frustum ?
  22781. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  22782. */
  22783. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  22784. /**
  22785. * No billboard
  22786. */
  22787. static readonly BILLBOARDMODE_NONE: number;
  22788. /** Billboard on X axis */
  22789. static readonly BILLBOARDMODE_X: number;
  22790. /** Billboard on Y axis */
  22791. static readonly BILLBOARDMODE_Y: number;
  22792. /** Billboard on Z axis */
  22793. static readonly BILLBOARDMODE_Z: number;
  22794. /** Billboard on all axes */
  22795. static readonly BILLBOARDMODE_ALL: number;
  22796. private _facetData;
  22797. /**
  22798. * The culling strategy to use to check whether the mesh must be rendered or not.
  22799. * This value can be changed at any time and will be used on the next render mesh selection.
  22800. * The possible values are :
  22801. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22802. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22803. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22804. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22805. * Please read each static variable documentation to get details about the culling process.
  22806. * */
  22807. cullingStrategy: number;
  22808. /**
  22809. * Gets the number of facets in the mesh
  22810. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22811. */
  22812. readonly facetNb: number;
  22813. /**
  22814. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  22815. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22816. */
  22817. partitioningSubdivisions: number;
  22818. /**
  22819. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  22820. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  22821. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22822. */
  22823. partitioningBBoxRatio: number;
  22824. /**
  22825. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  22826. * Works only for updatable meshes.
  22827. * Doesn't work with multi-materials
  22828. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22829. */
  22830. mustDepthSortFacets: boolean;
  22831. /**
  22832. * The location (Vector3) where the facet depth sort must be computed from.
  22833. * By default, the active camera position.
  22834. * Used only when facet depth sort is enabled
  22835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22836. */
  22837. facetDepthSortFrom: Vector3;
  22838. /**
  22839. * gets a boolean indicating if facetData is enabled
  22840. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22841. */
  22842. readonly isFacetDataEnabled: boolean;
  22843. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  22844. /**
  22845. * An event triggered when this mesh collides with another one
  22846. */
  22847. onCollideObservable: Observable<AbstractMesh>;
  22848. private _onCollideObserver;
  22849. /** Set a function to call when this mesh collides with another one */
  22850. onCollide: () => void;
  22851. /**
  22852. * An event triggered when the collision's position changes
  22853. */
  22854. onCollisionPositionChangeObservable: Observable<Vector3>;
  22855. private _onCollisionPositionChangeObserver;
  22856. /** Set a function to call when the collision's position changes */
  22857. onCollisionPositionChange: () => void;
  22858. /**
  22859. * An event triggered when material is changed
  22860. */
  22861. onMaterialChangedObservable: Observable<AbstractMesh>;
  22862. /**
  22863. * Gets or sets the orientation for POV movement & rotation
  22864. */
  22865. definedFacingForward: boolean;
  22866. /** @hidden */ occlusionQuery: Nullable<WebGLQuery>;
  22867. private _visibility;
  22868. /**
  22869. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22870. */
  22871. /**
  22872. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22873. */
  22874. visibility: number;
  22875. /** Gets or sets the alpha index used to sort transparent meshes
  22876. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  22877. */
  22878. alphaIndex: number;
  22879. /**
  22880. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  22881. */
  22882. isVisible: boolean;
  22883. /**
  22884. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  22885. */
  22886. isPickable: boolean;
  22887. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  22888. showSubMeshesBoundingBox: boolean;
  22889. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  22890. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  22891. */
  22892. isBlocker: boolean;
  22893. /**
  22894. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  22895. */
  22896. enablePointerMoveEvents: boolean;
  22897. /**
  22898. * Specifies the rendering group id for this mesh (0 by default)
  22899. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  22900. */
  22901. renderingGroupId: number;
  22902. private _material;
  22903. /** Gets or sets current material */
  22904. material: Nullable<Material>;
  22905. private _receiveShadows;
  22906. /**
  22907. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  22908. * @see http://doc.babylonjs.com/babylon101/shadows
  22909. */
  22910. receiveShadows: boolean;
  22911. /** Defines color to use when rendering outline */
  22912. outlineColor: Color3;
  22913. /** Define width to use when rendering outline */
  22914. outlineWidth: number;
  22915. /** Defines color to use when rendering overlay */
  22916. overlayColor: Color3;
  22917. /** Defines alpha to use when rendering overlay */
  22918. overlayAlpha: number;
  22919. private _hasVertexAlpha;
  22920. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  22921. hasVertexAlpha: boolean;
  22922. private _useVertexColors;
  22923. /** 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) */
  22924. useVertexColors: boolean;
  22925. private _computeBonesUsingShaders;
  22926. /**
  22927. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  22928. */
  22929. computeBonesUsingShaders: boolean;
  22930. private _numBoneInfluencers;
  22931. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  22932. numBoneInfluencers: number;
  22933. private _applyFog;
  22934. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  22935. applyFog: boolean;
  22936. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  22937. useOctreeForRenderingSelection: boolean;
  22938. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  22939. useOctreeForPicking: boolean;
  22940. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  22941. useOctreeForCollisions: boolean;
  22942. private _layerMask;
  22943. /**
  22944. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  22945. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  22946. */
  22947. layerMask: number;
  22948. /**
  22949. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  22950. */
  22951. alwaysSelectAsActiveMesh: boolean;
  22952. /**
  22953. * Gets or sets the current action manager
  22954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  22955. */
  22956. actionManager: Nullable<AbstractActionManager>;
  22957. private _checkCollisions;
  22958. private _collisionMask;
  22959. private _collisionGroup;
  22960. /**
  22961. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  22962. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22963. */
  22964. ellipsoid: Vector3;
  22965. /**
  22966. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  22967. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22968. */
  22969. ellipsoidOffset: Vector3;
  22970. private _collider;
  22971. private _oldPositionForCollisions;
  22972. private _diffPositionForCollisions;
  22973. /**
  22974. * Gets or sets a collision mask used to mask collisions (default is -1).
  22975. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22976. */
  22977. collisionMask: number;
  22978. /**
  22979. * Gets or sets the current collision group mask (-1 by default).
  22980. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22981. */
  22982. collisionGroup: number;
  22983. /**
  22984. * Defines edge width used when edgesRenderer is enabled
  22985. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22986. */
  22987. edgesWidth: number;
  22988. /**
  22989. * Defines edge color used when edgesRenderer is enabled
  22990. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22991. */
  22992. edgesColor: Color4;
  22993. /** @hidden */ edgesRenderer: Nullable<IEdgesRenderer>;
  22994. /** @hidden */ masterMesh: Nullable<AbstractMesh>;
  22995. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  22996. /** @hidden */ renderId: number;
  22997. /**
  22998. * Gets or sets the list of subMeshes
  22999. * @see http://doc.babylonjs.com/how_to/multi_materials
  23000. */
  23001. subMeshes: SubMesh[];
  23002. /** @hidden */ intersectionsInProgress: AbstractMesh[];
  23003. /** @hidden */ unIndexed: boolean;
  23004. /** @hidden */ lightSources: Light[];
  23005. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23006. /** @hidden */ waitingActions: any;
  23007. /** @hidden */ waitingFreezeWorldMatrix: Nullable<boolean>;
  23008. private _skeleton;
  23009. /** @hidden */ bonesTransformMatrices: Nullable<Float32Array>;
  23010. /**
  23011. * Gets or sets a skeleton to apply skining transformations
  23012. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23013. */
  23014. skeleton: Nullable<Skeleton>;
  23015. /**
  23016. * An event triggered when the mesh is rebuilt.
  23017. */
  23018. onRebuildObservable: Observable<AbstractMesh>;
  23019. /**
  23020. * Creates a new AbstractMesh
  23021. * @param name defines the name of the mesh
  23022. * @param scene defines the hosting scene
  23023. */
  23024. constructor(name: string, scene?: Nullable<Scene>);
  23025. /**
  23026. * Returns the string "AbstractMesh"
  23027. * @returns "AbstractMesh"
  23028. */
  23029. getClassName(): string;
  23030. /**
  23031. * Gets a string representation of the current mesh
  23032. * @param fullDetails defines a boolean indicating if full details must be included
  23033. * @returns a string representation of the current mesh
  23034. */
  23035. toString(fullDetails?: boolean): string;
  23036. /** @hidden */ rebuild(): void;
  23037. /** @hidden */ resyncLightSources(): void;
  23038. /** @hidden */ resyncLighSource(light: Light): void;
  23039. /** @hidden */ unBindEffect(): void;
  23040. /** @hidden */ removeLightSource(light: Light): void;
  23041. private _markSubMeshesAsDirty;
  23042. /** @hidden */ markSubMeshesAsLightDirty(): void;
  23043. /** @hidden */ markSubMeshesAsAttributesDirty(): void;
  23044. /** @hidden */ markSubMeshesAsMiscDirty(): void;
  23045. /**
  23046. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23047. */
  23048. scaling: Vector3;
  23049. /**
  23050. * Returns true if the mesh is blocked. Implemented by child classes
  23051. */
  23052. readonly isBlocked: boolean;
  23053. /**
  23054. * Returns the mesh itself by default. Implemented by child classes
  23055. * @param camera defines the camera to use to pick the right LOD level
  23056. * @returns the currentAbstractMesh
  23057. */
  23058. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23059. /**
  23060. * Returns 0 by default. Implemented by child classes
  23061. * @returns an integer
  23062. */
  23063. getTotalVertices(): number;
  23064. /**
  23065. * Returns a positive integer : the total number of indices in this mesh geometry.
  23066. * @returns the numner of indices or zero if the mesh has no geometry.
  23067. */
  23068. getTotalIndices(): number;
  23069. /**
  23070. * Returns null by default. Implemented by child classes
  23071. * @returns null
  23072. */
  23073. getIndices(): Nullable<IndicesArray>;
  23074. /**
  23075. * Returns the array of the requested vertex data kind. Implemented by child classes
  23076. * @param kind defines the vertex data kind to use
  23077. * @returns null
  23078. */
  23079. getVerticesData(kind: string): Nullable<FloatArray>;
  23080. /**
  23081. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23082. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23083. * Note that a new underlying VertexBuffer object is created each call.
  23084. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23085. * @param kind defines vertex data kind:
  23086. * * VertexBuffer.PositionKind
  23087. * * VertexBuffer.UVKind
  23088. * * VertexBuffer.UV2Kind
  23089. * * VertexBuffer.UV3Kind
  23090. * * VertexBuffer.UV4Kind
  23091. * * VertexBuffer.UV5Kind
  23092. * * VertexBuffer.UV6Kind
  23093. * * VertexBuffer.ColorKind
  23094. * * VertexBuffer.MatricesIndicesKind
  23095. * * VertexBuffer.MatricesIndicesExtraKind
  23096. * * VertexBuffer.MatricesWeightsKind
  23097. * * VertexBuffer.MatricesWeightsExtraKind
  23098. * @param data defines the data source
  23099. * @param updatable defines if the data must be flagged as updatable (or static)
  23100. * @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
  23101. * @returns the current mesh
  23102. */
  23103. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23104. /**
  23105. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23106. * If the mesh has no geometry, it is simply returned as it is.
  23107. * @param kind defines vertex data kind:
  23108. * * VertexBuffer.PositionKind
  23109. * * VertexBuffer.UVKind
  23110. * * VertexBuffer.UV2Kind
  23111. * * VertexBuffer.UV3Kind
  23112. * * VertexBuffer.UV4Kind
  23113. * * VertexBuffer.UV5Kind
  23114. * * VertexBuffer.UV6Kind
  23115. * * VertexBuffer.ColorKind
  23116. * * VertexBuffer.MatricesIndicesKind
  23117. * * VertexBuffer.MatricesIndicesExtraKind
  23118. * * VertexBuffer.MatricesWeightsKind
  23119. * * VertexBuffer.MatricesWeightsExtraKind
  23120. * @param data defines the data source
  23121. * @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
  23122. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23123. * @returns the current mesh
  23124. */
  23125. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23126. /**
  23127. * Sets the mesh indices,
  23128. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23129. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23130. * @param totalVertices Defines the total number of vertices
  23131. * @returns the current mesh
  23132. */
  23133. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23134. /**
  23135. * Gets a boolean indicating if specific vertex data is present
  23136. * @param kind defines the vertex data kind to use
  23137. * @returns true is data kind is present
  23138. */
  23139. isVerticesDataPresent(kind: string): boolean;
  23140. /**
  23141. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23142. * @returns a BoundingInfo
  23143. */
  23144. getBoundingInfo(): BoundingInfo;
  23145. /**
  23146. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23147. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  23148. * @returns the current mesh
  23149. */
  23150. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  23151. /**
  23152. * Overwrite the current bounding info
  23153. * @param boundingInfo defines the new bounding info
  23154. * @returns the current mesh
  23155. */
  23156. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23157. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23158. readonly useBones: boolean;
  23159. /** @hidden */ preActivate(): void;
  23160. /** @hidden */ preActivateForIntermediateRendering(renderId: number): void;
  23161. /** @hidden */ activate(renderId: number): void;
  23162. /**
  23163. * Gets the current world matrix
  23164. * @returns a Matrix
  23165. */
  23166. getWorldMatrix(): Matrix;
  23167. /** @hidden */ getWorldMatrixDeterminant(): number;
  23168. /**
  23169. * Perform relative position change from the point of view of behind the front of the mesh.
  23170. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23171. * Supports definition of mesh facing forward or backward
  23172. * @param amountRight defines the distance on the right axis
  23173. * @param amountUp defines the distance on the up axis
  23174. * @param amountForward defines the distance on the forward axis
  23175. * @returns the current mesh
  23176. */
  23177. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23178. /**
  23179. * Calculate relative position change from the point of view of behind the front of the mesh.
  23180. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23181. * Supports definition of mesh facing forward or backward
  23182. * @param amountRight defines the distance on the right axis
  23183. * @param amountUp defines the distance on the up axis
  23184. * @param amountForward defines the distance on the forward axis
  23185. * @returns the new displacement vector
  23186. */
  23187. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23188. /**
  23189. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23190. * Supports definition of mesh facing forward or backward
  23191. * @param flipBack defines the flip
  23192. * @param twirlClockwise defines the twirl
  23193. * @param tiltRight defines the tilt
  23194. * @returns the current mesh
  23195. */
  23196. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23197. /**
  23198. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23199. * Supports definition of mesh facing forward or backward.
  23200. * @param flipBack defines the flip
  23201. * @param twirlClockwise defines the twirl
  23202. * @param tiltRight defines the tilt
  23203. * @returns the new rotation vector
  23204. */
  23205. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23206. /**
  23207. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  23208. * @param includeDescendants Include bounding info from descendants as well (true by default)
  23209. * @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
  23210. * @returns the new bounding vectors
  23211. */
  23212. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  23213. min: Vector3;
  23214. max: Vector3;
  23215. };
  23216. /**
  23217. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23218. * This means the mesh underlying bounding box and sphere are recomputed.
  23219. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23220. * @returns the current mesh
  23221. */
  23222. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  23223. /** @hidden */ refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  23224. /** @hidden */ getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  23225. /** @hidden */ updateBoundingInfo(): AbstractMesh;
  23226. /** @hidden */ updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  23227. /** @hidden */
  23228. protected _afterComputeWorldMatrix(): void;
  23229. /**
  23230. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23231. * A mesh is in the frustum if its bounding box intersects the frustum
  23232. * @param frustumPlanes defines the frustum to test
  23233. * @returns true if the mesh is in the frustum planes
  23234. */
  23235. isInFrustum(frustumPlanes: Plane[]): boolean;
  23236. /**
  23237. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23238. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23239. * @param frustumPlanes defines the frustum to test
  23240. * @returns true if the mesh is completely in the frustum planes
  23241. */
  23242. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23243. /**
  23244. * True if the mesh intersects another mesh or a SolidParticle object
  23245. * @param mesh defines a target mesh or SolidParticle to test
  23246. * @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)
  23247. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23248. * @returns true if there is an intersection
  23249. */
  23250. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23251. /**
  23252. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23253. * @param point defines the point to test
  23254. * @returns true if there is an intersection
  23255. */
  23256. intersectsPoint(point: Vector3): boolean;
  23257. /**
  23258. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23259. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23260. */
  23261. checkCollisions: boolean;
  23262. /**
  23263. * Gets Collider object used to compute collisions (not physics)
  23264. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23265. */
  23266. readonly collider: Collider;
  23267. /**
  23268. * Move the mesh using collision engine
  23269. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23270. * @param displacement defines the requested displacement vector
  23271. * @returns the current mesh
  23272. */
  23273. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23274. private _onCollisionPositionChange;
  23275. /** @hidden */ collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23276. /** @hidden */ processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23277. /** @hidden */ checkCollision(collider: Collider): AbstractMesh;
  23278. /** @hidden */ generatePointsArray(): boolean;
  23279. /**
  23280. * Checks if the passed Ray intersects with the mesh
  23281. * @param ray defines the ray to use
  23282. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23283. * @returns the picking info
  23284. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23285. */
  23286. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  23287. /**
  23288. * Clones the current mesh
  23289. * @param name defines the mesh name
  23290. * @param newParent defines the new mesh parent
  23291. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23292. * @returns the new mesh
  23293. */
  23294. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  23295. /**
  23296. * Disposes all the submeshes of the current meshnp
  23297. * @returns the current mesh
  23298. */
  23299. releaseSubMeshes(): AbstractMesh;
  23300. /**
  23301. * Releases resources associated with this abstract mesh.
  23302. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23303. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23304. */
  23305. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23306. /**
  23307. * Adds the passed mesh as a child to the current mesh
  23308. * @param mesh defines the child mesh
  23309. * @returns the current mesh
  23310. */
  23311. addChild(mesh: AbstractMesh): AbstractMesh;
  23312. /**
  23313. * Removes the passed mesh from the current mesh children list
  23314. * @param mesh defines the child mesh
  23315. * @returns the current mesh
  23316. */
  23317. removeChild(mesh: AbstractMesh): AbstractMesh;
  23318. /** @hidden */
  23319. private _initFacetData;
  23320. /**
  23321. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  23322. * This method can be called within the render loop.
  23323. * 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
  23324. * @returns the current mesh
  23325. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23326. */
  23327. updateFacetData(): AbstractMesh;
  23328. /**
  23329. * Returns the facetLocalNormals array.
  23330. * The normals are expressed in the mesh local spac
  23331. * @returns an array of Vector3
  23332. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23333. */
  23334. getFacetLocalNormals(): Vector3[];
  23335. /**
  23336. * Returns the facetLocalPositions array.
  23337. * The facet positions are expressed in the mesh local space
  23338. * @returns an array of Vector3
  23339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23340. */
  23341. getFacetLocalPositions(): Vector3[];
  23342. /**
  23343. * Returns the facetLocalPartioning array
  23344. * @returns an array of array of numbers
  23345. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23346. */
  23347. getFacetLocalPartitioning(): number[][];
  23348. /**
  23349. * Returns the i-th facet position in the world system.
  23350. * This method allocates a new Vector3 per call
  23351. * @param i defines the facet index
  23352. * @returns a new Vector3
  23353. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23354. */
  23355. getFacetPosition(i: number): Vector3;
  23356. /**
  23357. * Sets the reference Vector3 with the i-th facet position in the world system
  23358. * @param i defines the facet index
  23359. * @param ref defines the target vector
  23360. * @returns the current mesh
  23361. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23362. */
  23363. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  23364. /**
  23365. * Returns the i-th facet normal in the world system.
  23366. * This method allocates a new Vector3 per call
  23367. * @param i defines the facet index
  23368. * @returns a new Vector3
  23369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23370. */
  23371. getFacetNormal(i: number): Vector3;
  23372. /**
  23373. * Sets the reference Vector3 with the i-th facet normal in the world system
  23374. * @param i defines the facet index
  23375. * @param ref defines the target vector
  23376. * @returns the current mesh
  23377. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23378. */
  23379. getFacetNormalToRef(i: number, ref: Vector3): this;
  23380. /**
  23381. * 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)
  23382. * @param x defines x coordinate
  23383. * @param y defines y coordinate
  23384. * @param z defines z coordinate
  23385. * @returns the array of facet indexes
  23386. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23387. */
  23388. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  23389. /**
  23390. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  23391. * @param projected sets as the (x,y,z) world projection on the facet
  23392. * @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
  23393. * @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
  23394. * @param x defines x coordinate
  23395. * @param y defines y coordinate
  23396. * @param z defines z coordinate
  23397. * @returns the face index if found (or null instead)
  23398. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23399. */
  23400. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23401. /**
  23402. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  23403. * @param projected sets as the (x,y,z) local projection on the facet
  23404. * @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
  23405. * @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
  23406. * @param x defines x coordinate
  23407. * @param y defines y coordinate
  23408. * @param z defines z coordinate
  23409. * @returns the face index if found (or null instead)
  23410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23411. */
  23412. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23413. /**
  23414. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  23415. * @returns the parameters
  23416. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23417. */
  23418. getFacetDataParameters(): any;
  23419. /**
  23420. * Disables the feature FacetData and frees the related memory
  23421. * @returns the current mesh
  23422. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23423. */
  23424. disableFacetData(): AbstractMesh;
  23425. /**
  23426. * Updates the AbstractMesh indices array
  23427. * @param indices defines the data source
  23428. * @returns the current mesh
  23429. */
  23430. updateIndices(indices: IndicesArray): AbstractMesh;
  23431. /**
  23432. * Creates new normals data for the mesh
  23433. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  23434. * @returns the current mesh
  23435. */
  23436. createNormals(updatable: boolean): AbstractMesh;
  23437. /**
  23438. * Align the mesh with a normal
  23439. * @param normal defines the normal to use
  23440. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  23441. * @returns the current mesh
  23442. */
  23443. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  23444. /** @hidden */ checkOcclusionQuery(): boolean;
  23445. }
  23446. }
  23447. declare module BABYLON {
  23448. /**
  23449. * Defines how a node can be built from a string name.
  23450. */
  23451. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  23452. /**
  23453. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  23454. */
  23455. export class Node implements IBehaviorAware<Node> {
  23456. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  23457. private static _NodeConstructors;
  23458. /**
  23459. * Add a new node constructor
  23460. * @param type defines the type name of the node to construct
  23461. * @param constructorFunc defines the constructor function
  23462. */
  23463. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  23464. /**
  23465. * Returns a node constructor based on type name
  23466. * @param type defines the type name
  23467. * @param name defines the new node name
  23468. * @param scene defines the hosting scene
  23469. * @param options defines optional options to transmit to constructors
  23470. * @returns the new constructor or null
  23471. */
  23472. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  23473. /**
  23474. * Gets or sets the name of the node
  23475. */
  23476. name: string;
  23477. /**
  23478. * Gets or sets the id of the node
  23479. */
  23480. id: string;
  23481. /**
  23482. * Gets or sets the unique id of the node
  23483. */
  23484. uniqueId: number;
  23485. /**
  23486. * Gets or sets a string used to store user defined state for the node
  23487. */
  23488. state: string;
  23489. /**
  23490. * Gets or sets an object used to store user defined information for the node
  23491. */
  23492. metadata: any;
  23493. /**
  23494. * For internal use only. Please do not use.
  23495. */
  23496. reservedDataStore: any;
  23497. /**
  23498. * Gets or sets a boolean used to define if the node must be serialized
  23499. */
  23500. doNotSerialize: boolean;
  23501. /** @hidden */ isDisposed: boolean;
  23502. /**
  23503. * Gets a list of Animations associated with the node
  23504. */
  23505. animations: Animation[];
  23506. protected _ranges: {
  23507. [name: string]: Nullable<AnimationRange>;
  23508. };
  23509. /**
  23510. * Callback raised when the node is ready to be used
  23511. */
  23512. onReady: (node: Node) => void;
  23513. private _isEnabled;
  23514. private _isParentEnabled;
  23515. private _isReady;
  23516. /** @hidden */ currentRenderId: number;
  23517. private _parentRenderId;
  23518. protected _childRenderId: number;
  23519. /** @hidden */ waitingParentId: Nullable<string>;
  23520. /** @hidden */ scene: Scene;
  23521. /** @hidden */ cache: any;
  23522. private _parentNode;
  23523. private _children;
  23524. /** @hidden */ worldMatrix: Matrix;
  23525. /** @hidden */ worldMatrixDeterminant: number;
  23526. /** @hidden */
  23527. private _sceneRootNodesIndex;
  23528. /**
  23529. * Gets a boolean indicating if the node has been disposed
  23530. * @returns true if the node was disposed
  23531. */
  23532. isDisposed(): boolean;
  23533. /**
  23534. * Gets or sets the parent of the node
  23535. */
  23536. parent: Nullable<Node>;
  23537. private addToSceneRootNodes;
  23538. private removeFromSceneRootNodes;
  23539. private _animationPropertiesOverride;
  23540. /**
  23541. * Gets or sets the animation properties override
  23542. */
  23543. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23544. /**
  23545. * Gets a string idenfifying the name of the class
  23546. * @returns "Node" string
  23547. */
  23548. getClassName(): string;
  23549. /** @hidden */ protected readonly _isNode: boolean;
  23550. /**
  23551. * An event triggered when the mesh is disposed
  23552. */
  23553. onDisposeObservable: Observable<Node>;
  23554. private _onDisposeObserver;
  23555. /**
  23556. * Sets a callback that will be raised when the node will be disposed
  23557. */
  23558. onDispose: () => void;
  23559. /**
  23560. * Creates a new Node
  23561. * @param name the name and id to be given to this node
  23562. * @param scene the scene this node will be added to
  23563. * @param addToRootNodes the node will be added to scene.rootNodes
  23564. */
  23565. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  23566. /**
  23567. * Gets the scene of the node
  23568. * @returns a scene
  23569. */
  23570. getScene(): Scene;
  23571. /**
  23572. * Gets the engine of the node
  23573. * @returns a Engine
  23574. */
  23575. getEngine(): Engine;
  23576. private _behaviors;
  23577. /**
  23578. * Attach a behavior to the node
  23579. * @see http://doc.babylonjs.com/features/behaviour
  23580. * @param behavior defines the behavior to attach
  23581. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  23582. * @returns the current Node
  23583. */
  23584. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  23585. /**
  23586. * Remove an attached behavior
  23587. * @see http://doc.babylonjs.com/features/behaviour
  23588. * @param behavior defines the behavior to attach
  23589. * @returns the current Node
  23590. */
  23591. removeBehavior(behavior: Behavior<Node>): Node;
  23592. /**
  23593. * Gets the list of attached behaviors
  23594. * @see http://doc.babylonjs.com/features/behaviour
  23595. */
  23596. readonly behaviors: Behavior<Node>[];
  23597. /**
  23598. * Gets an attached behavior by name
  23599. * @param name defines the name of the behavior to look for
  23600. * @see http://doc.babylonjs.com/features/behaviour
  23601. * @returns null if behavior was not found else the requested behavior
  23602. */
  23603. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  23604. /**
  23605. * Returns the latest update of the World matrix
  23606. * @returns a Matrix
  23607. */
  23608. getWorldMatrix(): Matrix;
  23609. /** @hidden */ getWorldMatrixDeterminant(): number;
  23610. /**
  23611. * Returns directly the latest state of the mesh World matrix.
  23612. * A Matrix is returned.
  23613. */
  23614. readonly worldMatrixFromCache: Matrix;
  23615. /** @hidden */ initCache(): void;
  23616. /** @hidden */
  23617. updateCache(force?: boolean): void;
  23618. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  23619. /** @hidden */ isSynchronized(): boolean;
  23620. /** @hidden */ markSyncedWithParent(): void;
  23621. /** @hidden */
  23622. isSynchronizedWithParent(): boolean;
  23623. /** @hidden */
  23624. isSynchronized(): boolean;
  23625. /**
  23626. * Is this node ready to be used/rendered
  23627. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23628. * @return true if the node is ready
  23629. */
  23630. isReady(completeCheck?: boolean): boolean;
  23631. /**
  23632. * Is this node enabled?
  23633. * 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
  23634. * @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
  23635. * @return whether this node (and its parent) is enabled
  23636. */
  23637. isEnabled(checkAncestors?: boolean): boolean;
  23638. /** @hidden */
  23639. protected _syncParentEnabledState(): void;
  23640. /**
  23641. * Set the enabled state of this node
  23642. * @param value defines the new enabled state
  23643. */
  23644. setEnabled(value: boolean): void;
  23645. /**
  23646. * Is this node a descendant of the given node?
  23647. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  23648. * @param ancestor defines the parent node to inspect
  23649. * @returns a boolean indicating if this node is a descendant of the given node
  23650. */
  23651. isDescendantOf(ancestor: Node): boolean;
  23652. /** @hidden */ getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  23653. /**
  23654. * Will return all nodes that have this node as ascendant
  23655. * @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
  23656. * @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
  23657. * @return all children nodes of all types
  23658. */
  23659. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  23660. /**
  23661. * Get all child-meshes of this node
  23662. * @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
  23663. * @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
  23664. * @returns an array of AbstractMesh
  23665. */
  23666. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  23667. /**
  23668. * Get all direct children of this node
  23669. * @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
  23670. * @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 (Default: true)
  23671. * @returns an array of Node
  23672. */
  23673. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  23674. /** @hidden */ setReady(state: boolean): void;
  23675. /**
  23676. * Get an animation by name
  23677. * @param name defines the name of the animation to look for
  23678. * @returns null if not found else the requested animation
  23679. */
  23680. getAnimationByName(name: string): Nullable<Animation>;
  23681. /**
  23682. * Creates an animation range for this node
  23683. * @param name defines the name of the range
  23684. * @param from defines the starting key
  23685. * @param to defines the end key
  23686. */
  23687. createAnimationRange(name: string, from: number, to: number): void;
  23688. /**
  23689. * Delete a specific animation range
  23690. * @param name defines the name of the range to delete
  23691. * @param deleteFrames defines if animation frames from the range must be deleted as well
  23692. */
  23693. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  23694. /**
  23695. * Get an animation range by name
  23696. * @param name defines the name of the animation range to look for
  23697. * @returns null if not found else the requested animation range
  23698. */
  23699. getAnimationRange(name: string): Nullable<AnimationRange>;
  23700. /**
  23701. * Will start the animation sequence
  23702. * @param name defines the range frames for animation sequence
  23703. * @param loop defines if the animation should loop (false by default)
  23704. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  23705. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  23706. * @returns the object created for this animation. If range does not exist, it will return null
  23707. */
  23708. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  23709. /**
  23710. * Serialize animation ranges into a JSON compatible object
  23711. * @returns serialization object
  23712. */
  23713. serializeAnimationRanges(): any;
  23714. /**
  23715. * Computes the world matrix of the node
  23716. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  23717. * @returns the world matrix
  23718. */
  23719. computeWorldMatrix(force?: boolean): Matrix;
  23720. /**
  23721. * Releases resources associated with this node.
  23722. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23723. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23724. */
  23725. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23726. /**
  23727. * Parse animation range data from a serialization object and store them into a given node
  23728. * @param node defines where to store the animation ranges
  23729. * @param parsedNode defines the serialization object to read data from
  23730. * @param scene defines the hosting scene
  23731. */
  23732. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  23733. }
  23734. }
  23735. declare module BABYLON {
  23736. /**
  23737. * Represents the range of an animation
  23738. */
  23739. export class AnimationRange {
  23740. /**The name of the animation range**/
  23741. name: string;
  23742. /**The starting frame of the animation */
  23743. from: number;
  23744. /**The ending frame of the animation*/
  23745. to: number;
  23746. /**
  23747. * Initializes the range of an animation
  23748. * @param name The name of the animation range
  23749. * @param from The starting frame of the animation
  23750. * @param to The ending frame of the animation
  23751. */
  23752. constructor(
  23753. /**The name of the animation range**/
  23754. name: string,
  23755. /**The starting frame of the animation */
  23756. from: number,
  23757. /**The ending frame of the animation*/
  23758. to: number);
  23759. /**
  23760. * Makes a copy of the animation range
  23761. * @returns A copy of the animation range
  23762. */
  23763. clone(): AnimationRange;
  23764. }
  23765. /**
  23766. * Composed of a frame, and an action function
  23767. */
  23768. export class AnimationEvent {
  23769. /** The frame for which the event is triggered **/
  23770. frame: number;
  23771. /** The event to perform when triggered **/
  23772. action: (currentFrame: number) => void;
  23773. /** Specifies if the event should be triggered only once**/
  23774. onlyOnce?: boolean | undefined;
  23775. /**
  23776. * Specifies if the animation event is done
  23777. */
  23778. isDone: boolean;
  23779. /**
  23780. * Initializes the animation event
  23781. * @param frame The frame for which the event is triggered
  23782. * @param action The event to perform when triggered
  23783. * @param onlyOnce Specifies if the event should be triggered only once
  23784. */
  23785. constructor(
  23786. /** The frame for which the event is triggered **/
  23787. frame: number,
  23788. /** The event to perform when triggered **/
  23789. action: (currentFrame: number) => void,
  23790. /** Specifies if the event should be triggered only once**/
  23791. onlyOnce?: boolean | undefined);
  23792. /** @hidden */ clone(): AnimationEvent;
  23793. }
  23794. /**
  23795. * A cursor which tracks a point on a path
  23796. */
  23797. export class PathCursor {
  23798. private path;
  23799. /**
  23800. * Stores path cursor callbacks for when an onchange event is triggered
  23801. */
  23802. private _onchange;
  23803. /**
  23804. * The value of the path cursor
  23805. */
  23806. value: number;
  23807. /**
  23808. * The animation array of the path cursor
  23809. */
  23810. animations: Animation[];
  23811. /**
  23812. * Initializes the path cursor
  23813. * @param path The path to track
  23814. */
  23815. constructor(path: Path2);
  23816. /**
  23817. * Gets the cursor point on the path
  23818. * @returns A point on the path cursor at the cursor location
  23819. */
  23820. getPoint(): Vector3;
  23821. /**
  23822. * Moves the cursor ahead by the step amount
  23823. * @param step The amount to move the cursor forward
  23824. * @returns This path cursor
  23825. */
  23826. moveAhead(step?: number): PathCursor;
  23827. /**
  23828. * Moves the cursor behind by the step amount
  23829. * @param step The amount to move the cursor back
  23830. * @returns This path cursor
  23831. */
  23832. moveBack(step?: number): PathCursor;
  23833. /**
  23834. * Moves the cursor by the step amount
  23835. * If the step amount is greater than one, an exception is thrown
  23836. * @param step The amount to move the cursor
  23837. * @returns This path cursor
  23838. */
  23839. move(step: number): PathCursor;
  23840. /**
  23841. * Ensures that the value is limited between zero and one
  23842. * @returns This path cursor
  23843. */
  23844. private ensureLimits;
  23845. /**
  23846. * Runs onchange callbacks on change (used by the animation engine)
  23847. * @returns This path cursor
  23848. */
  23849. private raiseOnChange;
  23850. /**
  23851. * Executes a function on change
  23852. * @param f A path cursor onchange callback
  23853. * @returns This path cursor
  23854. */
  23855. onchange(f: (cursor: PathCursor) => void): PathCursor;
  23856. }
  23857. /**
  23858. * Defines an interface which represents an animation key frame
  23859. */
  23860. export interface IAnimationKey {
  23861. /**
  23862. * Frame of the key frame
  23863. */
  23864. frame: number;
  23865. /**
  23866. * Value at the specifies key frame
  23867. */
  23868. value: any;
  23869. /**
  23870. * The input tangent for the cubic hermite spline
  23871. */
  23872. inTangent?: any;
  23873. /**
  23874. * The output tangent for the cubic hermite spline
  23875. */
  23876. outTangent?: any;
  23877. /**
  23878. * The animation interpolation type
  23879. */
  23880. interpolation?: AnimationKeyInterpolation;
  23881. }
  23882. /**
  23883. * Enum for the animation key frame interpolation type
  23884. */
  23885. export enum AnimationKeyInterpolation {
  23886. /**
  23887. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  23888. */
  23889. STEP = 1
  23890. }
  23891. /**
  23892. * Class used to store any kind of animation
  23893. */
  23894. export class Animation {
  23895. /**Name of the animation */
  23896. name: string;
  23897. /**Property to animate */
  23898. targetProperty: string;
  23899. /**The frames per second of the animation */
  23900. framePerSecond: number;
  23901. /**The data type of the animation */
  23902. dataType: number;
  23903. /**The loop mode of the animation */
  23904. loopMode?: number | undefined;
  23905. /**Specifies if blending should be enabled */
  23906. enableBlending?: boolean | undefined;
  23907. /**
  23908. * Use matrix interpolation instead of using direct key value when animating matrices
  23909. */
  23910. static AllowMatricesInterpolation: boolean;
  23911. /**
  23912. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  23913. */
  23914. static AllowMatrixDecomposeForInterpolation: boolean;
  23915. /**
  23916. * Stores the key frames of the animation
  23917. */
  23918. private _keys;
  23919. /**
  23920. * Stores the easing function of the animation
  23921. */
  23922. private _easingFunction;
  23923. /**
  23924. * @hidden Internal use only
  23925. */ runtimeAnimations: RuntimeAnimation[];
  23926. /**
  23927. * The set of event that will be linked to this animation
  23928. */
  23929. private _events;
  23930. /**
  23931. * Stores an array of target property paths
  23932. */
  23933. targetPropertyPath: string[];
  23934. /**
  23935. * Stores the blending speed of the animation
  23936. */
  23937. blendingSpeed: number;
  23938. /**
  23939. * Stores the animation ranges for the animation
  23940. */
  23941. private _ranges;
  23942. /**
  23943. * @hidden Internal use
  23944. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  23945. /**
  23946. * Sets up an animation
  23947. * @param property The property to animate
  23948. * @param animationType The animation type to apply
  23949. * @param framePerSecond The frames per second of the animation
  23950. * @param easingFunction The easing function used in the animation
  23951. * @returns The created animation
  23952. */
  23953. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  23954. /**
  23955. * Create and start an animation on a node
  23956. * @param name defines the name of the global animation that will be run on all nodes
  23957. * @param node defines the root node where the animation will take place
  23958. * @param targetProperty defines property to animate
  23959. * @param framePerSecond defines the number of frame per second yo use
  23960. * @param totalFrame defines the number of frames in total
  23961. * @param from defines the initial value
  23962. * @param to defines the final value
  23963. * @param loopMode defines which loop mode you want to use (off by default)
  23964. * @param easingFunction defines the easing function to use (linear by default)
  23965. * @param onAnimationEnd defines the callback to call when animation end
  23966. * @returns the animatable created for this animation
  23967. */
  23968. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  23969. /**
  23970. * Create and start an animation on a node and its descendants
  23971. * @param name defines the name of the global animation that will be run on all nodes
  23972. * @param node defines the root node where the animation will take place
  23973. * @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
  23974. * @param targetProperty defines property to animate
  23975. * @param framePerSecond defines the number of frame per second to use
  23976. * @param totalFrame defines the number of frames in total
  23977. * @param from defines the initial value
  23978. * @param to defines the final value
  23979. * @param loopMode defines which loop mode you want to use (off by default)
  23980. * @param easingFunction defines the easing function to use (linear by default)
  23981. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  23982. * @returns the list of animatables created for all nodes
  23983. * @example https://www.babylonjs-playground.com/#MH0VLI
  23984. */
  23985. 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[]>;
  23986. /**
  23987. * Creates a new animation, merges it with the existing animations and starts it
  23988. * @param name Name of the animation
  23989. * @param node Node which contains the scene that begins the animations
  23990. * @param targetProperty Specifies which property to animate
  23991. * @param framePerSecond The frames per second of the animation
  23992. * @param totalFrame The total number of frames
  23993. * @param from The frame at the beginning of the animation
  23994. * @param to The frame at the end of the animation
  23995. * @param loopMode Specifies the loop mode of the animation
  23996. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  23997. * @param onAnimationEnd Callback to run once the animation is complete
  23998. * @returns Nullable animation
  23999. */
  24000. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24001. /**
  24002. * Transition property of an host to the target Value
  24003. * @param property The property to transition
  24004. * @param targetValue The target Value of the property
  24005. * @param host The object where the property to animate belongs
  24006. * @param scene Scene used to run the animation
  24007. * @param frameRate Framerate (in frame/s) to use
  24008. * @param transition The transition type we want to use
  24009. * @param duration The duration of the animation, in milliseconds
  24010. * @param onAnimationEnd Callback trigger at the end of the animation
  24011. * @returns Nullable animation
  24012. */
  24013. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  24014. /**
  24015. * Return the array of runtime animations currently using this animation
  24016. */
  24017. readonly runtimeAnimations: RuntimeAnimation[];
  24018. /**
  24019. * Specifies if any of the runtime animations are currently running
  24020. */
  24021. readonly hasRunningRuntimeAnimations: boolean;
  24022. /**
  24023. * Initializes the animation
  24024. * @param name Name of the animation
  24025. * @param targetProperty Property to animate
  24026. * @param framePerSecond The frames per second of the animation
  24027. * @param dataType The data type of the animation
  24028. * @param loopMode The loop mode of the animation
  24029. * @param enableBlending Specifies if blending should be enabled
  24030. */
  24031. constructor(
  24032. /**Name of the animation */
  24033. name: string,
  24034. /**Property to animate */
  24035. targetProperty: string,
  24036. /**The frames per second of the animation */
  24037. framePerSecond: number,
  24038. /**The data type of the animation */
  24039. dataType: number,
  24040. /**The loop mode of the animation */
  24041. loopMode?: number | undefined,
  24042. /**Specifies if blending should be enabled */
  24043. enableBlending?: boolean | undefined);
  24044. /**
  24045. * Converts the animation to a string
  24046. * @param fullDetails support for multiple levels of logging within scene loading
  24047. * @returns String form of the animation
  24048. */
  24049. toString(fullDetails?: boolean): string;
  24050. /**
  24051. * Add an event to this animation
  24052. * @param event Event to add
  24053. */
  24054. addEvent(event: AnimationEvent): void;
  24055. /**
  24056. * Remove all events found at the given frame
  24057. * @param frame The frame to remove events from
  24058. */
  24059. removeEvents(frame: number): void;
  24060. /**
  24061. * Retrieves all the events from the animation
  24062. * @returns Events from the animation
  24063. */
  24064. getEvents(): AnimationEvent[];
  24065. /**
  24066. * Creates an animation range
  24067. * @param name Name of the animation range
  24068. * @param from Starting frame of the animation range
  24069. * @param to Ending frame of the animation
  24070. */
  24071. createRange(name: string, from: number, to: number): void;
  24072. /**
  24073. * Deletes an animation range by name
  24074. * @param name Name of the animation range to delete
  24075. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  24076. */
  24077. deleteRange(name: string, deleteFrames?: boolean): void;
  24078. /**
  24079. * Gets the animation range by name, or null if not defined
  24080. * @param name Name of the animation range
  24081. * @returns Nullable animation range
  24082. */
  24083. getRange(name: string): Nullable<AnimationRange>;
  24084. /**
  24085. * Gets the key frames from the animation
  24086. * @returns The key frames of the animation
  24087. */
  24088. getKeys(): Array<IAnimationKey>;
  24089. /**
  24090. * Gets the highest frame rate of the animation
  24091. * @returns Highest frame rate of the animation
  24092. */
  24093. getHighestFrame(): number;
  24094. /**
  24095. * Gets the easing function of the animation
  24096. * @returns Easing function of the animation
  24097. */
  24098. getEasingFunction(): IEasingFunction;
  24099. /**
  24100. * Sets the easing function of the animation
  24101. * @param easingFunction A custom mathematical formula for animation
  24102. */
  24103. setEasingFunction(easingFunction: EasingFunction): void;
  24104. /**
  24105. * Interpolates a scalar linearly
  24106. * @param startValue Start value of the animation curve
  24107. * @param endValue End value of the animation curve
  24108. * @param gradient Scalar amount to interpolate
  24109. * @returns Interpolated scalar value
  24110. */
  24111. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  24112. /**
  24113. * Interpolates a scalar cubically
  24114. * @param startValue Start value of the animation curve
  24115. * @param outTangent End tangent of the animation
  24116. * @param endValue End value of the animation curve
  24117. * @param inTangent Start tangent of the animation curve
  24118. * @param gradient Scalar amount to interpolate
  24119. * @returns Interpolated scalar value
  24120. */
  24121. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  24122. /**
  24123. * Interpolates a quaternion using a spherical linear interpolation
  24124. * @param startValue Start value of the animation curve
  24125. * @param endValue End value of the animation curve
  24126. * @param gradient Scalar amount to interpolate
  24127. * @returns Interpolated quaternion value
  24128. */
  24129. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  24130. /**
  24131. * Interpolates a quaternion cubically
  24132. * @param startValue Start value of the animation curve
  24133. * @param outTangent End tangent of the animation curve
  24134. * @param endValue End value of the animation curve
  24135. * @param inTangent Start tangent of the animation curve
  24136. * @param gradient Scalar amount to interpolate
  24137. * @returns Interpolated quaternion value
  24138. */
  24139. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  24140. /**
  24141. * Interpolates a Vector3 linearl
  24142. * @param startValue Start value of the animation curve
  24143. * @param endValue End value of the animation curve
  24144. * @param gradient Scalar amount to interpolate
  24145. * @returns Interpolated scalar value
  24146. */
  24147. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  24148. /**
  24149. * Interpolates a Vector3 cubically
  24150. * @param startValue Start value of the animation curve
  24151. * @param outTangent End tangent of the animation
  24152. * @param endValue End value of the animation curve
  24153. * @param inTangent Start tangent of the animation curve
  24154. * @param gradient Scalar amount to interpolate
  24155. * @returns InterpolatedVector3 value
  24156. */
  24157. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  24158. /**
  24159. * Interpolates a Vector2 linearly
  24160. * @param startValue Start value of the animation curve
  24161. * @param endValue End value of the animation curve
  24162. * @param gradient Scalar amount to interpolate
  24163. * @returns Interpolated Vector2 value
  24164. */
  24165. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  24166. /**
  24167. * Interpolates a Vector2 cubically
  24168. * @param startValue Start value of the animation curve
  24169. * @param outTangent End tangent of the animation
  24170. * @param endValue End value of the animation curve
  24171. * @param inTangent Start tangent of the animation curve
  24172. * @param gradient Scalar amount to interpolate
  24173. * @returns Interpolated Vector2 value
  24174. */
  24175. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  24176. /**
  24177. * Interpolates a size linearly
  24178. * @param startValue Start value of the animation curve
  24179. * @param endValue End value of the animation curve
  24180. * @param gradient Scalar amount to interpolate
  24181. * @returns Interpolated Size value
  24182. */
  24183. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  24184. /**
  24185. * Interpolates a Color3 linearly
  24186. * @param startValue Start value of the animation curve
  24187. * @param endValue End value of the animation curve
  24188. * @param gradient Scalar amount to interpolate
  24189. * @returns Interpolated Color3 value
  24190. */
  24191. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  24192. /**
  24193. * @hidden Internal use only
  24194. */ getKeyValue(value: any): any;
  24195. /**
  24196. * @hidden Internal use only
  24197. */ interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  24198. /**
  24199. * Defines the function to use to interpolate matrices
  24200. * @param startValue defines the start matrix
  24201. * @param endValue defines the end matrix
  24202. * @param gradient defines the gradient between both matrices
  24203. * @param result defines an optional target matrix where to store the interpolation
  24204. * @returns the interpolated matrix
  24205. */
  24206. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  24207. /**
  24208. * Makes a copy of the animation
  24209. * @returns Cloned animation
  24210. */
  24211. clone(): Animation;
  24212. /**
  24213. * Sets the key frames of the animation
  24214. * @param values The animation key frames to set
  24215. */
  24216. setKeys(values: Array<IAnimationKey>): void;
  24217. /**
  24218. * Serializes the animation to an object
  24219. * @returns Serialized object
  24220. */
  24221. serialize(): any;
  24222. /**
  24223. * Float animation type
  24224. */
  24225. private static _ANIMATIONTYPE_FLOAT;
  24226. /**
  24227. * Vector3 animation type
  24228. */
  24229. private static _ANIMATIONTYPE_VECTOR3;
  24230. /**
  24231. * Quaternion animation type
  24232. */
  24233. private static _ANIMATIONTYPE_QUATERNION;
  24234. /**
  24235. * Matrix animation type
  24236. */
  24237. private static _ANIMATIONTYPE_MATRIX;
  24238. /**
  24239. * Color3 animation type
  24240. */
  24241. private static _ANIMATIONTYPE_COLOR3;
  24242. /**
  24243. * Vector2 animation type
  24244. */
  24245. private static _ANIMATIONTYPE_VECTOR2;
  24246. /**
  24247. * Size animation type
  24248. */
  24249. private static _ANIMATIONTYPE_SIZE;
  24250. /**
  24251. * Relative Loop Mode
  24252. */
  24253. private static _ANIMATIONLOOPMODE_RELATIVE;
  24254. /**
  24255. * Cycle Loop Mode
  24256. */
  24257. private static _ANIMATIONLOOPMODE_CYCLE;
  24258. /**
  24259. * Constant Loop Mode
  24260. */
  24261. private static _ANIMATIONLOOPMODE_CONSTANT;
  24262. /**
  24263. * Get the float animation type
  24264. */
  24265. static readonly ANIMATIONTYPE_FLOAT: number;
  24266. /**
  24267. * Get the Vector3 animation type
  24268. */
  24269. static readonly ANIMATIONTYPE_VECTOR3: number;
  24270. /**
  24271. * Get the Vector2 animation type
  24272. */
  24273. static readonly ANIMATIONTYPE_VECTOR2: number;
  24274. /**
  24275. * Get the Size animation type
  24276. */
  24277. static readonly ANIMATIONTYPE_SIZE: number;
  24278. /**
  24279. * Get the Quaternion animation type
  24280. */
  24281. static readonly ANIMATIONTYPE_QUATERNION: number;
  24282. /**
  24283. * Get the Matrix animation type
  24284. */
  24285. static readonly ANIMATIONTYPE_MATRIX: number;
  24286. /**
  24287. * Get the Color3 animation type
  24288. */
  24289. static readonly ANIMATIONTYPE_COLOR3: number;
  24290. /**
  24291. * Get the Relative Loop Mode
  24292. */
  24293. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  24294. /**
  24295. * Get the Cycle Loop Mode
  24296. */
  24297. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  24298. /**
  24299. * Get the Constant Loop Mode
  24300. */
  24301. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  24302. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  24303. /**
  24304. * Parses an animation object and creates an animation
  24305. * @param parsedAnimation Parsed animation object
  24306. * @returns Animation object
  24307. */
  24308. static Parse(parsedAnimation: any): Animation;
  24309. /**
  24310. * Appends the serialized animations from the source animations
  24311. * @param source Source containing the animations
  24312. * @param destination Target to store the animations
  24313. */
  24314. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  24315. }
  24316. }
  24317. declare module BABYLON {
  24318. /**
  24319. * Base class of all the textures in babylon.
  24320. * It groups all the common properties the materials, post process, lights... might need
  24321. * in order to make a correct use of the texture.
  24322. */
  24323. export class BaseTexture implements IAnimatable {
  24324. /**
  24325. * Default anisotropic filtering level for the application.
  24326. * It is set to 4 as a good tradeoff between perf and quality.
  24327. */
  24328. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  24329. /**
  24330. * Gets or sets the unique id of the texture
  24331. */
  24332. uniqueId: number;
  24333. /**
  24334. * Define the name of the texture.
  24335. */
  24336. name: string;
  24337. /**
  24338. * Gets or sets an object used to store user defined information.
  24339. */
  24340. metadata: any;
  24341. /**
  24342. * For internal use only. Please do not use.
  24343. */
  24344. reservedDataStore: any;
  24345. private _hasAlpha;
  24346. /**
  24347. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  24348. */
  24349. hasAlpha: boolean;
  24350. /**
  24351. * Defines if the alpha value should be determined via the rgb values.
  24352. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  24353. */
  24354. getAlphaFromRGB: boolean;
  24355. /**
  24356. * Intensity or strength of the texture.
  24357. * It is commonly used by materials to fine tune the intensity of the texture
  24358. */
  24359. level: number;
  24360. /**
  24361. * Define the UV chanel to use starting from 0 and defaulting to 0.
  24362. * This is part of the texture as textures usually maps to one uv set.
  24363. */
  24364. coordinatesIndex: number;
  24365. private _coordinatesMode;
  24366. /**
  24367. * How a texture is mapped.
  24368. *
  24369. * | Value | Type | Description |
  24370. * | ----- | ----------------------------------- | ----------- |
  24371. * | 0 | EXPLICIT_MODE | |
  24372. * | 1 | SPHERICAL_MODE | |
  24373. * | 2 | PLANAR_MODE | |
  24374. * | 3 | CUBIC_MODE | |
  24375. * | 4 | PROJECTION_MODE | |
  24376. * | 5 | SKYBOX_MODE | |
  24377. * | 6 | INVCUBIC_MODE | |
  24378. * | 7 | EQUIRECTANGULAR_MODE | |
  24379. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  24380. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  24381. */
  24382. coordinatesMode: number;
  24383. /**
  24384. * | Value | Type | Description |
  24385. * | ----- | ------------------ | ----------- |
  24386. * | 0 | CLAMP_ADDRESSMODE | |
  24387. * | 1 | WRAP_ADDRESSMODE | |
  24388. * | 2 | MIRROR_ADDRESSMODE | |
  24389. */
  24390. wrapU: number;
  24391. /**
  24392. * | Value | Type | Description |
  24393. * | ----- | ------------------ | ----------- |
  24394. * | 0 | CLAMP_ADDRESSMODE | |
  24395. * | 1 | WRAP_ADDRESSMODE | |
  24396. * | 2 | MIRROR_ADDRESSMODE | |
  24397. */
  24398. wrapV: number;
  24399. /**
  24400. * | Value | Type | Description |
  24401. * | ----- | ------------------ | ----------- |
  24402. * | 0 | CLAMP_ADDRESSMODE | |
  24403. * | 1 | WRAP_ADDRESSMODE | |
  24404. * | 2 | MIRROR_ADDRESSMODE | |
  24405. */
  24406. wrapR: number;
  24407. /**
  24408. * With compliant hardware and browser (supporting anisotropic filtering)
  24409. * this defines the level of anisotropic filtering in the texture.
  24410. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  24411. */
  24412. anisotropicFilteringLevel: number;
  24413. /**
  24414. * Define if the texture is a cube texture or if false a 2d texture.
  24415. */
  24416. isCube: boolean;
  24417. /**
  24418. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  24419. */
  24420. is3D: boolean;
  24421. /**
  24422. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  24423. * HDR texture are usually stored in linear space.
  24424. * This only impacts the PBR and Background materials
  24425. */
  24426. gammaSpace: boolean;
  24427. /**
  24428. * Gets whether or not the texture contains RGBD data.
  24429. */
  24430. readonly isRGBD: boolean;
  24431. /**
  24432. * Is Z inverted in the texture (useful in a cube texture).
  24433. */
  24434. invertZ: boolean;
  24435. /**
  24436. * Are mip maps generated for this texture or not.
  24437. */
  24438. readonly noMipmap: boolean;
  24439. /**
  24440. * @hidden
  24441. */
  24442. lodLevelInAlpha: boolean;
  24443. /**
  24444. * With prefiltered texture, defined the offset used during the prefiltering steps.
  24445. */
  24446. lodGenerationOffset: number;
  24447. /**
  24448. * With prefiltered texture, defined the scale used during the prefiltering steps.
  24449. */
  24450. lodGenerationScale: number;
  24451. /**
  24452. * Define if the texture is a render target.
  24453. */
  24454. isRenderTarget: boolean;
  24455. /**
  24456. * Define the unique id of the texture in the scene.
  24457. */
  24458. readonly uid: string;
  24459. /**
  24460. * Return a string representation of the texture.
  24461. * @returns the texture as a string
  24462. */
  24463. toString(): string;
  24464. /**
  24465. * Get the class name of the texture.
  24466. * @returns "BaseTexture"
  24467. */
  24468. getClassName(): string;
  24469. /**
  24470. * Define the list of animation attached to the texture.
  24471. */
  24472. animations: Animation[];
  24473. /**
  24474. * An event triggered when the texture is disposed.
  24475. */
  24476. onDisposeObservable: Observable<BaseTexture>;
  24477. private _onDisposeObserver;
  24478. /**
  24479. * Callback triggered when the texture has been disposed.
  24480. * Kept for back compatibility, you can use the onDisposeObservable instead.
  24481. */
  24482. onDispose: () => void;
  24483. /**
  24484. * Define the current state of the loading sequence when in delayed load mode.
  24485. */
  24486. delayLoadState: number;
  24487. private _scene;
  24488. /** @hidden */ texture: Nullable<InternalTexture>;
  24489. private _uid;
  24490. /**
  24491. * Define if the texture is preventinga material to render or not.
  24492. * If not and the texture is not ready, the engine will use a default black texture instead.
  24493. */
  24494. readonly isBlocking: boolean;
  24495. /**
  24496. * Instantiates a new BaseTexture.
  24497. * Base class of all the textures in babylon.
  24498. * It groups all the common properties the materials, post process, lights... might need
  24499. * in order to make a correct use of the texture.
  24500. * @param scene Define the scene the texture blongs to
  24501. */
  24502. constructor(scene: Nullable<Scene>);
  24503. /**
  24504. * Get the scene the texture belongs to.
  24505. * @returns the scene or null if undefined
  24506. */
  24507. getScene(): Nullable<Scene>;
  24508. /**
  24509. * Get the texture transform matrix used to offset tile the texture for istance.
  24510. * @returns the transformation matrix
  24511. */
  24512. getTextureMatrix(): Matrix;
  24513. /**
  24514. * Get the texture reflection matrix used to rotate/transform the reflection.
  24515. * @returns the reflection matrix
  24516. */
  24517. getReflectionTextureMatrix(): Matrix;
  24518. /**
  24519. * Get the underlying lower level texture from Babylon.
  24520. * @returns the insternal texture
  24521. */
  24522. getInternalTexture(): Nullable<InternalTexture>;
  24523. /**
  24524. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  24525. * @returns true if ready or not blocking
  24526. */
  24527. isReadyOrNotBlocking(): boolean;
  24528. /**
  24529. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  24530. * @returns true if fully ready
  24531. */
  24532. isReady(): boolean;
  24533. private _cachedSize;
  24534. /**
  24535. * Get the size of the texture.
  24536. * @returns the texture size.
  24537. */
  24538. getSize(): ISize;
  24539. /**
  24540. * Get the base size of the texture.
  24541. * It can be different from the size if the texture has been resized for POT for instance
  24542. * @returns the base size
  24543. */
  24544. getBaseSize(): ISize;
  24545. /**
  24546. * Update the sampling mode of the texture.
  24547. * Default is Trilinear mode.
  24548. *
  24549. * | Value | Type | Description |
  24550. * | ----- | ------------------ | ----------- |
  24551. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  24552. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  24553. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  24554. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  24555. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  24556. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  24557. * | 7 | NEAREST_LINEAR | |
  24558. * | 8 | NEAREST_NEAREST | |
  24559. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  24560. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  24561. * | 11 | LINEAR_LINEAR | |
  24562. * | 12 | LINEAR_NEAREST | |
  24563. *
  24564. * > _mag_: magnification filter (close to the viewer)
  24565. * > _min_: minification filter (far from the viewer)
  24566. * > _mip_: filter used between mip map levels
  24567. *@param samplingMode Define the new sampling mode of the texture
  24568. */
  24569. updateSamplingMode(samplingMode: number): void;
  24570. /**
  24571. * Scales the texture if is `canRescale()`
  24572. * @param ratio the resize factor we want to use to rescale
  24573. */
  24574. scale(ratio: number): void;
  24575. /**
  24576. * Get if the texture can rescale.
  24577. */
  24578. readonly canRescale: boolean;
  24579. /** @hidden */ getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  24580. /** @hidden */ rebuild(): void;
  24581. /**
  24582. * Triggers the load sequence in delayed load mode.
  24583. */
  24584. delayLoad(): void;
  24585. /**
  24586. * Clones the texture.
  24587. * @returns the cloned texture
  24588. */
  24589. clone(): Nullable<BaseTexture>;
  24590. /**
  24591. * Get the texture underlying type (INT, FLOAT...)
  24592. */
  24593. readonly textureType: number;
  24594. /**
  24595. * Get the texture underlying format (RGB, RGBA...)
  24596. */
  24597. readonly textureFormat: number;
  24598. /**
  24599. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  24600. * This will returns an RGBA array buffer containing either in values (0-255) or
  24601. * float values (0-1) depending of the underlying buffer type.
  24602. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  24603. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  24604. * @param buffer defines a user defined buffer to fill with data (can be null)
  24605. * @returns The Array buffer containing the pixels data.
  24606. */
  24607. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  24608. /**
  24609. * Release and destroy the underlying lower level texture aka internalTexture.
  24610. */
  24611. releaseInternalTexture(): void;
  24612. /**
  24613. * Get the polynomial representation of the texture data.
  24614. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  24615. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  24616. */
  24617. sphericalPolynomial: Nullable<SphericalPolynomial>;
  24618. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  24619. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  24620. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  24621. /**
  24622. * Dispose the texture and release its associated resources.
  24623. */
  24624. dispose(): void;
  24625. /**
  24626. * Serialize the texture into a JSON representation that can be parsed later on.
  24627. * @returns the JSON representation of the texture
  24628. */
  24629. serialize(): any;
  24630. /**
  24631. * Helper function to be called back once a list of texture contains only ready textures.
  24632. * @param textures Define the list of textures to wait for
  24633. * @param callback Define the callback triggered once the entire list will be ready
  24634. */
  24635. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  24636. }
  24637. }
  24638. declare module BABYLON {
  24639. /**
  24640. * Uniform buffer objects.
  24641. *
  24642. * Handles blocks of uniform on the GPU.
  24643. *
  24644. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  24645. *
  24646. * For more information, please refer to :
  24647. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  24648. */
  24649. export class UniformBuffer {
  24650. private _engine;
  24651. private _buffer;
  24652. private _data;
  24653. private _bufferData;
  24654. private _dynamic?;
  24655. private _uniformLocations;
  24656. private _uniformSizes;
  24657. private _uniformLocationPointer;
  24658. private _needSync;
  24659. private _noUBO;
  24660. private _currentEffect;
  24661. private static _MAX_UNIFORM_SIZE;
  24662. private static _tempBuffer;
  24663. /**
  24664. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  24665. * This is dynamic to allow compat with webgl 1 and 2.
  24666. * You will need to pass the name of the uniform as well as the value.
  24667. */
  24668. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  24669. /**
  24670. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  24671. * This is dynamic to allow compat with webgl 1 and 2.
  24672. * You will need to pass the name of the uniform as well as the value.
  24673. */
  24674. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  24675. /**
  24676. * Lambda to Update a single float in a uniform buffer.
  24677. * This is dynamic to allow compat with webgl 1 and 2.
  24678. * You will need to pass the name of the uniform as well as the value.
  24679. */
  24680. updateFloat: (name: string, x: number) => void;
  24681. /**
  24682. * Lambda to Update a vec2 of float in a uniform buffer.
  24683. * This is dynamic to allow compat with webgl 1 and 2.
  24684. * You will need to pass the name of the uniform as well as the value.
  24685. */
  24686. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  24687. /**
  24688. * Lambda to Update a vec3 of float in a uniform buffer.
  24689. * This is dynamic to allow compat with webgl 1 and 2.
  24690. * You will need to pass the name of the uniform as well as the value.
  24691. */
  24692. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  24693. /**
  24694. * Lambda to Update a vec4 of float in a uniform buffer.
  24695. * This is dynamic to allow compat with webgl 1 and 2.
  24696. * You will need to pass the name of the uniform as well as the value.
  24697. */
  24698. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  24699. /**
  24700. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  24701. * This is dynamic to allow compat with webgl 1 and 2.
  24702. * You will need to pass the name of the uniform as well as the value.
  24703. */
  24704. updateMatrix: (name: string, mat: Matrix) => void;
  24705. /**
  24706. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  24707. * This is dynamic to allow compat with webgl 1 and 2.
  24708. * You will need to pass the name of the uniform as well as the value.
  24709. */
  24710. updateVector3: (name: string, vector: Vector3) => void;
  24711. /**
  24712. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  24713. * This is dynamic to allow compat with webgl 1 and 2.
  24714. * You will need to pass the name of the uniform as well as the value.
  24715. */
  24716. updateVector4: (name: string, vector: Vector4) => void;
  24717. /**
  24718. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  24719. * This is dynamic to allow compat with webgl 1 and 2.
  24720. * You will need to pass the name of the uniform as well as the value.
  24721. */
  24722. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  24723. /**
  24724. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  24725. * This is dynamic to allow compat with webgl 1 and 2.
  24726. * You will need to pass the name of the uniform as well as the value.
  24727. */
  24728. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  24729. /**
  24730. * Instantiates a new Uniform buffer objects.
  24731. *
  24732. * Handles blocks of uniform on the GPU.
  24733. *
  24734. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  24735. *
  24736. * For more information, please refer to :
  24737. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  24738. * @param engine Define the engine the buffer is associated with
  24739. * @param data Define the data contained in the buffer
  24740. * @param dynamic Define if the buffer is updatable
  24741. */
  24742. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  24743. /**
  24744. * Indicates if the buffer is using the WebGL2 UBO implementation,
  24745. * or just falling back on setUniformXXX calls.
  24746. */
  24747. readonly useUbo: boolean;
  24748. /**
  24749. * Indicates if the WebGL underlying uniform buffer is in sync
  24750. * with the javascript cache data.
  24751. */
  24752. readonly isSync: boolean;
  24753. /**
  24754. * Indicates if the WebGL underlying uniform buffer is dynamic.
  24755. * Also, a dynamic UniformBuffer will disable cache verification and always
  24756. * update the underlying WebGL uniform buffer to the GPU.
  24757. * @returns if Dynamic, otherwise false
  24758. */
  24759. isDynamic(): boolean;
  24760. /**
  24761. * The data cache on JS side.
  24762. * @returns the underlying data as a float array
  24763. */
  24764. getData(): Float32Array;
  24765. /**
  24766. * The underlying WebGL Uniform buffer.
  24767. * @returns the webgl buffer
  24768. */
  24769. getBuffer(): Nullable<WebGLBuffer>;
  24770. /**
  24771. * std140 layout specifies how to align data within an UBO structure.
  24772. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  24773. * for specs.
  24774. */
  24775. private _fillAlignment;
  24776. /**
  24777. * Adds an uniform in the buffer.
  24778. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  24779. * for the layout to be correct !
  24780. * @param name Name of the uniform, as used in the uniform block in the shader.
  24781. * @param size Data size, or data directly.
  24782. */
  24783. addUniform(name: string, size: number | number[]): void;
  24784. /**
  24785. * Adds a Matrix 4x4 to the uniform buffer.
  24786. * @param name Name of the uniform, as used in the uniform block in the shader.
  24787. * @param mat A 4x4 matrix.
  24788. */
  24789. addMatrix(name: string, mat: Matrix): void;
  24790. /**
  24791. * Adds a vec2 to the uniform buffer.
  24792. * @param name Name of the uniform, as used in the uniform block in the shader.
  24793. * @param x Define the x component value of the vec2
  24794. * @param y Define the y component value of the vec2
  24795. */
  24796. addFloat2(name: string, x: number, y: number): void;
  24797. /**
  24798. * Adds a vec3 to the uniform buffer.
  24799. * @param name Name of the uniform, as used in the uniform block in the shader.
  24800. * @param x Define the x component value of the vec3
  24801. * @param y Define the y component value of the vec3
  24802. * @param z Define the z component value of the vec3
  24803. */
  24804. addFloat3(name: string, x: number, y: number, z: number): void;
  24805. /**
  24806. * Adds a vec3 to the uniform buffer.
  24807. * @param name Name of the uniform, as used in the uniform block in the shader.
  24808. * @param color Define the vec3 from a Color
  24809. */
  24810. addColor3(name: string, color: Color3): void;
  24811. /**
  24812. * Adds a vec4 to the uniform buffer.
  24813. * @param name Name of the uniform, as used in the uniform block in the shader.
  24814. * @param color Define the rgb components from a Color
  24815. * @param alpha Define the a component of the vec4
  24816. */
  24817. addColor4(name: string, color: Color3, alpha: number): void;
  24818. /**
  24819. * Adds a vec3 to the uniform buffer.
  24820. * @param name Name of the uniform, as used in the uniform block in the shader.
  24821. * @param vector Define the vec3 components from a Vector
  24822. */
  24823. addVector3(name: string, vector: Vector3): void;
  24824. /**
  24825. * Adds a Matrix 3x3 to the uniform buffer.
  24826. * @param name Name of the uniform, as used in the uniform block in the shader.
  24827. */
  24828. addMatrix3x3(name: string): void;
  24829. /**
  24830. * Adds a Matrix 2x2 to the uniform buffer.
  24831. * @param name Name of the uniform, as used in the uniform block in the shader.
  24832. */
  24833. addMatrix2x2(name: string): void;
  24834. /**
  24835. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  24836. */
  24837. create(): void;
  24838. /** @hidden */ rebuild(): void;
  24839. /**
  24840. * Updates the WebGL Uniform Buffer on the GPU.
  24841. * If the `dynamic` flag is set to true, no cache comparison is done.
  24842. * Otherwise, the buffer will be updated only if the cache differs.
  24843. */
  24844. update(): void;
  24845. /**
  24846. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  24847. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  24848. * @param data Define the flattened data
  24849. * @param size Define the size of the data.
  24850. */
  24851. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  24852. private _updateMatrix3x3ForUniform;
  24853. private _updateMatrix3x3ForEffect;
  24854. private _updateMatrix2x2ForEffect;
  24855. private _updateMatrix2x2ForUniform;
  24856. private _updateFloatForEffect;
  24857. private _updateFloatForUniform;
  24858. private _updateFloat2ForEffect;
  24859. private _updateFloat2ForUniform;
  24860. private _updateFloat3ForEffect;
  24861. private _updateFloat3ForUniform;
  24862. private _updateFloat4ForEffect;
  24863. private _updateFloat4ForUniform;
  24864. private _updateMatrixForEffect;
  24865. private _updateMatrixForUniform;
  24866. private _updateVector3ForEffect;
  24867. private _updateVector3ForUniform;
  24868. private _updateVector4ForEffect;
  24869. private _updateVector4ForUniform;
  24870. private _updateColor3ForEffect;
  24871. private _updateColor3ForUniform;
  24872. private _updateColor4ForEffect;
  24873. private _updateColor4ForUniform;
  24874. /**
  24875. * Sets a sampler uniform on the effect.
  24876. * @param name Define the name of the sampler.
  24877. * @param texture Define the texture to set in the sampler
  24878. */
  24879. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  24880. /**
  24881. * Directly updates the value of the uniform in the cache AND on the GPU.
  24882. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  24883. * @param data Define the flattened data
  24884. */
  24885. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  24886. /**
  24887. * Binds this uniform buffer to an effect.
  24888. * @param effect Define the effect to bind the buffer to
  24889. * @param name Name of the uniform block in the shader.
  24890. */
  24891. bindToEffect(effect: Effect, name: string): void;
  24892. /**
  24893. * Disposes the uniform buffer.
  24894. */
  24895. dispose(): void;
  24896. }
  24897. }
  24898. declare module BABYLON {
  24899. /**
  24900. * This represents the required contract to create a new type of texture loader.
  24901. */
  24902. export interface IInternalTextureLoader {
  24903. /**
  24904. * Defines wether the loader supports cascade loading the different faces.
  24905. */
  24906. supportCascades: boolean;
  24907. /**
  24908. * This returns if the loader support the current file information.
  24909. * @param extension defines the file extension of the file being loaded
  24910. * @param textureFormatInUse defines the current compressed format in use iun the engine
  24911. * @param fallback defines the fallback internal texture if any
  24912. * @param isBase64 defines whether the texture is encoded as a base64
  24913. * @param isBuffer defines whether the texture data are stored as a buffer
  24914. * @returns true if the loader can load the specified file
  24915. */
  24916. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  24917. /**
  24918. * Transform the url before loading if required.
  24919. * @param rootUrl the url of the texture
  24920. * @param textureFormatInUse defines the current compressed format in use iun the engine
  24921. * @returns the transformed texture
  24922. */
  24923. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  24924. /**
  24925. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  24926. * @param rootUrl the url of the texture
  24927. * @param textureFormatInUse defines the current compressed format in use iun the engine
  24928. * @returns the fallback texture
  24929. */
  24930. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  24931. /**
  24932. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  24933. * @param data contains the texture data
  24934. * @param texture defines the BabylonJS internal texture
  24935. * @param createPolynomials will be true if polynomials have been requested
  24936. * @param onLoad defines the callback to trigger once the texture is ready
  24937. * @param onError defines the callback to trigger in case of error
  24938. */
  24939. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  24940. /**
  24941. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  24942. * @param data contains the texture data
  24943. * @param texture defines the BabylonJS internal texture
  24944. * @param callback defines the method to call once ready to upload
  24945. */
  24946. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  24947. }
  24948. }
  24949. declare module BABYLON {
  24950. /**
  24951. * Creation options of the multi render target texture.
  24952. */
  24953. export interface IMultiRenderTargetOptions {
  24954. /**
  24955. * Define if the texture needs to create mip maps after render.
  24956. */
  24957. generateMipMaps?: boolean;
  24958. /**
  24959. * Define the types of all the draw buffers we want to create
  24960. */
  24961. types?: number[];
  24962. /**
  24963. * Define the sampling modes of all the draw buffers we want to create
  24964. */
  24965. samplingModes?: number[];
  24966. /**
  24967. * Define if a depth buffer is required
  24968. */
  24969. generateDepthBuffer?: boolean;
  24970. /**
  24971. * Define if a stencil buffer is required
  24972. */
  24973. generateStencilBuffer?: boolean;
  24974. /**
  24975. * Define if a depth texture is required instead of a depth buffer
  24976. */
  24977. generateDepthTexture?: boolean;
  24978. /**
  24979. * Define the number of desired draw buffers
  24980. */
  24981. textureCount?: number;
  24982. /**
  24983. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24984. */
  24985. doNotChangeAspectRatio?: boolean;
  24986. /**
  24987. * Define the default type of the buffers we are creating
  24988. */
  24989. defaultType?: number;
  24990. }
  24991. /**
  24992. * A multi render target, like a render target provides the ability to render to a texture.
  24993. * Unlike the render target, it can render to several draw buffers in one draw.
  24994. * This is specially interesting in deferred rendering or for any effects requiring more than
  24995. * just one color from a single pass.
  24996. */
  24997. export class MultiRenderTarget extends RenderTargetTexture {
  24998. private _internalTextures;
  24999. private _textures;
  25000. private _multiRenderTargetOptions;
  25001. /**
  25002. * Get if draw buffers are currently supported by the used hardware and browser.
  25003. */
  25004. readonly isSupported: boolean;
  25005. /**
  25006. * Get the list of textures generated by the multi render target.
  25007. */
  25008. readonly textures: Texture[];
  25009. /**
  25010. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25011. */
  25012. readonly depthTexture: Texture;
  25013. /**
  25014. * Set the wrapping mode on U of all the textures we are rendering to.
  25015. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25016. */
  25017. wrapU: number;
  25018. /**
  25019. * Set the wrapping mode on V of all the textures we are rendering to.
  25020. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25021. */
  25022. wrapV: number;
  25023. /**
  25024. * Instantiate a new multi render target texture.
  25025. * A multi render target, like a render target provides the ability to render to a texture.
  25026. * Unlike the render target, it can render to several draw buffers in one draw.
  25027. * This is specially interesting in deferred rendering or for any effects requiring more than
  25028. * just one color from a single pass.
  25029. * @param name Define the name of the texture
  25030. * @param size Define the size of the buffers to render to
  25031. * @param count Define the number of target we are rendering into
  25032. * @param scene Define the scene the texture belongs to
  25033. * @param options Define the options used to create the multi render target
  25034. */
  25035. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25036. /** @hidden */ rebuild(): void;
  25037. private _createInternalTextures;
  25038. private _createTextures;
  25039. /**
  25040. * Define the number of samples used if MSAA is enabled.
  25041. */
  25042. samples: number;
  25043. /**
  25044. * Resize all the textures in the multi render target.
  25045. * Be carrefull as it will recreate all the data in the new texture.
  25046. * @param size Define the new size
  25047. */
  25048. resize(size: any): void;
  25049. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25050. /**
  25051. * Dispose the render targets and their associated resources
  25052. */
  25053. dispose(): void;
  25054. /**
  25055. * Release all the underlying texture used as draw buffers.
  25056. */
  25057. releaseInternalTextures(): void;
  25058. }
  25059. }
  25060. declare module BABYLON {
  25061. /**
  25062. * Class used to work with sound analyzer using fast fourier transform (FFT)
  25063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25064. */
  25065. export class Analyser {
  25066. /**
  25067. * Gets or sets the smoothing
  25068. * @ignorenaming
  25069. */
  25070. SMOOTHING: number;
  25071. /**
  25072. * Gets or sets the FFT table size
  25073. * @ignorenaming
  25074. */
  25075. FFT_SIZE: number;
  25076. /**
  25077. * Gets or sets the bar graph amplitude
  25078. * @ignorenaming
  25079. */
  25080. BARGRAPHAMPLITUDE: number;
  25081. /**
  25082. * Gets or sets the position of the debug canvas
  25083. * @ignorenaming
  25084. */
  25085. DEBUGCANVASPOS: {
  25086. x: number;
  25087. y: number;
  25088. };
  25089. /**
  25090. * Gets or sets the debug canvas size
  25091. * @ignorenaming
  25092. */
  25093. DEBUGCANVASSIZE: {
  25094. width: number;
  25095. height: number;
  25096. };
  25097. private _byteFreqs;
  25098. private _byteTime;
  25099. private _floatFreqs;
  25100. private _webAudioAnalyser;
  25101. private _debugCanvas;
  25102. private _debugCanvasContext;
  25103. private _scene;
  25104. private _registerFunc;
  25105. private _audioEngine;
  25106. /**
  25107. * Creates a new analyser
  25108. * @param scene defines hosting scene
  25109. */
  25110. constructor(scene: Scene);
  25111. /**
  25112. * Get the number of data values you will have to play with for the visualization
  25113. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  25114. * @returns a number
  25115. */
  25116. getFrequencyBinCount(): number;
  25117. /**
  25118. * Gets the current frequency data as a byte array
  25119. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25120. * @returns a Uint8Array
  25121. */
  25122. getByteFrequencyData(): Uint8Array;
  25123. /**
  25124. * Gets the current waveform as a byte array
  25125. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  25126. * @returns a Uint8Array
  25127. */
  25128. getByteTimeDomainData(): Uint8Array;
  25129. /**
  25130. * Gets the current frequency data as a float array
  25131. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25132. * @returns a Float32Array
  25133. */
  25134. getFloatFrequencyData(): Float32Array;
  25135. /**
  25136. * Renders the debug canvas
  25137. */
  25138. drawDebugCanvas(): void;
  25139. /**
  25140. * Stops rendering the debug canvas and removes it
  25141. */
  25142. stopDebugCanvas(): void;
  25143. /**
  25144. * Connects two audio nodes
  25145. * @param inputAudioNode defines first node to connect
  25146. * @param outputAudioNode defines second node to connect
  25147. */
  25148. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  25149. /**
  25150. * Releases all associated resources
  25151. */
  25152. dispose(): void;
  25153. }
  25154. }
  25155. declare module BABYLON {
  25156. /**
  25157. * This represents an audio engine and it is responsible
  25158. * to play, synchronize and analyse sounds throughout the application.
  25159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25160. */
  25161. export interface IAudioEngine extends IDisposable {
  25162. /**
  25163. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25164. */
  25165. readonly canUseWebAudio: boolean;
  25166. /**
  25167. * Gets the current AudioContext if available.
  25168. */
  25169. readonly audioContext: Nullable<AudioContext>;
  25170. /**
  25171. * The master gain node defines the global audio volume of your audio engine.
  25172. */
  25173. readonly masterGain: GainNode;
  25174. /**
  25175. * Gets whether or not mp3 are supported by your browser.
  25176. */
  25177. readonly isMP3supported: boolean;
  25178. /**
  25179. * Gets whether or not ogg are supported by your browser.
  25180. */
  25181. readonly isOGGsupported: boolean;
  25182. /**
  25183. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25184. * @ignoreNaming
  25185. */
  25186. WarnedWebAudioUnsupported: boolean;
  25187. /**
  25188. * Defines if the audio engine relies on a custom unlocked button.
  25189. * In this case, the embedded button will not be displayed.
  25190. */
  25191. useCustomUnlockedButton: boolean;
  25192. /**
  25193. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  25194. */
  25195. readonly unlocked: boolean;
  25196. /**
  25197. * Event raised when audio has been unlocked on the browser.
  25198. */
  25199. onAudioUnlockedObservable: Observable<AudioEngine>;
  25200. /**
  25201. * Event raised when audio has been locked on the browser.
  25202. */
  25203. onAudioLockedObservable: Observable<AudioEngine>;
  25204. /**
  25205. * Flags the audio engine in Locked state.
  25206. * This happens due to new browser policies preventing audio to autoplay.
  25207. */
  25208. lock(): void;
  25209. /**
  25210. * Unlocks the audio engine once a user action has been done on the dom.
  25211. * This is helpful to resume play once browser policies have been satisfied.
  25212. */
  25213. unlock(): void;
  25214. }
  25215. /**
  25216. * This represents the default audio engine used in babylon.
  25217. * It is responsible to play, synchronize and analyse sounds throughout the application.
  25218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25219. */
  25220. export class AudioEngine implements IAudioEngine {
  25221. private _audioContext;
  25222. private _audioContextInitialized;
  25223. private _muteButton;
  25224. private _hostElement;
  25225. /**
  25226. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25227. */
  25228. canUseWebAudio: boolean;
  25229. /**
  25230. * The master gain node defines the global audio volume of your audio engine.
  25231. */
  25232. masterGain: GainNode;
  25233. /**
  25234. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25235. * @ignoreNaming
  25236. */
  25237. WarnedWebAudioUnsupported: boolean;
  25238. /**
  25239. * Gets whether or not mp3 are supported by your browser.
  25240. */
  25241. isMP3supported: boolean;
  25242. /**
  25243. * Gets whether or not ogg are supported by your browser.
  25244. */
  25245. isOGGsupported: boolean;
  25246. /**
  25247. * Gets whether audio has been unlocked on the device.
  25248. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  25249. * a user interaction has happened.
  25250. */
  25251. unlocked: boolean;
  25252. /**
  25253. * Defines if the audio engine relies on a custom unlocked button.
  25254. * In this case, the embedded button will not be displayed.
  25255. */
  25256. useCustomUnlockedButton: boolean;
  25257. /**
  25258. * Event raised when audio has been unlocked on the browser.
  25259. */
  25260. onAudioUnlockedObservable: Observable<AudioEngine>;
  25261. /**
  25262. * Event raised when audio has been locked on the browser.
  25263. */
  25264. onAudioLockedObservable: Observable<AudioEngine>;
  25265. /**
  25266. * Gets the current AudioContext if available.
  25267. */
  25268. readonly audioContext: Nullable<AudioContext>;
  25269. private _connectedAnalyser;
  25270. /**
  25271. * Instantiates a new audio engine.
  25272. *
  25273. * There should be only one per page as some browsers restrict the number
  25274. * of audio contexts you can create.
  25275. * @param hostElement defines the host element where to display the mute icon if necessary
  25276. */
  25277. constructor(hostElement?: Nullable<HTMLElement>);
  25278. /**
  25279. * Flags the audio engine in Locked state.
  25280. * This happens due to new browser policies preventing audio to autoplay.
  25281. */
  25282. lock(): void;
  25283. /**
  25284. * Unlocks the audio engine once a user action has been done on the dom.
  25285. * This is helpful to resume play once browser policies have been satisfied.
  25286. */
  25287. unlock(): void;
  25288. private _resumeAudioContext;
  25289. private _initializeAudioContext;
  25290. private _tryToRun;
  25291. private _triggerRunningState;
  25292. private _triggerSuspendedState;
  25293. private _displayMuteButton;
  25294. private _moveButtonToTopLeft;
  25295. private _onResize;
  25296. private _hideMuteButton;
  25297. /**
  25298. * Destroy and release the resources associated with the audio ccontext.
  25299. */
  25300. dispose(): void;
  25301. /**
  25302. * Gets the global volume sets on the master gain.
  25303. * @returns the global volume if set or -1 otherwise
  25304. */
  25305. getGlobalVolume(): number;
  25306. /**
  25307. * Sets the global volume of your experience (sets on the master gain).
  25308. * @param newVolume Defines the new global volume of the application
  25309. */
  25310. setGlobalVolume(newVolume: number): void;
  25311. /**
  25312. * Connect the audio engine to an audio analyser allowing some amazing
  25313. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  25314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  25315. * @param analyser The analyser to connect to the engine
  25316. */
  25317. connectToAnalyser(analyser: Analyser): void;
  25318. }
  25319. }
  25320. declare module BABYLON {
  25321. /**
  25322. * Interface used to present a loading screen while loading a scene
  25323. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25324. */
  25325. export interface ILoadingScreen {
  25326. /**
  25327. * Function called to display the loading screen
  25328. */
  25329. displayLoadingUI: () => void;
  25330. /**
  25331. * Function called to hide the loading screen
  25332. */
  25333. hideLoadingUI: () => void;
  25334. /**
  25335. * Gets or sets the color to use for the background
  25336. */
  25337. loadingUIBackgroundColor: string;
  25338. /**
  25339. * Gets or sets the text to display while loading
  25340. */
  25341. loadingUIText: string;
  25342. }
  25343. /**
  25344. * Class used for the default loading screen
  25345. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25346. */
  25347. export class DefaultLoadingScreen implements ILoadingScreen {
  25348. private _renderingCanvas;
  25349. private _loadingText;
  25350. private _loadingDivBackgroundColor;
  25351. private _loadingDiv;
  25352. private _loadingTextDiv;
  25353. /**
  25354. * Creates a new default loading screen
  25355. * @param _renderingCanvas defines the canvas used to render the scene
  25356. * @param _loadingText defines the default text to display
  25357. * @param _loadingDivBackgroundColor defines the default background color
  25358. */
  25359. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  25360. /**
  25361. * Function called to display the loading screen
  25362. */
  25363. displayLoadingUI(): void;
  25364. /**
  25365. * Function called to hide the loading screen
  25366. */
  25367. hideLoadingUI(): void;
  25368. /**
  25369. * Gets or sets the text to display while loading
  25370. */
  25371. loadingUIText: string;
  25372. /**
  25373. * Gets or sets the color to use for the background
  25374. */
  25375. loadingUIBackgroundColor: string;
  25376. private _resizeLoadingUI;
  25377. }
  25378. }
  25379. declare module BABYLON {
  25380. /**
  25381. * Settings for finer control over video usage
  25382. */
  25383. export interface VideoTextureSettings {
  25384. /**
  25385. * Applies `autoplay` to video, if specified
  25386. */
  25387. autoPlay?: boolean;
  25388. /**
  25389. * Applies `loop` to video, if specified
  25390. */
  25391. loop?: boolean;
  25392. /**
  25393. * Automatically updates internal texture from video at every frame in the render loop
  25394. */
  25395. autoUpdateTexture: boolean;
  25396. /**
  25397. * Image src displayed during the video loading or until the user interacts with the video.
  25398. */
  25399. poster?: string;
  25400. }
  25401. /**
  25402. * If you want to display a video in your scene, this is the special texture for that.
  25403. * This special texture works similar to other textures, with the exception of a few parameters.
  25404. * @see https://doc.babylonjs.com/how_to/video_texture
  25405. */
  25406. export class VideoTexture extends Texture {
  25407. /**
  25408. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  25409. */
  25410. readonly autoUpdateTexture: boolean;
  25411. /**
  25412. * The video instance used by the texture internally
  25413. */
  25414. readonly video: HTMLVideoElement;
  25415. private _onUserActionRequestedObservable;
  25416. /**
  25417. * Event triggerd when a dom action is required by the user to play the video.
  25418. * This happens due to recent changes in browser policies preventing video to auto start.
  25419. */
  25420. readonly onUserActionRequestedObservable: Observable<Texture>;
  25421. private _generateMipMaps;
  25422. private _engine;
  25423. private _stillImageCaptured;
  25424. private _displayingPosterTexture;
  25425. private _settings;
  25426. private _createInternalTextureOnEvent;
  25427. /**
  25428. * Creates a video texture.
  25429. * If you want to display a video in your scene, this is the special texture for that.
  25430. * This special texture works similar to other textures, with the exception of a few parameters.
  25431. * @see https://doc.babylonjs.com/how_to/video_texture
  25432. * @param name optional name, will detect from video source, if not defined
  25433. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  25434. * @param scene is obviously the current scene.
  25435. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  25436. * @param invertY is false by default but can be used to invert video on Y axis
  25437. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  25438. * @param settings allows finer control over video usage
  25439. */
  25440. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  25441. private _getName;
  25442. private _getVideo;
  25443. private _createInternalTexture;
  25444. private reset;
  25445. /**
  25446. * @hidden Internal method to initiate `update`.
  25447. */ rebuild(): void;
  25448. /**
  25449. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  25450. */
  25451. update(): void;
  25452. /**
  25453. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  25454. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  25455. */
  25456. updateTexture(isVisible: boolean): void;
  25457. protected _updateInternalTexture: () => void;
  25458. /**
  25459. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  25460. * @param url New url.
  25461. */
  25462. updateURL(url: string): void;
  25463. /**
  25464. * Dispose the texture and release its associated resources.
  25465. */
  25466. dispose(): void;
  25467. /**
  25468. * Creates a video texture straight from your WebCam video feed.
  25469. * @param scene Define the scene the texture should be created in
  25470. * @param onReady Define a callback to triggered once the texture will be ready
  25471. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  25472. */
  25473. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  25474. minWidth: number;
  25475. maxWidth: number;
  25476. minHeight: number;
  25477. maxHeight: number;
  25478. deviceId: string;
  25479. }): void;
  25480. }
  25481. }
  25482. declare module BABYLON {
  25483. /**
  25484. * Interface for attribute information associated with buffer instanciation
  25485. */
  25486. export class InstancingAttributeInfo {
  25487. /**
  25488. * Index/offset of the attribute in the vertex shader
  25489. */
  25490. index: number;
  25491. /**
  25492. * size of the attribute, 1, 2, 3 or 4
  25493. */
  25494. attributeSize: number;
  25495. /**
  25496. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  25497. * default is FLOAT
  25498. */
  25499. attribyteType: number;
  25500. /**
  25501. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  25502. */
  25503. normalized: boolean;
  25504. /**
  25505. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  25506. */
  25507. offset: number;
  25508. /**
  25509. * Name of the GLSL attribute, for debugging purpose only
  25510. */
  25511. attributeName: string;
  25512. }
  25513. /**
  25514. * Define options used to create a depth texture
  25515. */
  25516. export class DepthTextureCreationOptions {
  25517. /** Specifies whether or not a stencil should be allocated in the texture */
  25518. generateStencil?: boolean;
  25519. /** Specifies whether or not bilinear filtering is enable on the texture */
  25520. bilinearFiltering?: boolean;
  25521. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  25522. comparisonFunction?: number;
  25523. /** Specifies if the created texture is a cube texture */
  25524. isCube?: boolean;
  25525. }
  25526. /**
  25527. * Class used to describe the capabilities of the engine relatively to the current browser
  25528. */
  25529. export class EngineCapabilities {
  25530. /** Maximum textures units per fragment shader */
  25531. maxTexturesImageUnits: number;
  25532. /** Maximum texture units per vertex shader */
  25533. maxVertexTextureImageUnits: number;
  25534. /** Maximum textures units in the entire pipeline */
  25535. maxCombinedTexturesImageUnits: number;
  25536. /** Maximum texture size */
  25537. maxTextureSize: number;
  25538. /** Maximum cube texture size */
  25539. maxCubemapTextureSize: number;
  25540. /** Maximum render texture size */
  25541. maxRenderTextureSize: number;
  25542. /** Maximum number of vertex attributes */
  25543. maxVertexAttribs: number;
  25544. /** Maximum number of varyings */
  25545. maxVaryingVectors: number;
  25546. /** Maximum number of uniforms per vertex shader */
  25547. maxVertexUniformVectors: number;
  25548. /** Maximum number of uniforms per fragment shader */
  25549. maxFragmentUniformVectors: number;
  25550. /** Defines if standard derivates (dx/dy) are supported */
  25551. standardDerivatives: boolean;
  25552. /** Defines if s3tc texture compression is supported */
  25553. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  25554. /** Defines if pvrtc texture compression is supported */
  25555. pvrtc: any;
  25556. /** Defines if etc1 texture compression is supported */
  25557. etc1: any;
  25558. /** Defines if etc2 texture compression is supported */
  25559. etc2: any;
  25560. /** Defines if astc texture compression is supported */
  25561. astc: any;
  25562. /** Defines if float textures are supported */
  25563. textureFloat: boolean;
  25564. /** Defines if vertex array objects are supported */
  25565. vertexArrayObject: boolean;
  25566. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  25567. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  25568. /** Gets the maximum level of anisotropy supported */
  25569. maxAnisotropy: number;
  25570. /** Defines if instancing is supported */
  25571. instancedArrays: boolean;
  25572. /** Defines if 32 bits indices are supported */
  25573. uintIndices: boolean;
  25574. /** Defines if high precision shaders are supported */
  25575. highPrecisionShaderSupported: boolean;
  25576. /** Defines if depth reading in the fragment shader is supported */
  25577. fragmentDepthSupported: boolean;
  25578. /** Defines if float texture linear filtering is supported*/
  25579. textureFloatLinearFiltering: boolean;
  25580. /** Defines if rendering to float textures is supported */
  25581. textureFloatRender: boolean;
  25582. /** Defines if half float textures are supported*/
  25583. textureHalfFloat: boolean;
  25584. /** Defines if half float texture linear filtering is supported*/
  25585. textureHalfFloatLinearFiltering: boolean;
  25586. /** Defines if rendering to half float textures is supported */
  25587. textureHalfFloatRender: boolean;
  25588. /** Defines if textureLOD shader command is supported */
  25589. textureLOD: boolean;
  25590. /** Defines if draw buffers extension is supported */
  25591. drawBuffersExtension: boolean;
  25592. /** Defines if depth textures are supported */
  25593. depthTextureExtension: boolean;
  25594. /** Defines if float color buffer are supported */
  25595. colorBufferFloat: boolean;
  25596. /** Gets disjoint timer query extension (null if not supported) */
  25597. timerQuery: EXT_disjoint_timer_query;
  25598. /** Defines if timestamp can be used with timer query */
  25599. canUseTimestampForTimerQuery: boolean;
  25600. /** Function used to let the system compiles shaders in background */
  25601. parallelShaderCompile: {
  25602. MAX_SHADER_COMPILER_THREADS_KHR: number;
  25603. maxShaderCompilerThreadsKHR: (thread: number) => void;
  25604. COMPLETION_STATUS_KHR: number;
  25605. };
  25606. }
  25607. /** Interface defining initialization parameters for Engine class */
  25608. export interface EngineOptions extends WebGLContextAttributes {
  25609. /**
  25610. * Defines if the engine should no exceed a specified device ratio
  25611. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  25612. */
  25613. limitDeviceRatio?: number;
  25614. /**
  25615. * Defines if webvr should be enabled automatically
  25616. * @see http://doc.babylonjs.com/how_to/webvr_camera
  25617. */
  25618. autoEnableWebVR?: boolean;
  25619. /**
  25620. * Defines if webgl2 should be turned off even if supported
  25621. * @see http://doc.babylonjs.com/features/webgl2
  25622. */
  25623. disableWebGL2Support?: boolean;
  25624. /**
  25625. * Defines if webaudio should be initialized as well
  25626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25627. */
  25628. audioEngine?: boolean;
  25629. /**
  25630. * Defines if animations should run using a deterministic lock step
  25631. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  25632. */
  25633. deterministicLockstep?: boolean;
  25634. /** Defines the maximum steps to use with deterministic lock step mode */
  25635. lockstepMaxSteps?: number;
  25636. /**
  25637. * Defines that engine should ignore context lost events
  25638. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  25639. */
  25640. doNotHandleContextLost?: boolean;
  25641. /**
  25642. * Defines that engine should ignore modifying touch action attribute and style
  25643. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  25644. */
  25645. doNotHandleTouchAction?: boolean;
  25646. }
  25647. /**
  25648. * Defines the interface used by display changed events
  25649. */
  25650. export interface IDisplayChangedEventArgs {
  25651. /** Gets the vrDisplay object (if any) */
  25652. vrDisplay: Nullable<any>;
  25653. /** Gets a boolean indicating if webVR is supported */
  25654. vrSupported: boolean;
  25655. }
  25656. /**
  25657. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  25658. */
  25659. export class Engine {
  25660. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  25661. static ExceptionList: ({
  25662. key: string;
  25663. capture: string;
  25664. captureConstraint: number;
  25665. targets: string[];
  25666. } | {
  25667. key: string;
  25668. capture: null;
  25669. captureConstraint: null;
  25670. targets: string[];
  25671. })[];
  25672. /** Gets the list of created engines */
  25673. static readonly Instances: Engine[];
  25674. /**
  25675. * Gets the latest created engine
  25676. */
  25677. static readonly LastCreatedEngine: Nullable<Engine>;
  25678. /**
  25679. * Gets the latest created scene
  25680. */
  25681. static readonly LastCreatedScene: Nullable<Scene>;
  25682. /**
  25683. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  25684. * @param flag defines which part of the materials must be marked as dirty
  25685. * @param predicate defines a predicate used to filter which materials should be affected
  25686. */
  25687. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  25688. /**
  25689. * Hidden
  25690. */ private static _TextureLoaders: IInternalTextureLoader[];
  25691. /** Defines that alpha blending is disabled */
  25692. static readonly ALPHA_DISABLE: number;
  25693. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  25694. static readonly ALPHA_ADD: number;
  25695. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  25696. static readonly ALPHA_COMBINE: number;
  25697. /** Defines that alpha blending to DEST - SRC * DEST */
  25698. static readonly ALPHA_SUBTRACT: number;
  25699. /** Defines that alpha blending to SRC * DEST */
  25700. static readonly ALPHA_MULTIPLY: number;
  25701. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  25702. static readonly ALPHA_MAXIMIZED: number;
  25703. /** Defines that alpha blending to SRC + DEST */
  25704. static readonly ALPHA_ONEONE: number;
  25705. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  25706. static readonly ALPHA_PREMULTIPLIED: number;
  25707. /**
  25708. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  25709. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  25710. */
  25711. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  25712. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  25713. static readonly ALPHA_INTERPOLATE: number;
  25714. /**
  25715. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  25716. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  25717. */
  25718. static readonly ALPHA_SCREENMODE: number;
  25719. /** Defines that the ressource is not delayed*/
  25720. static readonly DELAYLOADSTATE_NONE: number;
  25721. /** Defines that the ressource was successfully delay loaded */
  25722. static readonly DELAYLOADSTATE_LOADED: number;
  25723. /** Defines that the ressource is currently delay loading */
  25724. static readonly DELAYLOADSTATE_LOADING: number;
  25725. /** Defines that the ressource is delayed and has not started loading */
  25726. static readonly DELAYLOADSTATE_NOTLOADED: number;
  25727. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  25728. static readonly NEVER: number;
  25729. /** 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 */
  25730. static readonly ALWAYS: number;
  25731. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  25732. static readonly LESS: number;
  25733. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  25734. static readonly EQUAL: number;
  25735. /** 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 */
  25736. static readonly LEQUAL: number;
  25737. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  25738. static readonly GREATER: number;
  25739. /** 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 */
  25740. static readonly GEQUAL: number;
  25741. /** 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 */
  25742. static readonly NOTEQUAL: number;
  25743. /** Passed to stencilOperation to specify that stencil value must be kept */
  25744. static readonly KEEP: number;
  25745. /** Passed to stencilOperation to specify that stencil value must be replaced */
  25746. static readonly REPLACE: number;
  25747. /** Passed to stencilOperation to specify that stencil value must be incremented */
  25748. static readonly INCR: number;
  25749. /** Passed to stencilOperation to specify that stencil value must be decremented */
  25750. static readonly DECR: number;
  25751. /** Passed to stencilOperation to specify that stencil value must be inverted */
  25752. static readonly INVERT: number;
  25753. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  25754. static readonly INCR_WRAP: number;
  25755. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  25756. static readonly DECR_WRAP: number;
  25757. /** Texture is not repeating outside of 0..1 UVs */
  25758. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  25759. /** Texture is repeating outside of 0..1 UVs */
  25760. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  25761. /** Texture is repeating and mirrored */
  25762. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  25763. /** ALPHA */
  25764. static readonly TEXTUREFORMAT_ALPHA: number;
  25765. /** LUMINANCE */
  25766. static readonly TEXTUREFORMAT_LUMINANCE: number;
  25767. /** LUMINANCE_ALPHA */
  25768. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  25769. /** RGB */
  25770. static readonly TEXTUREFORMAT_RGB: number;
  25771. /** RGBA */
  25772. static readonly TEXTUREFORMAT_RGBA: number;
  25773. /** RED */
  25774. static readonly TEXTUREFORMAT_RED: number;
  25775. /** RED (2nd reference) */
  25776. static readonly TEXTUREFORMAT_R: number;
  25777. /** RG */
  25778. static readonly TEXTUREFORMAT_RG: number;
  25779. /** RED_INTEGER */
  25780. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  25781. /** RED_INTEGER (2nd reference) */
  25782. static readonly TEXTUREFORMAT_R_INTEGER: number;
  25783. /** RG_INTEGER */
  25784. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  25785. /** RGB_INTEGER */
  25786. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  25787. /** RGBA_INTEGER */
  25788. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  25789. /** UNSIGNED_BYTE */
  25790. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  25791. /** UNSIGNED_BYTE (2nd reference) */
  25792. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  25793. /** FLOAT */
  25794. static readonly TEXTURETYPE_FLOAT: number;
  25795. /** HALF_FLOAT */
  25796. static readonly TEXTURETYPE_HALF_FLOAT: number;
  25797. /** BYTE */
  25798. static readonly TEXTURETYPE_BYTE: number;
  25799. /** SHORT */
  25800. static readonly TEXTURETYPE_SHORT: number;
  25801. /** UNSIGNED_SHORT */
  25802. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  25803. /** INT */
  25804. static readonly TEXTURETYPE_INT: number;
  25805. /** UNSIGNED_INT */
  25806. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  25807. /** UNSIGNED_SHORT_4_4_4_4 */
  25808. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  25809. /** UNSIGNED_SHORT_5_5_5_1 */
  25810. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  25811. /** UNSIGNED_SHORT_5_6_5 */
  25812. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  25813. /** UNSIGNED_INT_2_10_10_10_REV */
  25814. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  25815. /** UNSIGNED_INT_24_8 */
  25816. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  25817. /** UNSIGNED_INT_10F_11F_11F_REV */
  25818. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  25819. /** UNSIGNED_INT_5_9_9_9_REV */
  25820. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  25821. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  25822. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  25823. /** nearest is mag = nearest and min = nearest and mip = linear */
  25824. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  25825. /** Bilinear is mag = linear and min = linear and mip = nearest */
  25826. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  25827. /** Trilinear is mag = linear and min = linear and mip = linear */
  25828. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  25829. /** nearest is mag = nearest and min = nearest and mip = linear */
  25830. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  25831. /** Bilinear is mag = linear and min = linear and mip = nearest */
  25832. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  25833. /** Trilinear is mag = linear and min = linear and mip = linear */
  25834. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  25835. /** mag = nearest and min = nearest and mip = nearest */
  25836. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  25837. /** mag = nearest and min = linear and mip = nearest */
  25838. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  25839. /** mag = nearest and min = linear and mip = linear */
  25840. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  25841. /** mag = nearest and min = linear and mip = none */
  25842. static readonly TEXTURE_NEAREST_LINEAR: number;
  25843. /** mag = nearest and min = nearest and mip = none */
  25844. static readonly TEXTURE_NEAREST_NEAREST: number;
  25845. /** mag = linear and min = nearest and mip = nearest */
  25846. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  25847. /** mag = linear and min = nearest and mip = linear */
  25848. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  25849. /** mag = linear and min = linear and mip = none */
  25850. static readonly TEXTURE_LINEAR_LINEAR: number;
  25851. /** mag = linear and min = nearest and mip = none */
  25852. static readonly TEXTURE_LINEAR_NEAREST: number;
  25853. /** Explicit coordinates mode */
  25854. static readonly TEXTURE_EXPLICIT_MODE: number;
  25855. /** Spherical coordinates mode */
  25856. static readonly TEXTURE_SPHERICAL_MODE: number;
  25857. /** Planar coordinates mode */
  25858. static readonly TEXTURE_PLANAR_MODE: number;
  25859. /** Cubic coordinates mode */
  25860. static readonly TEXTURE_CUBIC_MODE: number;
  25861. /** Projection coordinates mode */
  25862. static readonly TEXTURE_PROJECTION_MODE: number;
  25863. /** Skybox coordinates mode */
  25864. static readonly TEXTURE_SKYBOX_MODE: number;
  25865. /** Inverse Cubic coordinates mode */
  25866. static readonly TEXTURE_INVCUBIC_MODE: number;
  25867. /** Equirectangular coordinates mode */
  25868. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  25869. /** Equirectangular Fixed coordinates mode */
  25870. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  25871. /** Equirectangular Fixed Mirrored coordinates mode */
  25872. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  25873. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  25874. static readonly SCALEMODE_FLOOR: number;
  25875. /** Defines that texture rescaling will look for the nearest power of 2 size */
  25876. static readonly SCALEMODE_NEAREST: number;
  25877. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  25878. static readonly SCALEMODE_CEILING: number;
  25879. /**
  25880. * Returns the current version of the framework
  25881. */
  25882. static readonly Version: string;
  25883. /**
  25884. * Returns a string describing the current engine
  25885. */
  25886. readonly description: string;
  25887. /**
  25888. * Gets or sets the epsilon value used by collision engine
  25889. */
  25890. static CollisionsEpsilon: number;
  25891. /**
  25892. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  25893. */
  25894. static ShadersRepository: string;
  25895. /**
  25896. * Method called to create the default loading screen.
  25897. * This can be overriden in your own app.
  25898. * @param canvas The rendering canvas element
  25899. * @returns The loading screen
  25900. */
  25901. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  25902. /**
  25903. * Method called to create the default rescale post process on each engine.
  25904. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  25905. /**
  25906. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  25907. */
  25908. forcePOTTextures: boolean;
  25909. /**
  25910. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  25911. */
  25912. isFullscreen: boolean;
  25913. /**
  25914. * Gets a boolean indicating if the pointer is currently locked
  25915. */
  25916. isPointerLock: boolean;
  25917. /**
  25918. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  25919. */
  25920. cullBackFaces: boolean;
  25921. /**
  25922. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  25923. */
  25924. renderEvenInBackground: boolean;
  25925. /**
  25926. * Gets or sets a boolean indicating that cache can be kept between frames
  25927. */
  25928. preventCacheWipeBetweenFrames: boolean;
  25929. /**
  25930. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  25931. **/
  25932. enableOfflineSupport: boolean;
  25933. /**
  25934. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  25935. **/
  25936. disableManifestCheck: boolean;
  25937. /**
  25938. * Gets the list of created scenes
  25939. */
  25940. scenes: Scene[];
  25941. /**
  25942. * Event raised when a new scene is created
  25943. */
  25944. onNewSceneAddedObservable: Observable<Scene>;
  25945. /**
  25946. * Gets the list of created postprocesses
  25947. */
  25948. postProcesses: PostProcess[];
  25949. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  25950. validateShaderPrograms: boolean;
  25951. /**
  25952. * Observable event triggered each time the rendering canvas is resized
  25953. */
  25954. onResizeObservable: Observable<Engine>;
  25955. /**
  25956. * Observable event triggered each time the canvas loses focus
  25957. */
  25958. onCanvasBlurObservable: Observable<Engine>;
  25959. /**
  25960. * Observable event triggered each time the canvas gains focus
  25961. */
  25962. onCanvasFocusObservable: Observable<Engine>;
  25963. /**
  25964. * Observable event triggered each time the canvas receives pointerout event
  25965. */
  25966. onCanvasPointerOutObservable: Observable<PointerEvent>;
  25967. /**
  25968. * Observable event triggered before each texture is initialized
  25969. */
  25970. onBeforeTextureInitObservable: Observable<Texture>;
  25971. private _vrDisplay;
  25972. private _vrSupported;
  25973. private _oldSize;
  25974. private _oldHardwareScaleFactor;
  25975. private _vrExclusivePointerMode;
  25976. private _webVRInitPromise;
  25977. /**
  25978. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  25979. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  25980. */
  25981. readonly isInVRExclusivePointerMode: boolean;
  25982. /**
  25983. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  25984. */
  25985. disableUniformBuffers: boolean;
  25986. /** @hidden */ uniformBuffers: UniformBuffer[];
  25987. /**
  25988. * Gets a boolean indicating that the engine supports uniform buffers
  25989. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  25990. */
  25991. readonly supportsUniformBuffers: boolean;
  25992. /**
  25993. * Observable raised when the engine begins a new frame
  25994. */
  25995. onBeginFrameObservable: Observable<Engine>;
  25996. /**
  25997. * If set, will be used to request the next animation frame for the render loop
  25998. */
  25999. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  26000. /**
  26001. * Observable raised when the engine ends the current frame
  26002. */
  26003. onEndFrameObservable: Observable<Engine>;
  26004. /**
  26005. * Observable raised when the engine is about to compile a shader
  26006. */
  26007. onBeforeShaderCompilationObservable: Observable<Engine>;
  26008. /**
  26009. * Observable raised when the engine has jsut compiled a shader
  26010. */
  26011. onAfterShaderCompilationObservable: Observable<Engine>;
  26012. /** @hidden */ gl: WebGLRenderingContext;
  26013. private _renderingCanvas;
  26014. private _windowIsBackground;
  26015. private _webGLVersion;
  26016. /**
  26017. * Gets a boolean indicating that only power of 2 textures are supported
  26018. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  26019. */
  26020. readonly needPOTTextures: boolean;
  26021. /** @hidden */ badOS: boolean;
  26022. /** @hidden */ badDesktopOS: boolean;
  26023. /**
  26024. * Gets or sets a value indicating if we want to disable texture binding optimization.
  26025. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  26026. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  26027. */
  26028. disableTextureBindingOptimization: boolean;
  26029. /**
  26030. * Gets the audio engine
  26031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26032. * @ignorenaming
  26033. */
  26034. static audioEngine: IAudioEngine;
  26035. /**
  26036. * Default AudioEngine factory responsible of creating the Audio Engine.
  26037. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  26038. */
  26039. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  26040. /**
  26041. * Default offline support factory responsible of creating a tool used to store data locally.
  26042. * By default, this will create a Database object if the workload has been embedded.
  26043. */
  26044. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  26045. private _onFocus;
  26046. private _onBlur;
  26047. private _onCanvasPointerOut;
  26048. private _onCanvasBlur;
  26049. private _onCanvasFocus;
  26050. private _onFullscreenChange;
  26051. private _onPointerLockChange;
  26052. private _onVRDisplayPointerRestricted;
  26053. private _onVRDisplayPointerUnrestricted;
  26054. private _onVrDisplayConnect;
  26055. private _onVrDisplayDisconnect;
  26056. private _onVrDisplayPresentChange;
  26057. /**
  26058. * Observable signaled when VR display mode changes
  26059. */
  26060. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26061. /**
  26062. * Observable signaled when VR request present is complete
  26063. */
  26064. onVRRequestPresentComplete: Observable<boolean>;
  26065. /**
  26066. * Observable signaled when VR request present starts
  26067. */
  26068. onVRRequestPresentStart: Observable<Engine>;
  26069. private _hardwareScalingLevel;
  26070. /** @hidden */
  26071. protected _caps: EngineCapabilities;
  26072. private _pointerLockRequested;
  26073. private _isStencilEnable;
  26074. private _colorWrite;
  26075. private _loadingScreen;
  26076. /** @hidden */ drawCalls: PerfCounter;
  26077. /** @hidden */ textureCollisions: PerfCounter;
  26078. private _glVersion;
  26079. private _glRenderer;
  26080. private _glVendor;
  26081. private _videoTextureSupported;
  26082. private _renderingQueueLaunched;
  26083. private _activeRenderLoops;
  26084. private _deterministicLockstep;
  26085. private _lockstepMaxSteps;
  26086. /**
  26087. * Observable signaled when a context lost event is raised
  26088. */
  26089. onContextLostObservable: Observable<Engine>;
  26090. /**
  26091. * Observable signaled when a context restored event is raised
  26092. */
  26093. onContextRestoredObservable: Observable<Engine>;
  26094. private _onContextLost;
  26095. private _onContextRestored;
  26096. private _contextWasLost;
  26097. private _doNotHandleContextLost;
  26098. /**
  26099. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  26100. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  26101. */
  26102. doNotHandleContextLost: boolean;
  26103. private _performanceMonitor;
  26104. private _fps;
  26105. private _deltaTime;
  26106. /**
  26107. * Turn this value on if you want to pause FPS computation when in background
  26108. */
  26109. disablePerformanceMonitorInBackground: boolean;
  26110. /**
  26111. * Gets the performance monitor attached to this engine
  26112. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  26113. */
  26114. readonly performanceMonitor: PerformanceMonitor;
  26115. /** @hidden */
  26116. protected _depthCullingState: _DepthCullingState;
  26117. /** @hidden */
  26118. protected _stencilState: _StencilState;
  26119. /** @hidden */
  26120. protected _alphaState: _AlphaState;
  26121. /** @hidden */
  26122. protected _alphaMode: number;
  26123. protected _internalTexturesCache: InternalTexture[];
  26124. /** @hidden */
  26125. protected _activeChannel: number;
  26126. private _currentTextureChannel;
  26127. /** @hidden */
  26128. protected _boundTexturesCache: {
  26129. [key: string]: Nullable<InternalTexture>;
  26130. };
  26131. /** @hidden */
  26132. protected _currentEffect: Nullable<Effect>;
  26133. /** @hidden */
  26134. protected _currentProgram: Nullable<WebGLProgram>;
  26135. private _compiledEffects;
  26136. private _vertexAttribArraysEnabled;
  26137. /** @hidden */
  26138. protected _cachedViewport: Nullable<Viewport>;
  26139. private _cachedVertexArrayObject;
  26140. /** @hidden */
  26141. protected _cachedVertexBuffers: any;
  26142. /** @hidden */
  26143. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  26144. /** @hidden */
  26145. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  26146. /** @hidden */
  26147. protected _currentRenderTarget: Nullable<InternalTexture>;
  26148. private _uintIndicesCurrentlySet;
  26149. private _currentBoundBuffer;
  26150. /** @hidden */
  26151. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  26152. private _currentBufferPointers;
  26153. private _currentInstanceLocations;
  26154. private _currentInstanceBuffers;
  26155. private _textureUnits;
  26156. private _firstBoundInternalTextureTracker;
  26157. private _lastBoundInternalTextureTracker;
  26158. private _workingCanvas;
  26159. private _workingContext;
  26160. private _rescalePostProcess;
  26161. private _dummyFramebuffer;
  26162. private _externalData;
  26163. private _bindedRenderFunction;
  26164. private _vaoRecordInProgress;
  26165. private _mustWipeVertexAttributes;
  26166. private _emptyTexture;
  26167. private _emptyCubeTexture;
  26168. private _emptyTexture3D;
  26169. /** @hidden */ frameHandler: number;
  26170. private _nextFreeTextureSlots;
  26171. private _maxSimultaneousTextures;
  26172. private _activeRequests;
  26173. private _texturesSupported;
  26174. private _textureFormatInUse;
  26175. /**
  26176. * Gets the list of texture formats supported
  26177. */
  26178. readonly texturesSupported: Array<string>;
  26179. /**
  26180. * Gets the list of texture formats in use
  26181. */
  26182. readonly textureFormatInUse: Nullable<string>;
  26183. /**
  26184. * Gets the current viewport
  26185. */
  26186. readonly currentViewport: Nullable<Viewport>;
  26187. /**
  26188. * Gets the default empty texture
  26189. */
  26190. readonly emptyTexture: InternalTexture;
  26191. /**
  26192. * Gets the default empty 3D texture
  26193. */
  26194. readonly emptyTexture3D: InternalTexture;
  26195. /**
  26196. * Gets the default empty cube texture
  26197. */
  26198. readonly emptyCubeTexture: InternalTexture;
  26199. /**
  26200. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  26201. */
  26202. readonly premultipliedAlpha: boolean;
  26203. /**
  26204. * Creates a new engine
  26205. * @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
  26206. * @param antialias defines enable antialiasing (default: false)
  26207. * @param options defines further options to be sent to the getContext() function
  26208. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  26209. */
  26210. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  26211. private _disableTouchAction;
  26212. private _rebuildInternalTextures;
  26213. private _rebuildEffects;
  26214. /**
  26215. * Gets a boolean indicating if all created effects are ready
  26216. * @returns true if all effects are ready
  26217. */
  26218. areAllEffectsReady(): boolean;
  26219. private _rebuildBuffers;
  26220. private _initGLContext;
  26221. /**
  26222. * Gets version of the current webGL context
  26223. */
  26224. readonly webGLVersion: number;
  26225. /**
  26226. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  26227. */
  26228. readonly isStencilEnable: boolean;
  26229. private _prepareWorkingCanvas;
  26230. /**
  26231. * Reset the texture cache to empty state
  26232. */
  26233. resetTextureCache(): void;
  26234. /**
  26235. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  26236. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26237. * @returns true if engine is in deterministic lock step mode
  26238. */
  26239. isDeterministicLockStep(): boolean;
  26240. /**
  26241. * Gets the max steps when engine is running in deterministic lock step
  26242. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26243. * @returns the max steps
  26244. */
  26245. getLockstepMaxSteps(): number;
  26246. /**
  26247. * Gets an object containing information about the current webGL context
  26248. * @returns an object containing the vender, the renderer and the version of the current webGL context
  26249. */
  26250. getGlInfo(): {
  26251. vendor: string;
  26252. renderer: string;
  26253. version: string;
  26254. };
  26255. /**
  26256. * Gets current aspect ratio
  26257. * @param camera defines the camera to use to get the aspect ratio
  26258. * @param useScreen defines if screen size must be used (or the current render target if any)
  26259. * @returns a number defining the aspect ratio
  26260. */
  26261. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  26262. /**
  26263. * Gets current screen aspect ratio
  26264. * @returns a number defining the aspect ratio
  26265. */
  26266. getScreenAspectRatio(): number;
  26267. /**
  26268. * Gets the current render width
  26269. * @param useScreen defines if screen size must be used (or the current render target if any)
  26270. * @returns a number defining the current render width
  26271. */
  26272. getRenderWidth(useScreen?: boolean): number;
  26273. /**
  26274. * Gets the current render height
  26275. * @param useScreen defines if screen size must be used (or the current render target if any)
  26276. * @returns a number defining the current render height
  26277. */
  26278. getRenderHeight(useScreen?: boolean): number;
  26279. /**
  26280. * Gets the HTML canvas attached with the current webGL context
  26281. * @returns a HTML canvas
  26282. */
  26283. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  26284. /**
  26285. * Gets the client rect of the HTML canvas attached with the current webGL context
  26286. * @returns a client rectanglee
  26287. */
  26288. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  26289. /**
  26290. * Defines the hardware scaling level.
  26291. * By default the hardware scaling level is computed from the window device ratio.
  26292. * 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.
  26293. * @param level defines the level to use
  26294. */
  26295. setHardwareScalingLevel(level: number): void;
  26296. /**
  26297. * Gets the current hardware scaling level.
  26298. * By default the hardware scaling level is computed from the window device ratio.
  26299. * 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.
  26300. * @returns a number indicating the current hardware scaling level
  26301. */
  26302. getHardwareScalingLevel(): number;
  26303. /**
  26304. * Gets the list of loaded textures
  26305. * @returns an array containing all loaded textures
  26306. */
  26307. getLoadedTexturesCache(): InternalTexture[];
  26308. /**
  26309. * Gets the object containing all engine capabilities
  26310. * @returns the EngineCapabilities object
  26311. */
  26312. getCaps(): EngineCapabilities;
  26313. /**
  26314. * Gets the current depth function
  26315. * @returns a number defining the depth function
  26316. */
  26317. getDepthFunction(): Nullable<number>;
  26318. /**
  26319. * Sets the current depth function
  26320. * @param depthFunc defines the function to use
  26321. */
  26322. setDepthFunction(depthFunc: number): void;
  26323. /**
  26324. * Sets the current depth function to GREATER
  26325. */
  26326. setDepthFunctionToGreater(): void;
  26327. /**
  26328. * Sets the current depth function to GEQUAL
  26329. */
  26330. setDepthFunctionToGreaterOrEqual(): void;
  26331. /**
  26332. * Sets the current depth function to LESS
  26333. */
  26334. setDepthFunctionToLess(): void;
  26335. /**
  26336. * Sets the current depth function to LEQUAL
  26337. */
  26338. setDepthFunctionToLessOrEqual(): void;
  26339. /**
  26340. * Gets a boolean indicating if stencil buffer is enabled
  26341. * @returns the current stencil buffer state
  26342. */
  26343. getStencilBuffer(): boolean;
  26344. /**
  26345. * Enable or disable the stencil buffer
  26346. * @param enable defines if the stencil buffer must be enabled or disabled
  26347. */
  26348. setStencilBuffer(enable: boolean): void;
  26349. /**
  26350. * Gets the current stencil mask
  26351. * @returns a number defining the new stencil mask to use
  26352. */
  26353. getStencilMask(): number;
  26354. /**
  26355. * Sets the current stencil mask
  26356. * @param mask defines the new stencil mask to use
  26357. */
  26358. setStencilMask(mask: number): void;
  26359. /**
  26360. * Gets the current stencil function
  26361. * @returns a number defining the stencil function to use
  26362. */
  26363. getStencilFunction(): number;
  26364. /**
  26365. * Gets the current stencil reference value
  26366. * @returns a number defining the stencil reference value to use
  26367. */
  26368. getStencilFunctionReference(): number;
  26369. /**
  26370. * Gets the current stencil mask
  26371. * @returns a number defining the stencil mask to use
  26372. */
  26373. getStencilFunctionMask(): number;
  26374. /**
  26375. * Sets the current stencil function
  26376. * @param stencilFunc defines the new stencil function to use
  26377. */
  26378. setStencilFunction(stencilFunc: number): void;
  26379. /**
  26380. * Sets the current stencil reference
  26381. * @param reference defines the new stencil reference to use
  26382. */
  26383. setStencilFunctionReference(reference: number): void;
  26384. /**
  26385. * Sets the current stencil mask
  26386. * @param mask defines the new stencil mask to use
  26387. */
  26388. setStencilFunctionMask(mask: number): void;
  26389. /**
  26390. * Gets the current stencil operation when stencil fails
  26391. * @returns a number defining stencil operation to use when stencil fails
  26392. */
  26393. getStencilOperationFail(): number;
  26394. /**
  26395. * Gets the current stencil operation when depth fails
  26396. * @returns a number defining stencil operation to use when depth fails
  26397. */
  26398. getStencilOperationDepthFail(): number;
  26399. /**
  26400. * Gets the current stencil operation when stencil passes
  26401. * @returns a number defining stencil operation to use when stencil passes
  26402. */
  26403. getStencilOperationPass(): number;
  26404. /**
  26405. * Sets the stencil operation to use when stencil fails
  26406. * @param operation defines the stencil operation to use when stencil fails
  26407. */
  26408. setStencilOperationFail(operation: number): void;
  26409. /**
  26410. * Sets the stencil operation to use when depth fails
  26411. * @param operation defines the stencil operation to use when depth fails
  26412. */
  26413. setStencilOperationDepthFail(operation: number): void;
  26414. /**
  26415. * Sets the stencil operation to use when stencil passes
  26416. * @param operation defines the stencil operation to use when stencil passes
  26417. */
  26418. setStencilOperationPass(operation: number): void;
  26419. /**
  26420. * Sets a boolean indicating if the dithering state is enabled or disabled
  26421. * @param value defines the dithering state
  26422. */
  26423. setDitheringState(value: boolean): void;
  26424. /**
  26425. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  26426. * @param value defines the rasterizer state
  26427. */
  26428. setRasterizerState(value: boolean): void;
  26429. /**
  26430. * stop executing a render loop function and remove it from the execution array
  26431. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  26432. */
  26433. stopRenderLoop(renderFunction?: () => void): void;
  26434. /** @hidden */ renderLoop(): void;
  26435. /**
  26436. * Register and execute a render loop. The engine can have more than one render function
  26437. * @param renderFunction defines the function to continuously execute
  26438. */
  26439. runRenderLoop(renderFunction: () => void): void;
  26440. /**
  26441. * Toggle full screen mode
  26442. * @param requestPointerLock defines if a pointer lock should be requested from the user
  26443. */
  26444. switchFullscreen(requestPointerLock: boolean): void;
  26445. /**
  26446. * Clear the current render buffer or the current render target (if any is set up)
  26447. * @param color defines the color to use
  26448. * @param backBuffer defines if the back buffer must be cleared
  26449. * @param depth defines if the depth buffer must be cleared
  26450. * @param stencil defines if the stencil buffer must be cleared
  26451. */
  26452. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  26453. /**
  26454. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  26455. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  26456. * @param y defines the y-coordinate of the corner of the clear rectangle
  26457. * @param width defines the width of the clear rectangle
  26458. * @param height defines the height of the clear rectangle
  26459. * @param clearColor defines the clear color
  26460. */
  26461. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  26462. /**
  26463. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  26464. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  26465. * @param y defines the y-coordinate of the corner of the clear rectangle
  26466. * @param width defines the width of the clear rectangle
  26467. * @param height defines the height of the clear rectangle
  26468. */
  26469. enableScissor(x: number, y: number, width: number, height: number): void;
  26470. /**
  26471. * Disable previously set scissor test rectangle
  26472. */
  26473. disableScissor(): void;
  26474. private _viewportCached;
  26475. /** @hidden */ viewport(x: number, y: number, width: number, height: number): void;
  26476. /**
  26477. * Set the WebGL's viewport
  26478. * @param viewport defines the viewport element to be used
  26479. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  26480. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  26481. */
  26482. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  26483. /**
  26484. * Directly set the WebGL Viewport
  26485. * @param x defines the x coordinate of the viewport (in screen space)
  26486. * @param y defines the y coordinate of the viewport (in screen space)
  26487. * @param width defines the width of the viewport (in screen space)
  26488. * @param height defines the height of the viewport (in screen space)
  26489. * @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
  26490. */
  26491. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  26492. /**
  26493. * Begin a new frame
  26494. */
  26495. beginFrame(): void;
  26496. /**
  26497. * Enf the current frame
  26498. */
  26499. endFrame(): void;
  26500. /**
  26501. * Resize the view according to the canvas' size
  26502. */
  26503. resize(): void;
  26504. /**
  26505. * Force a specific size of the canvas
  26506. * @param width defines the new canvas' width
  26507. * @param height defines the new canvas' height
  26508. */
  26509. setSize(width: number, height: number): void;
  26510. /**
  26511. * Gets a boolean indicating if a webVR device was detected
  26512. * @returns true if a webVR device was detected
  26513. */
  26514. isVRDevicePresent(): boolean;
  26515. /**
  26516. * Gets the current webVR device
  26517. * @returns the current webVR device (or null)
  26518. */
  26519. getVRDevice(): any;
  26520. /**
  26521. * Initializes a webVR display and starts listening to display change events
  26522. * The onVRDisplayChangedObservable will be notified upon these changes
  26523. * @returns The onVRDisplayChangedObservable
  26524. */
  26525. initWebVR(): Observable<IDisplayChangedEventArgs>;
  26526. /**
  26527. * Initializes a webVR display and starts listening to display change events
  26528. * The onVRDisplayChangedObservable will be notified upon these changes
  26529. * @returns A promise containing a VRDisplay and if vr is supported
  26530. */
  26531. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  26532. /**
  26533. * Call this function to switch to webVR mode
  26534. * Will do nothing if webVR is not supported or if there is no webVR device
  26535. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26536. */
  26537. enableVR(): void;
  26538. /**
  26539. * Call this function to leave webVR mode
  26540. * Will do nothing if webVR is not supported or if there is no webVR device
  26541. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26542. */
  26543. disableVR(): void;
  26544. private _onVRFullScreenTriggered;
  26545. private _getVRDisplaysAsync;
  26546. /**
  26547. * Binds the frame buffer to the specified texture.
  26548. * @param texture The texture to render to or null for the default canvas
  26549. * @param faceIndex The face of the texture to render to in case of cube texture
  26550. * @param requiredWidth The width of the target to render to
  26551. * @param requiredHeight The height of the target to render to
  26552. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  26553. * @param depthStencilTexture The depth stencil texture to use to render
  26554. * @param lodLevel defines le lod level to bind to the frame buffer
  26555. */
  26556. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  26557. private bindUnboundFramebuffer;
  26558. /**
  26559. * Unbind the current render target texture from the webGL context
  26560. * @param texture defines the render target texture to unbind
  26561. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  26562. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  26563. */
  26564. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  26565. /**
  26566. * Unbind a list of render target textures from the webGL context
  26567. * This is used only when drawBuffer extension or webGL2 are active
  26568. * @param textures defines the render target textures to unbind
  26569. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  26570. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  26571. */
  26572. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  26573. /**
  26574. * Force the mipmap generation for the given render target texture
  26575. * @param texture defines the render target texture to use
  26576. */
  26577. generateMipMapsForCubemap(texture: InternalTexture): void;
  26578. /**
  26579. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  26580. */
  26581. flushFramebuffer(): void;
  26582. /**
  26583. * Unbind the current render target and bind the default framebuffer
  26584. */
  26585. restoreDefaultFramebuffer(): void;
  26586. /**
  26587. * Create an uniform buffer
  26588. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26589. * @param elements defines the content of the uniform buffer
  26590. * @returns the webGL uniform buffer
  26591. */
  26592. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  26593. /**
  26594. * Create a dynamic uniform buffer
  26595. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26596. * @param elements defines the content of the uniform buffer
  26597. * @returns the webGL uniform buffer
  26598. */
  26599. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  26600. /**
  26601. * Update an existing uniform buffer
  26602. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26603. * @param uniformBuffer defines the target uniform buffer
  26604. * @param elements defines the content to update
  26605. * @param offset defines the offset in the uniform buffer where update should start
  26606. * @param count defines the size of the data to update
  26607. */
  26608. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  26609. private _resetVertexBufferBinding;
  26610. /**
  26611. * Creates a vertex buffer
  26612. * @param data the data for the vertex buffer
  26613. * @returns the new WebGL static buffer
  26614. */
  26615. createVertexBuffer(data: DataArray): WebGLBuffer;
  26616. /**
  26617. * Creates a dynamic vertex buffer
  26618. * @param data the data for the dynamic vertex buffer
  26619. * @returns the new WebGL dynamic buffer
  26620. */
  26621. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  26622. /**
  26623. * Update a dynamic index buffer
  26624. * @param indexBuffer defines the target index buffer
  26625. * @param indices defines the data to update
  26626. * @param offset defines the offset in the target index buffer where update should start
  26627. */
  26628. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  26629. /**
  26630. * Updates a dynamic vertex buffer.
  26631. * @param vertexBuffer the vertex buffer to update
  26632. * @param data the data used to update the vertex buffer
  26633. * @param byteOffset the byte offset of the data
  26634. * @param byteLength the byte length of the data
  26635. */
  26636. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  26637. private _resetIndexBufferBinding;
  26638. /**
  26639. * Creates a new index buffer
  26640. * @param indices defines the content of the index buffer
  26641. * @param updatable defines if the index buffer must be updatable
  26642. * @returns a new webGL buffer
  26643. */
  26644. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  26645. /**
  26646. * Bind a webGL buffer to the webGL context
  26647. * @param buffer defines the buffer to bind
  26648. */
  26649. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  26650. /**
  26651. * Bind an uniform buffer to the current webGL context
  26652. * @param buffer defines the buffer to bind
  26653. */
  26654. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  26655. /**
  26656. * Bind a buffer to the current webGL context at a given location
  26657. * @param buffer defines the buffer to bind
  26658. * @param location defines the index where to bind the buffer
  26659. */
  26660. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  26661. /**
  26662. * Bind a specific block at a given index in a specific shader program
  26663. * @param shaderProgram defines the shader program
  26664. * @param blockName defines the block name
  26665. * @param index defines the index where to bind the block
  26666. */
  26667. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  26668. private bindIndexBuffer;
  26669. private bindBuffer;
  26670. /**
  26671. * update the bound buffer with the given data
  26672. * @param data defines the data to update
  26673. */
  26674. updateArrayBuffer(data: Float32Array): void;
  26675. private _vertexAttribPointer;
  26676. private _bindIndexBufferWithCache;
  26677. private _bindVertexBuffersAttributes;
  26678. /**
  26679. * Records a vertex array object
  26680. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  26681. * @param vertexBuffers defines the list of vertex buffers to store
  26682. * @param indexBuffer defines the index buffer to store
  26683. * @param effect defines the effect to store
  26684. * @returns the new vertex array object
  26685. */
  26686. recordVertexArrayObject(vertexBuffers: {
  26687. [key: string]: VertexBuffer;
  26688. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  26689. /**
  26690. * Bind a specific vertex array object
  26691. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  26692. * @param vertexArrayObject defines the vertex array object to bind
  26693. * @param indexBuffer defines the index buffer to bind
  26694. */
  26695. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  26696. /**
  26697. * Bind webGl buffers directly to the webGL context
  26698. * @param vertexBuffer defines the vertex buffer to bind
  26699. * @param indexBuffer defines the index buffer to bind
  26700. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  26701. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  26702. * @param effect defines the effect associated with the vertex buffer
  26703. */
  26704. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  26705. private _unbindVertexArrayObject;
  26706. /**
  26707. * Bind a list of vertex buffers to the webGL context
  26708. * @param vertexBuffers defines the list of vertex buffers to bind
  26709. * @param indexBuffer defines the index buffer to bind
  26710. * @param effect defines the effect associated with the vertex buffers
  26711. */
  26712. bindBuffers(vertexBuffers: {
  26713. [key: string]: Nullable<VertexBuffer>;
  26714. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  26715. /**
  26716. * Unbind all instance attributes
  26717. */
  26718. unbindInstanceAttributes(): void;
  26719. /**
  26720. * Release and free the memory of a vertex array object
  26721. * @param vao defines the vertex array object to delete
  26722. */
  26723. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  26724. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  26725. /**
  26726. * Creates a webGL buffer to use with instanciation
  26727. * @param capacity defines the size of the buffer
  26728. * @returns the webGL buffer
  26729. */
  26730. createInstancesBuffer(capacity: number): WebGLBuffer;
  26731. /**
  26732. * Delete a webGL buffer used with instanciation
  26733. * @param buffer defines the webGL buffer to delete
  26734. */
  26735. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  26736. /**
  26737. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  26738. * @param instancesBuffer defines the webGL buffer to update and bind
  26739. * @param data defines the data to store in the buffer
  26740. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  26741. */
  26742. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  26743. /**
  26744. * Apply all cached states (depth, culling, stencil and alpha)
  26745. */
  26746. applyStates(): void;
  26747. /**
  26748. * Send a draw order
  26749. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  26750. * @param indexStart defines the starting index
  26751. * @param indexCount defines the number of index to draw
  26752. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26753. */
  26754. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  26755. /**
  26756. * Draw a list of points
  26757. * @param verticesStart defines the index of first vertex to draw
  26758. * @param verticesCount defines the count of vertices to draw
  26759. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26760. */
  26761. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  26762. /**
  26763. * Draw a list of unindexed primitives
  26764. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  26765. * @param verticesStart defines the index of first vertex to draw
  26766. * @param verticesCount defines the count of vertices to draw
  26767. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26768. */
  26769. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  26770. /**
  26771. * Draw a list of indexed primitives
  26772. * @param fillMode defines the primitive to use
  26773. * @param indexStart defines the starting index
  26774. * @param indexCount defines the number of index to draw
  26775. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26776. */
  26777. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  26778. /**
  26779. * Draw a list of unindexed primitives
  26780. * @param fillMode defines the primitive to use
  26781. * @param verticesStart defines the index of first vertex to draw
  26782. * @param verticesCount defines the count of vertices to draw
  26783. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26784. */
  26785. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  26786. private _drawMode;
  26787. /** @hidden */ releaseEffect(effect: Effect): void;
  26788. /** @hidden */ deleteProgram(program: WebGLProgram): void;
  26789. /**
  26790. * Create a new effect (used to store vertex/fragment shaders)
  26791. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  26792. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  26793. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  26794. * @param samplers defines an array of string used to represent textures
  26795. * @param defines defines the string containing the defines to use to compile the shaders
  26796. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  26797. * @param onCompiled defines a function to call when the effect creation is successful
  26798. * @param onError defines a function to call when the effect creation has failed
  26799. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  26800. * @returns the new Effect
  26801. */
  26802. 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;
  26803. private _compileShader;
  26804. private _compileRawShader;
  26805. /**
  26806. * Directly creates a webGL program
  26807. * @param vertexCode defines the vertex shader code to use
  26808. * @param fragmentCode defines the fragment shader code to use
  26809. * @param context defines the webGL context to use (if not set, the current one will be used)
  26810. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  26811. * @returns the new webGL program
  26812. */
  26813. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  26814. /**
  26815. * Creates a webGL program
  26816. * @param vertexCode defines the vertex shader code to use
  26817. * @param fragmentCode defines the fragment shader code to use
  26818. * @param defines defines the string containing the defines to use to compile the shaders
  26819. * @param context defines the webGL context to use (if not set, the current one will be used)
  26820. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  26821. * @returns the new webGL program
  26822. */
  26823. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  26824. private _createShaderProgram;
  26825. private _finalizeProgram;
  26826. /** @hidden */ isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  26827. /** @hidden */ executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  26828. /**
  26829. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  26830. * @param shaderProgram defines the webGL program to use
  26831. * @param uniformsNames defines the list of uniform names
  26832. * @returns an array of webGL uniform locations
  26833. */
  26834. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  26835. /**
  26836. * Gets the lsit of active attributes for a given webGL program
  26837. * @param shaderProgram defines the webGL program to use
  26838. * @param attributesNames defines the list of attribute names to get
  26839. * @returns an array of indices indicating the offset of each attribute
  26840. */
  26841. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  26842. /**
  26843. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  26844. * @param effect defines the effect to activate
  26845. */
  26846. enableEffect(effect: Nullable<Effect>): void;
  26847. /**
  26848. * Set the value of an uniform to an array of int32
  26849. * @param uniform defines the webGL uniform location where to store the value
  26850. * @param array defines the array of int32 to store
  26851. */
  26852. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  26853. /**
  26854. * Set the value of an uniform to an array of int32 (stored as vec2)
  26855. * @param uniform defines the webGL uniform location where to store the value
  26856. * @param array defines the array of int32 to store
  26857. */
  26858. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  26859. /**
  26860. * Set the value of an uniform to an array of int32 (stored as vec3)
  26861. * @param uniform defines the webGL uniform location where to store the value
  26862. * @param array defines the array of int32 to store
  26863. */
  26864. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  26865. /**
  26866. * Set the value of an uniform to an array of int32 (stored as vec4)
  26867. * @param uniform defines the webGL uniform location where to store the value
  26868. * @param array defines the array of int32 to store
  26869. */
  26870. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  26871. /**
  26872. * Set the value of an uniform to an array of float32
  26873. * @param uniform defines the webGL uniform location where to store the value
  26874. * @param array defines the array of float32 to store
  26875. */
  26876. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  26877. /**
  26878. * Set the value of an uniform to an array of float32 (stored as vec2)
  26879. * @param uniform defines the webGL uniform location where to store the value
  26880. * @param array defines the array of float32 to store
  26881. */
  26882. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  26883. /**
  26884. * Set the value of an uniform to an array of float32 (stored as vec3)
  26885. * @param uniform defines the webGL uniform location where to store the value
  26886. * @param array defines the array of float32 to store
  26887. */
  26888. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  26889. /**
  26890. * Set the value of an uniform to an array of float32 (stored as vec4)
  26891. * @param uniform defines the webGL uniform location where to store the value
  26892. * @param array defines the array of float32 to store
  26893. */
  26894. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  26895. /**
  26896. * Set the value of an uniform to an array of number
  26897. * @param uniform defines the webGL uniform location where to store the value
  26898. * @param array defines the array of number to store
  26899. */
  26900. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  26901. /**
  26902. * Set the value of an uniform to an array of number (stored as vec2)
  26903. * @param uniform defines the webGL uniform location where to store the value
  26904. * @param array defines the array of number to store
  26905. */
  26906. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  26907. /**
  26908. * Set the value of an uniform to an array of number (stored as vec3)
  26909. * @param uniform defines the webGL uniform location where to store the value
  26910. * @param array defines the array of number to store
  26911. */
  26912. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  26913. /**
  26914. * Set the value of an uniform to an array of number (stored as vec4)
  26915. * @param uniform defines the webGL uniform location where to store the value
  26916. * @param array defines the array of number to store
  26917. */
  26918. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  26919. /**
  26920. * Set the value of an uniform to an array of float32 (stored as matrices)
  26921. * @param uniform defines the webGL uniform location where to store the value
  26922. * @param matrices defines the array of float32 to store
  26923. */
  26924. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  26925. /**
  26926. * Set the value of an uniform to a matrix
  26927. * @param uniform defines the webGL uniform location where to store the value
  26928. * @param matrix defines the matrix to store
  26929. */
  26930. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  26931. /**
  26932. * Set the value of an uniform to a matrix (3x3)
  26933. * @param uniform defines the webGL uniform location where to store the value
  26934. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  26935. */
  26936. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  26937. /**
  26938. * Set the value of an uniform to a matrix (2x2)
  26939. * @param uniform defines the webGL uniform location where to store the value
  26940. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  26941. */
  26942. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  26943. /**
  26944. * Set the value of an uniform to a number (int)
  26945. * @param uniform defines the webGL uniform location where to store the value
  26946. * @param value defines the int number to store
  26947. */
  26948. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  26949. /**
  26950. * Set the value of an uniform to a number (float)
  26951. * @param uniform defines the webGL uniform location where to store the value
  26952. * @param value defines the float number to store
  26953. */
  26954. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  26955. /**
  26956. * Set the value of an uniform to a vec2
  26957. * @param uniform defines the webGL uniform location where to store the value
  26958. * @param x defines the 1st component of the value
  26959. * @param y defines the 2nd component of the value
  26960. */
  26961. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  26962. /**
  26963. * Set the value of an uniform to a vec3
  26964. * @param uniform defines the webGL uniform location where to store the value
  26965. * @param x defines the 1st component of the value
  26966. * @param y defines the 2nd component of the value
  26967. * @param z defines the 3rd component of the value
  26968. */
  26969. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  26970. /**
  26971. * Set the value of an uniform to a boolean
  26972. * @param uniform defines the webGL uniform location where to store the value
  26973. * @param bool defines the boolean to store
  26974. */
  26975. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  26976. /**
  26977. * Set the value of an uniform to a vec4
  26978. * @param uniform defines the webGL uniform location where to store the value
  26979. * @param x defines the 1st component of the value
  26980. * @param y defines the 2nd component of the value
  26981. * @param z defines the 3rd component of the value
  26982. * @param w defines the 4th component of the value
  26983. */
  26984. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  26985. /**
  26986. * Set the value of an uniform to a Color3
  26987. * @param uniform defines the webGL uniform location where to store the value
  26988. * @param color3 defines the color to store
  26989. */
  26990. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  26991. /**
  26992. * Set the value of an uniform to a Color3 and an alpha value
  26993. * @param uniform defines the webGL uniform location where to store the value
  26994. * @param color3 defines the color to store
  26995. * @param alpha defines the alpha component to store
  26996. */
  26997. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  26998. /**
  26999. * Sets a Color4 on a uniform variable
  27000. * @param uniform defines the uniform location
  27001. * @param color4 defines the value to be set
  27002. */
  27003. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  27004. /**
  27005. * Set various states to the webGL context
  27006. * @param culling defines backface culling state
  27007. * @param zOffset defines the value to apply to zOffset (0 by default)
  27008. * @param force defines if states must be applied even if cache is up to date
  27009. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  27010. */
  27011. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  27012. /**
  27013. * Set the z offset to apply to current rendering
  27014. * @param value defines the offset to apply
  27015. */
  27016. setZOffset(value: number): void;
  27017. /**
  27018. * Gets the current value of the zOffset
  27019. * @returns the current zOffset state
  27020. */
  27021. getZOffset(): number;
  27022. /**
  27023. * Enable or disable depth buffering
  27024. * @param enable defines the state to set
  27025. */
  27026. setDepthBuffer(enable: boolean): void;
  27027. /**
  27028. * Gets a boolean indicating if depth writing is enabled
  27029. * @returns the current depth writing state
  27030. */
  27031. getDepthWrite(): boolean;
  27032. /**
  27033. * Enable or disable depth writing
  27034. * @param enable defines the state to set
  27035. */
  27036. setDepthWrite(enable: boolean): void;
  27037. /**
  27038. * Enable or disable color writing
  27039. * @param enable defines the state to set
  27040. */
  27041. setColorWrite(enable: boolean): void;
  27042. /**
  27043. * Gets a boolean indicating if color writing is enabled
  27044. * @returns the current color writing state
  27045. */
  27046. getColorWrite(): boolean;
  27047. /**
  27048. * Sets alpha constants used by some alpha blending modes
  27049. * @param r defines the red component
  27050. * @param g defines the green component
  27051. * @param b defines the blue component
  27052. * @param a defines the alpha component
  27053. */
  27054. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  27055. /**
  27056. * Sets the current alpha mode
  27057. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  27058. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  27059. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27060. */
  27061. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  27062. /**
  27063. * Gets the current alpha mode
  27064. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27065. * @returns the current alpha mode
  27066. */
  27067. getAlphaMode(): number;
  27068. /**
  27069. * Clears the list of texture accessible through engine.
  27070. * This can help preventing texture load conflict due to name collision.
  27071. */
  27072. clearInternalTexturesCache(): void;
  27073. /**
  27074. * Force the entire cache to be cleared
  27075. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  27076. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  27077. */
  27078. wipeCaches(bruteForce?: boolean): void;
  27079. /**
  27080. * Set the compressed texture format to use, based on the formats you have, and the formats
  27081. * supported by the hardware / browser.
  27082. *
  27083. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  27084. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  27085. * to API arguments needed to compressed textures. This puts the burden on the container
  27086. * generator to house the arcane code for determining these for current & future formats.
  27087. *
  27088. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27089. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27090. *
  27091. * Note: The result of this call is not taken into account when a texture is base64.
  27092. *
  27093. * @param formatsAvailable defines the list of those format families you have created
  27094. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  27095. *
  27096. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  27097. * @returns The extension selected.
  27098. */
  27099. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  27100. private _getSamplingParameters;
  27101. private _partialLoadImg;
  27102. private _cascadeLoadImgs;
  27103. /** @hidden */ createTexture(): WebGLTexture;
  27104. /**
  27105. * Usually called from Texture.ts.
  27106. * Passed information to create a WebGLTexture
  27107. * @param urlArg defines a value which contains one of the following:
  27108. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  27109. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  27110. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  27111. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  27112. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  27113. * @param scene needed for loading to the correct scene
  27114. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  27115. * @param onLoad optional callback to be called upon successful completion
  27116. * @param onError optional callback to be called upon failure
  27117. * @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
  27118. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  27119. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  27120. * @param forcedExtension defines the extension to use to pick the right loader
  27121. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  27122. * @returns a InternalTexture for assignment back into BABYLON.Texture
  27123. */
  27124. 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>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  27125. private _rescaleTexture;
  27126. /**
  27127. * Update a raw texture
  27128. * @param texture defines the texture to update
  27129. * @param data defines the data to store in the texture
  27130. * @param format defines the format of the data
  27131. * @param invertY defines if data must be stored with Y axis inverted
  27132. * @param compression defines the compression used (null by default)
  27133. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27134. */
  27135. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  27136. /**
  27137. * Creates a raw texture
  27138. * @param data defines the data to store in the texture
  27139. * @param width defines the width of the texture
  27140. * @param height defines the height of the texture
  27141. * @param format defines the format of the data
  27142. * @param generateMipMaps defines if the engine should generate the mip levels
  27143. * @param invertY defines if data must be stored with Y axis inverted
  27144. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27145. * @param compression defines the compression used (null by default)
  27146. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27147. * @returns the raw texture inside an InternalTexture
  27148. */
  27149. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  27150. private _unpackFlipYCached;
  27151. /**
  27152. * In case you are sharing the context with other applications, it might
  27153. * be interested to not cache the unpack flip y state to ensure a consistent
  27154. * value would be set.
  27155. */
  27156. enableUnpackFlipYCached: boolean;
  27157. /** @hidden */ unpackFlipY(value: boolean): void;
  27158. /** @hidden */ getUnpackAlignement(): number;
  27159. /**
  27160. * Creates a dynamic texture
  27161. * @param width defines the width of the texture
  27162. * @param height defines the height of the texture
  27163. * @param generateMipMaps defines if the engine should generate the mip levels
  27164. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27165. * @returns the dynamic texture inside an InternalTexture
  27166. */
  27167. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  27168. /**
  27169. * Update the sampling mode of a given texture
  27170. * @param samplingMode defines the required sampling mode
  27171. * @param texture defines the texture to update
  27172. */
  27173. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  27174. /**
  27175. * Update the content of a dynamic texture
  27176. * @param texture defines the texture to update
  27177. * @param canvas defines the canvas containing the source
  27178. * @param invertY defines if data must be stored with Y axis inverted
  27179. * @param premulAlpha defines if alpha is stored as premultiplied
  27180. * @param format defines the format of the data
  27181. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  27182. */
  27183. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  27184. /**
  27185. * Update a video texture
  27186. * @param texture defines the texture to update
  27187. * @param video defines the video element to use
  27188. * @param invertY defines if data must be stored with Y axis inverted
  27189. */
  27190. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  27191. /**
  27192. * Updates a depth texture Comparison Mode and Function.
  27193. * If the comparison Function is equal to 0, the mode will be set to none.
  27194. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  27195. * @param texture The texture to set the comparison function for
  27196. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  27197. */
  27198. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  27199. private _setupDepthStencilTexture;
  27200. /**
  27201. * Creates a depth stencil texture.
  27202. * This is only available in WebGL 2 or with the depth texture extension available.
  27203. * @param size The size of face edge in the texture.
  27204. * @param options The options defining the texture.
  27205. * @returns The texture
  27206. */
  27207. createDepthStencilTexture(size: number | {
  27208. width: number;
  27209. height: number;
  27210. }, options: DepthTextureCreationOptions): InternalTexture;
  27211. /**
  27212. * Creates a depth stencil texture.
  27213. * This is only available in WebGL 2 or with the depth texture extension available.
  27214. * @param size The size of face edge in the texture.
  27215. * @param options The options defining the texture.
  27216. * @returns The texture
  27217. */
  27218. private _createDepthStencilTexture;
  27219. /**
  27220. * Creates a depth stencil cube texture.
  27221. * This is only available in WebGL 2.
  27222. * @param size The size of face edge in the cube texture.
  27223. * @param options The options defining the cube texture.
  27224. * @returns The cube texture
  27225. */
  27226. private _createDepthStencilCubeTexture;
  27227. /**
  27228. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  27229. * @param renderTarget The render target to set the frame buffer for
  27230. */
  27231. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  27232. /**
  27233. * Creates a new render target texture
  27234. * @param size defines the size of the texture
  27235. * @param options defines the options used to create the texture
  27236. * @returns a new render target texture stored in an InternalTexture
  27237. */
  27238. createRenderTargetTexture(size: number | {
  27239. width: number;
  27240. height: number;
  27241. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  27242. /**
  27243. * Create a multi render target texture
  27244. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  27245. * @param size defines the size of the texture
  27246. * @param options defines the creation options
  27247. * @returns the cube texture as an InternalTexture
  27248. */
  27249. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  27250. private _setupFramebufferDepthAttachments;
  27251. /**
  27252. * Updates the sample count of a render target texture
  27253. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27254. * @param texture defines the texture to update
  27255. * @param samples defines the sample count to set
  27256. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27257. */
  27258. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  27259. /**
  27260. * Update the sample count for a given multiple render target texture
  27261. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27262. * @param textures defines the textures to update
  27263. * @param samples defines the sample count to set
  27264. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27265. */
  27266. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  27267. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27268. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27269. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27270. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  27271. /**
  27272. * Creates a new render target cube texture
  27273. * @param size defines the size of the texture
  27274. * @param options defines the options used to create the texture
  27275. * @returns a new render target cube texture stored in an InternalTexture
  27276. */
  27277. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  27278. /**
  27279. * Creates a cube texture
  27280. * @param rootUrl defines the url where the files to load is located
  27281. * @param scene defines the current scene
  27282. * @param files defines the list of files to load (1 per face)
  27283. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  27284. * @param onLoad defines an optional callback raised when the texture is loaded
  27285. * @param onError defines an optional callback raised if there is an issue to load the texture
  27286. * @param format defines the format of the data
  27287. * @param forcedExtension defines the extension to use to pick the right loader
  27288. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  27289. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  27290. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  27291. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  27292. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  27293. * @returns the cube texture as an InternalTexture
  27294. */
  27295. 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>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  27296. /**
  27297. * @hidden
  27298. */ setCubeMapTextureParams(loadMipmap: boolean): void;
  27299. /**
  27300. * Update a raw cube texture
  27301. * @param texture defines the texture to udpdate
  27302. * @param data defines the data to store
  27303. * @param format defines the data format
  27304. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27305. * @param invertY defines if data must be stored with Y axis inverted
  27306. * @param compression defines the compression used (null by default)
  27307. * @param level defines which level of the texture to update
  27308. */
  27309. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  27310. /**
  27311. * Creates a new raw cube texture
  27312. * @param data defines the array of data to use to create each face
  27313. * @param size defines the size of the textures
  27314. * @param format defines the format of the data
  27315. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27316. * @param generateMipMaps defines if the engine should generate the mip levels
  27317. * @param invertY defines if data must be stored with Y axis inverted
  27318. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27319. * @param compression defines the compression used (null by default)
  27320. * @returns the cube texture as an InternalTexture
  27321. */
  27322. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  27323. /**
  27324. * Creates a new raw cube texture from a specified url
  27325. * @param url defines the url where the data is located
  27326. * @param scene defines the current scene
  27327. * @param size defines the size of the textures
  27328. * @param format defines the format of the data
  27329. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27330. * @param noMipmap defines if the engine should avoid generating the mip levels
  27331. * @param callback defines a callback used to extract texture data from loaded data
  27332. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  27333. * @param onLoad defines a callback called when texture is loaded
  27334. * @param onError defines a callback called if there is an error
  27335. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27336. * @param invertY defines if data must be stored with Y axis inverted
  27337. * @returns the cube texture as an InternalTexture
  27338. */
  27339. 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;
  27340. /**
  27341. * Update a raw 3D texture
  27342. * @param texture defines the texture to update
  27343. * @param data defines the data to store
  27344. * @param format defines the data format
  27345. * @param invertY defines if data must be stored with Y axis inverted
  27346. * @param compression defines the used compression (can be null)
  27347. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  27348. */
  27349. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  27350. /**
  27351. * Creates a new raw 3D texture
  27352. * @param data defines the data used to create the texture
  27353. * @param width defines the width of the texture
  27354. * @param height defines the height of the texture
  27355. * @param depth defines the depth of the texture
  27356. * @param format defines the format of the texture
  27357. * @param generateMipMaps defines if the engine must generate mip levels
  27358. * @param invertY defines if data must be stored with Y axis inverted
  27359. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27360. * @param compression defines the compressed used (can be null)
  27361. * @param textureType defines the compressed used (can be null)
  27362. * @returns a new raw 3D texture (stored in an InternalTexture)
  27363. */
  27364. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  27365. private _prepareWebGLTextureContinuation;
  27366. private _prepareWebGLTexture;
  27367. private _convertRGBtoRGBATextureData;
  27368. /** @hidden */ releaseFramebufferObjects(texture: InternalTexture): void;
  27369. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  27370. private setProgram;
  27371. private _boundUniforms;
  27372. /**
  27373. * Binds an effect to the webGL context
  27374. * @param effect defines the effect to bind
  27375. */
  27376. bindSamplers(effect: Effect): void;
  27377. private _moveBoundTextureOnTop;
  27378. private _getCorrectTextureChannel;
  27379. private _linkTrackers;
  27380. private _removeDesignatedSlot;
  27381. private _activateCurrentTexture;
  27382. /** @hidden */ bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  27383. /** @hidden */ bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  27384. /**
  27385. * Sets a texture to the webGL context from a postprocess
  27386. * @param channel defines the channel to use
  27387. * @param postProcess defines the source postprocess
  27388. */
  27389. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  27390. /**
  27391. * Binds the output of the passed in post process to the texture channel specified
  27392. * @param channel The channel the texture should be bound to
  27393. * @param postProcess The post process which's output should be bound
  27394. */
  27395. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  27396. /**
  27397. * Unbind all textures from the webGL context
  27398. */
  27399. unbindAllTextures(): void;
  27400. /**
  27401. * Sets a texture to the according uniform.
  27402. * @param channel The texture channel
  27403. * @param uniform The uniform to set
  27404. * @param texture The texture to apply
  27405. */
  27406. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  27407. /**
  27408. * Sets a depth stencil texture from a render target to the according uniform.
  27409. * @param channel The texture channel
  27410. * @param uniform The uniform to set
  27411. * @param texture The render target texture containing the depth stencil texture to apply
  27412. */
  27413. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  27414. private _bindSamplerUniformToChannel;
  27415. private _getTextureWrapMode;
  27416. private _setTexture;
  27417. /**
  27418. * Sets an array of texture to the webGL context
  27419. * @param channel defines the channel where the texture array must be set
  27420. * @param uniform defines the associated uniform location
  27421. * @param textures defines the array of textures to bind
  27422. */
  27423. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  27424. /** @hidden */ setAnisotropicLevel(target: number, texture: BaseTexture): void;
  27425. private _setTextureParameterFloat;
  27426. private _setTextureParameterInteger;
  27427. /**
  27428. * Reads pixels from the current frame buffer. Please note that this function can be slow
  27429. * @param x defines the x coordinate of the rectangle where pixels must be read
  27430. * @param y defines the y coordinate of the rectangle where pixels must be read
  27431. * @param width defines the width of the rectangle where pixels must be read
  27432. * @param height defines the height of the rectangle where pixels must be read
  27433. * @returns a Uint8Array containing RGBA colors
  27434. */
  27435. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  27436. /**
  27437. * Add an externaly attached data from its key.
  27438. * This method call will fail and return false, if such key already exists.
  27439. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  27440. * @param key the unique key that identifies the data
  27441. * @param data the data object to associate to the key for this Engine instance
  27442. * @return true if no such key were already present and the data was added successfully, false otherwise
  27443. */
  27444. addExternalData<T>(key: string, data: T): boolean;
  27445. /**
  27446. * Get an externaly attached data from its key
  27447. * @param key the unique key that identifies the data
  27448. * @return the associated data, if present (can be null), or undefined if not present
  27449. */
  27450. getExternalData<T>(key: string): T;
  27451. /**
  27452. * Get an externaly attached data from its key, create it using a factory if it's not already present
  27453. * @param key the unique key that identifies the data
  27454. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  27455. * @return the associated data, can be null if the factory returned null.
  27456. */
  27457. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  27458. /**
  27459. * Remove an externaly attached data from the Engine instance
  27460. * @param key the unique key that identifies the data
  27461. * @return true if the data was successfully removed, false if it doesn't exist
  27462. */
  27463. removeExternalData(key: string): boolean;
  27464. /**
  27465. * Unbind all vertex attributes from the webGL context
  27466. */
  27467. unbindAllAttributes(): void;
  27468. /**
  27469. * 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
  27470. */
  27471. releaseEffects(): void;
  27472. /**
  27473. * Dispose and release all associated resources
  27474. */
  27475. dispose(): void;
  27476. /**
  27477. * Display the loading screen
  27478. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27479. */
  27480. displayLoadingUI(): void;
  27481. /**
  27482. * Hide the loading screen
  27483. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27484. */
  27485. hideLoadingUI(): void;
  27486. /**
  27487. * Gets the current loading screen object
  27488. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27489. */
  27490. /**
  27491. * Sets the current loading screen object
  27492. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27493. */
  27494. loadingScreen: ILoadingScreen;
  27495. /**
  27496. * Sets the current loading screen text
  27497. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27498. */
  27499. loadingUIText: string;
  27500. /**
  27501. * Sets the current loading screen background color
  27502. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27503. */
  27504. loadingUIBackgroundColor: string;
  27505. /**
  27506. * Attach a new callback raised when context lost event is fired
  27507. * @param callback defines the callback to call
  27508. */
  27509. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  27510. /**
  27511. * Attach a new callback raised when context restored event is fired
  27512. * @param callback defines the callback to call
  27513. */
  27514. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  27515. /**
  27516. * Gets the source code of the vertex shader associated with a specific webGL program
  27517. * @param program defines the program to use
  27518. * @returns a string containing the source code of the vertex shader associated with the program
  27519. */
  27520. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  27521. /**
  27522. * Gets the source code of the fragment shader associated with a specific webGL program
  27523. * @param program defines the program to use
  27524. * @returns a string containing the source code of the fragment shader associated with the program
  27525. */
  27526. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  27527. /**
  27528. * Get the current error code of the webGL context
  27529. * @returns the error code
  27530. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  27531. */
  27532. getError(): number;
  27533. /**
  27534. * Gets the current framerate
  27535. * @returns a number representing the framerate
  27536. */
  27537. getFps(): number;
  27538. /**
  27539. * Gets the time spent between current and previous frame
  27540. * @returns a number representing the delta time in ms
  27541. */
  27542. getDeltaTime(): number;
  27543. private _measureFps;
  27544. /** @hidden */ readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  27545. private _canRenderToFloatFramebuffer;
  27546. private _canRenderToHalfFloatFramebuffer;
  27547. private _canRenderToFramebuffer;
  27548. /** @hidden */ getWebGLTextureType(type: number): number;
  27549. private _getInternalFormat;
  27550. /** @hidden */ getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  27551. /** @hidden */ getRGBAMultiSampleBufferFormat(type: number): number;
  27552. /** @hidden */ loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  27553. /** @hidden */ loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  27554. private _partialLoadFile;
  27555. private _cascadeLoadFiles;
  27556. /**
  27557. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  27558. * @returns true if the engine can be created
  27559. * @ignorenaming
  27560. */
  27561. static isSupported(): boolean;
  27562. }
  27563. }
  27564. declare module BABYLON {
  27565. /**
  27566. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  27567. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  27568. */
  27569. export class EffectFallbacks {
  27570. private _defines;
  27571. private _currentRank;
  27572. private _maxRank;
  27573. private _mesh;
  27574. /**
  27575. * Removes the fallback from the bound mesh.
  27576. */
  27577. unBindMesh(): void;
  27578. /**
  27579. * Adds a fallback on the specified property.
  27580. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27581. * @param define The name of the define in the shader
  27582. */
  27583. addFallback(rank: number, define: string): void;
  27584. /**
  27585. * Sets the mesh to use CPU skinning when needing to fallback.
  27586. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27587. * @param mesh The mesh to use the fallbacks.
  27588. */
  27589. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  27590. /**
  27591. * Checks to see if more fallbacks are still availible.
  27592. */
  27593. readonly isMoreFallbacks: boolean;
  27594. /**
  27595. * Removes the defines that shoould be removed when falling back.
  27596. * @param currentDefines defines the current define statements for the shader.
  27597. * @param effect defines the current effect we try to compile
  27598. * @returns The resulting defines with defines of the current rank removed.
  27599. */
  27600. reduce(currentDefines: string, effect: Effect): string;
  27601. }
  27602. /**
  27603. * Options to be used when creating an effect.
  27604. */
  27605. export class EffectCreationOptions {
  27606. /**
  27607. * Atrributes that will be used in the shader.
  27608. */
  27609. attributes: string[];
  27610. /**
  27611. * Uniform varible names that will be set in the shader.
  27612. */
  27613. uniformsNames: string[];
  27614. /**
  27615. * Uniform buffer varible names that will be set in the shader.
  27616. */
  27617. uniformBuffersNames: string[];
  27618. /**
  27619. * Sampler texture variable names that will be set in the shader.
  27620. */
  27621. samplers: string[];
  27622. /**
  27623. * Define statements that will be set in the shader.
  27624. */
  27625. defines: any;
  27626. /**
  27627. * Possible fallbacks for this effect to improve performance when needed.
  27628. */
  27629. fallbacks: Nullable<EffectFallbacks>;
  27630. /**
  27631. * Callback that will be called when the shader is compiled.
  27632. */
  27633. onCompiled: Nullable<(effect: Effect) => void>;
  27634. /**
  27635. * Callback that will be called if an error occurs during shader compilation.
  27636. */
  27637. onError: Nullable<(effect: Effect, errors: string) => void>;
  27638. /**
  27639. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27640. */
  27641. indexParameters: any;
  27642. /**
  27643. * Max number of lights that can be used in the shader.
  27644. */
  27645. maxSimultaneousLights: number;
  27646. /**
  27647. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27648. */
  27649. transformFeedbackVaryings: Nullable<string[]>;
  27650. }
  27651. /**
  27652. * Effect containing vertex and fragment shader that can be executed on an object.
  27653. */
  27654. export class Effect {
  27655. /**
  27656. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27657. */
  27658. static ShadersRepository: string;
  27659. /**
  27660. * Name of the effect.
  27661. */
  27662. name: any;
  27663. /**
  27664. * String container all the define statements that should be set on the shader.
  27665. */
  27666. defines: string;
  27667. /**
  27668. * Callback that will be called when the shader is compiled.
  27669. */
  27670. onCompiled: Nullable<(effect: Effect) => void>;
  27671. /**
  27672. * Callback that will be called if an error occurs during shader compilation.
  27673. */
  27674. onError: Nullable<(effect: Effect, errors: string) => void>;
  27675. /**
  27676. * Callback that will be called when effect is bound.
  27677. */
  27678. onBind: Nullable<(effect: Effect) => void>;
  27679. /**
  27680. * Unique ID of the effect.
  27681. */
  27682. uniqueId: number;
  27683. /**
  27684. * Observable that will be called when the shader is compiled.
  27685. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27686. */
  27687. onCompileObservable: Observable<Effect>;
  27688. /**
  27689. * Observable that will be called if an error occurs during shader compilation.
  27690. */
  27691. onErrorObservable: Observable<Effect>;
  27692. /** @hidden */ onBindObservable: Nullable<Observable<Effect>>;
  27693. /**
  27694. * Observable that will be called when effect is bound.
  27695. */
  27696. readonly onBindObservable: Observable<Effect>;
  27697. /** @hidden */ bonesComputationForcedToCPU: boolean;
  27698. private static _uniqueIdSeed;
  27699. private _engine;
  27700. private _uniformBuffersNames;
  27701. private _uniformsNames;
  27702. private _samplers;
  27703. private _isReady;
  27704. private _compilationError;
  27705. private _attributesNames;
  27706. private _attributes;
  27707. private _uniforms;
  27708. /**
  27709. * Key for the effect.
  27710. * @hidden
  27711. */ key: string;
  27712. private _indexParameters;
  27713. private _fallbacks;
  27714. private _vertexSourceCode;
  27715. private _fragmentSourceCode;
  27716. private _vertexSourceCodeOverride;
  27717. private _fragmentSourceCodeOverride;
  27718. private _transformFeedbackVaryings;
  27719. /**
  27720. * Compiled shader to webGL program.
  27721. * @hidden
  27722. */ program: WebGLProgram;
  27723. private _valueCache;
  27724. private static _baseCache;
  27725. /**
  27726. * Instantiates an effect.
  27727. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27728. * @param baseName Name of the effect.
  27729. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27730. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27731. * @param samplers List of sampler variables that will be passed to the shader.
  27732. * @param engine Engine to be used to render the effect
  27733. * @param defines Define statements to be added to the shader.
  27734. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27735. * @param onCompiled Callback that will be called when the shader is compiled.
  27736. * @param onError Callback that will be called if an error occurs during shader compilation.
  27737. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27738. */
  27739. 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);
  27740. /**
  27741. * Unique key for this effect
  27742. */
  27743. readonly key: string;
  27744. /**
  27745. * If the effect has been compiled and prepared.
  27746. * @returns if the effect is compiled and prepared.
  27747. */
  27748. isReady(): boolean;
  27749. /**
  27750. * The engine the effect was initialized with.
  27751. * @returns the engine.
  27752. */
  27753. getEngine(): Engine;
  27754. /**
  27755. * The compiled webGL program for the effect
  27756. * @returns the webGL program.
  27757. */
  27758. getProgram(): WebGLProgram;
  27759. /**
  27760. * The set of names of attribute variables for the shader.
  27761. * @returns An array of attribute names.
  27762. */
  27763. getAttributesNames(): string[];
  27764. /**
  27765. * Returns the attribute at the given index.
  27766. * @param index The index of the attribute.
  27767. * @returns The location of the attribute.
  27768. */
  27769. getAttributeLocation(index: number): number;
  27770. /**
  27771. * Returns the attribute based on the name of the variable.
  27772. * @param name of the attribute to look up.
  27773. * @returns the attribute location.
  27774. */
  27775. getAttributeLocationByName(name: string): number;
  27776. /**
  27777. * The number of attributes.
  27778. * @returns the numnber of attributes.
  27779. */
  27780. getAttributesCount(): number;
  27781. /**
  27782. * Gets the index of a uniform variable.
  27783. * @param uniformName of the uniform to look up.
  27784. * @returns the index.
  27785. */
  27786. getUniformIndex(uniformName: string): number;
  27787. /**
  27788. * Returns the attribute based on the name of the variable.
  27789. * @param uniformName of the uniform to look up.
  27790. * @returns the location of the uniform.
  27791. */
  27792. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27793. /**
  27794. * Returns an array of sampler variable names
  27795. * @returns The array of sampler variable neames.
  27796. */
  27797. getSamplers(): string[];
  27798. /**
  27799. * The error from the last compilation.
  27800. * @returns the error string.
  27801. */
  27802. getCompilationError(): string;
  27803. /**
  27804. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27805. * @param func The callback to be used.
  27806. */
  27807. executeWhenCompiled(func: (effect: Effect) => void): void;
  27808. private _checkIsReady;
  27809. /** @hidden */ loadVertexShader(vertex: any, callback: (data: any) => void): void;
  27810. /** @hidden */ loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  27811. /** @hidden */ dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  27812. private _processShaderConversion;
  27813. private _processIncludes;
  27814. private _processPrecision;
  27815. /**
  27816. * Recompiles the webGL program
  27817. * @param vertexSourceCode The source code for the vertex shader.
  27818. * @param fragmentSourceCode The source code for the fragment shader.
  27819. * @param onCompiled Callback called when completed.
  27820. * @param onError Callback called on error.
  27821. * @hidden
  27822. */ rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  27823. /**
  27824. * Gets the uniform locations of the the specified variable names
  27825. * @param names THe names of the variables to lookup.
  27826. * @returns Array of locations in the same order as variable names.
  27827. */
  27828. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  27829. /**
  27830. * Prepares the effect
  27831. * @hidden
  27832. */ prepareEffect(): void;
  27833. /**
  27834. * Checks if the effect is supported. (Must be called after compilation)
  27835. */
  27836. readonly isSupported: boolean;
  27837. /**
  27838. * Binds a texture to the engine to be used as output of the shader.
  27839. * @param channel Name of the output variable.
  27840. * @param texture Texture to bind.
  27841. * @hidden
  27842. */ bindTexture(channel: string, texture: InternalTexture): void;
  27843. /**
  27844. * Sets a texture on the engine to be used in the shader.
  27845. * @param channel Name of the sampler variable.
  27846. * @param texture Texture to set.
  27847. */
  27848. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  27849. /**
  27850. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  27851. * @param channel Name of the sampler variable.
  27852. * @param texture Texture to set.
  27853. */
  27854. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  27855. /**
  27856. * Sets an array of textures on the engine to be used in the shader.
  27857. * @param channel Name of the variable.
  27858. * @param textures Textures to set.
  27859. */
  27860. setTextureArray(channel: string, textures: BaseTexture[]): void;
  27861. /**
  27862. * 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)
  27863. * @param channel Name of the sampler variable.
  27864. * @param postProcess Post process to get the input texture from.
  27865. */
  27866. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  27867. /**
  27868. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  27869. * 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)
  27870. * @param channel Name of the sampler variable.
  27871. * @param postProcess Post process to get the output texture from.
  27872. */
  27873. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  27874. /** @hidden */ cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  27875. /** @hidden */ cacheFloat2(uniformName: string, x: number, y: number): boolean;
  27876. /** @hidden */ cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  27877. /** @hidden */ cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  27878. /**
  27879. * Binds a buffer to a uniform.
  27880. * @param buffer Buffer to bind.
  27881. * @param name Name of the uniform variable to bind to.
  27882. */
  27883. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  27884. /**
  27885. * Binds block to a uniform.
  27886. * @param blockName Name of the block to bind.
  27887. * @param index Index to bind.
  27888. */
  27889. bindUniformBlock(blockName: string, index: number): void;
  27890. /**
  27891. * Sets an interger value on a uniform variable.
  27892. * @param uniformName Name of the variable.
  27893. * @param value Value to be set.
  27894. * @returns this effect.
  27895. */
  27896. setInt(uniformName: string, value: number): Effect;
  27897. /**
  27898. * Sets an int array on a uniform variable.
  27899. * @param uniformName Name of the variable.
  27900. * @param array array to be set.
  27901. * @returns this effect.
  27902. */
  27903. setIntArray(uniformName: string, array: Int32Array): Effect;
  27904. /**
  27905. * 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)
  27906. * @param uniformName Name of the variable.
  27907. * @param array array to be set.
  27908. * @returns this effect.
  27909. */
  27910. setIntArray2(uniformName: string, array: Int32Array): Effect;
  27911. /**
  27912. * 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)
  27913. * @param uniformName Name of the variable.
  27914. * @param array array to be set.
  27915. * @returns this effect.
  27916. */
  27917. setIntArray3(uniformName: string, array: Int32Array): Effect;
  27918. /**
  27919. * 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)
  27920. * @param uniformName Name of the variable.
  27921. * @param array array to be set.
  27922. * @returns this effect.
  27923. */
  27924. setIntArray4(uniformName: string, array: Int32Array): Effect;
  27925. /**
  27926. * Sets an float array on a uniform variable.
  27927. * @param uniformName Name of the variable.
  27928. * @param array array to be set.
  27929. * @returns this effect.
  27930. */
  27931. setFloatArray(uniformName: string, array: Float32Array): Effect;
  27932. /**
  27933. * 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)
  27934. * @param uniformName Name of the variable.
  27935. * @param array array to be set.
  27936. * @returns this effect.
  27937. */
  27938. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  27939. /**
  27940. * 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)
  27941. * @param uniformName Name of the variable.
  27942. * @param array array to be set.
  27943. * @returns this effect.
  27944. */
  27945. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  27946. /**
  27947. * 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)
  27948. * @param uniformName Name of the variable.
  27949. * @param array array to be set.
  27950. * @returns this effect.
  27951. */
  27952. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  27953. /**
  27954. * Sets an array on a uniform variable.
  27955. * @param uniformName Name of the variable.
  27956. * @param array array to be set.
  27957. * @returns this effect.
  27958. */
  27959. setArray(uniformName: string, array: number[]): Effect;
  27960. /**
  27961. * 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)
  27962. * @param uniformName Name of the variable.
  27963. * @param array array to be set.
  27964. * @returns this effect.
  27965. */
  27966. setArray2(uniformName: string, array: number[]): Effect;
  27967. /**
  27968. * 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)
  27969. * @param uniformName Name of the variable.
  27970. * @param array array to be set.
  27971. * @returns this effect.
  27972. */
  27973. setArray3(uniformName: string, array: number[]): Effect;
  27974. /**
  27975. * 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)
  27976. * @param uniformName Name of the variable.
  27977. * @param array array to be set.
  27978. * @returns this effect.
  27979. */
  27980. setArray4(uniformName: string, array: number[]): Effect;
  27981. /**
  27982. * Sets matrices on a uniform variable.
  27983. * @param uniformName Name of the variable.
  27984. * @param matrices matrices to be set.
  27985. * @returns this effect.
  27986. */
  27987. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  27988. /**
  27989. * Sets matrix on a uniform variable.
  27990. * @param uniformName Name of the variable.
  27991. * @param matrix matrix to be set.
  27992. * @returns this effect.
  27993. */
  27994. setMatrix(uniformName: string, matrix: Matrix): Effect;
  27995. /**
  27996. * 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)
  27997. * @param uniformName Name of the variable.
  27998. * @param matrix matrix to be set.
  27999. * @returns this effect.
  28000. */
  28001. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28002. /**
  28003. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28004. * @param uniformName Name of the variable.
  28005. * @param matrix matrix to be set.
  28006. * @returns this effect.
  28007. */
  28008. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28009. /**
  28010. * Sets a float on a uniform variable.
  28011. * @param uniformName Name of the variable.
  28012. * @param value value to be set.
  28013. * @returns this effect.
  28014. */
  28015. setFloat(uniformName: string, value: number): Effect;
  28016. /**
  28017. * Sets a boolean on a uniform variable.
  28018. * @param uniformName Name of the variable.
  28019. * @param bool value to be set.
  28020. * @returns this effect.
  28021. */
  28022. setBool(uniformName: string, bool: boolean): Effect;
  28023. /**
  28024. * Sets a Vector2 on a uniform variable.
  28025. * @param uniformName Name of the variable.
  28026. * @param vector2 vector2 to be set.
  28027. * @returns this effect.
  28028. */
  28029. setVector2(uniformName: string, vector2: Vector2): Effect;
  28030. /**
  28031. * Sets a float2 on a uniform variable.
  28032. * @param uniformName Name of the variable.
  28033. * @param x First float in float2.
  28034. * @param y Second float in float2.
  28035. * @returns this effect.
  28036. */
  28037. setFloat2(uniformName: string, x: number, y: number): Effect;
  28038. /**
  28039. * Sets a Vector3 on a uniform variable.
  28040. * @param uniformName Name of the variable.
  28041. * @param vector3 Value to be set.
  28042. * @returns this effect.
  28043. */
  28044. setVector3(uniformName: string, vector3: Vector3): Effect;
  28045. /**
  28046. * Sets a float3 on a uniform variable.
  28047. * @param uniformName Name of the variable.
  28048. * @param x First float in float3.
  28049. * @param y Second float in float3.
  28050. * @param z Third float in float3.
  28051. * @returns this effect.
  28052. */
  28053. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28054. /**
  28055. * Sets a Vector4 on a uniform variable.
  28056. * @param uniformName Name of the variable.
  28057. * @param vector4 Value to be set.
  28058. * @returns this effect.
  28059. */
  28060. setVector4(uniformName: string, vector4: Vector4): Effect;
  28061. /**
  28062. * Sets a float4 on a uniform variable.
  28063. * @param uniformName Name of the variable.
  28064. * @param x First float in float4.
  28065. * @param y Second float in float4.
  28066. * @param z Third float in float4.
  28067. * @param w Fourth float in float4.
  28068. * @returns this effect.
  28069. */
  28070. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28071. /**
  28072. * Sets a Color3 on a uniform variable.
  28073. * @param uniformName Name of the variable.
  28074. * @param color3 Value to be set.
  28075. * @returns this effect.
  28076. */
  28077. setColor3(uniformName: string, color3: Color3): Effect;
  28078. /**
  28079. * Sets a Color4 on a uniform variable.
  28080. * @param uniformName Name of the variable.
  28081. * @param color3 Value to be set.
  28082. * @param alpha Alpha value to be set.
  28083. * @returns this effect.
  28084. */
  28085. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28086. /**
  28087. * Sets a Color4 on a uniform variable
  28088. * @param uniformName defines the name of the variable
  28089. * @param color4 defines the value to be set
  28090. * @returns this effect.
  28091. */
  28092. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28093. /**
  28094. * This function will add a new shader to the shader store
  28095. * @param name the name of the shader
  28096. * @param pixelShader optional pixel shader content
  28097. * @param vertexShader optional vertex shader content
  28098. */
  28099. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28100. /**
  28101. * Store of each shader (The can be looked up using effect.key)
  28102. */
  28103. static ShadersStore: {
  28104. [key: string]: string;
  28105. };
  28106. /**
  28107. * Store of each included file for a shader (The can be looked up using effect.key)
  28108. */
  28109. static IncludesShadersStore: {
  28110. [key: string]: string;
  28111. };
  28112. /**
  28113. * Resets the cache of effects.
  28114. */
  28115. static ResetCache(): void;
  28116. }
  28117. }
  28118. declare module BABYLON {
  28119. /**
  28120. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28121. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28122. * 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;
  28123. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28124. */
  28125. export class ColorCurves {
  28126. private _dirty;
  28127. private _tempColor;
  28128. private _globalCurve;
  28129. private _highlightsCurve;
  28130. private _midtonesCurve;
  28131. private _shadowsCurve;
  28132. private _positiveCurve;
  28133. private _negativeCurve;
  28134. private _globalHue;
  28135. private _globalDensity;
  28136. private _globalSaturation;
  28137. private _globalExposure;
  28138. /**
  28139. * Gets the global Hue value.
  28140. * 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).
  28141. */
  28142. /**
  28143. * Sets the global Hue value.
  28144. * 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).
  28145. */
  28146. globalHue: number;
  28147. /**
  28148. * Gets the global Density value.
  28149. * 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.
  28150. * Values less than zero provide a filter of opposite hue.
  28151. */
  28152. /**
  28153. * Sets the global Density value.
  28154. * 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.
  28155. * Values less than zero provide a filter of opposite hue.
  28156. */
  28157. globalDensity: number;
  28158. /**
  28159. * Gets the global Saturation value.
  28160. * 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.
  28161. */
  28162. /**
  28163. * Sets the global Saturation value.
  28164. * 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.
  28165. */
  28166. globalSaturation: number;
  28167. /**
  28168. * Gets the global Exposure value.
  28169. * 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.
  28170. */
  28171. /**
  28172. * Sets the global Exposure value.
  28173. * 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.
  28174. */
  28175. globalExposure: number;
  28176. private _highlightsHue;
  28177. private _highlightsDensity;
  28178. private _highlightsSaturation;
  28179. private _highlightsExposure;
  28180. /**
  28181. * Gets the highlights Hue value.
  28182. * 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).
  28183. */
  28184. /**
  28185. * Sets the highlights Hue value.
  28186. * 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).
  28187. */
  28188. highlightsHue: number;
  28189. /**
  28190. * Gets the highlights Density value.
  28191. * 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.
  28192. * Values less than zero provide a filter of opposite hue.
  28193. */
  28194. /**
  28195. * Sets the highlights Density value.
  28196. * 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.
  28197. * Values less than zero provide a filter of opposite hue.
  28198. */
  28199. highlightsDensity: number;
  28200. /**
  28201. * Gets the highlights Saturation value.
  28202. * 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.
  28203. */
  28204. /**
  28205. * Sets the highlights Saturation value.
  28206. * 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.
  28207. */
  28208. highlightsSaturation: number;
  28209. /**
  28210. * Gets the highlights Exposure value.
  28211. * 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.
  28212. */
  28213. /**
  28214. * Sets the highlights Exposure value.
  28215. * 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.
  28216. */
  28217. highlightsExposure: number;
  28218. private _midtonesHue;
  28219. private _midtonesDensity;
  28220. private _midtonesSaturation;
  28221. private _midtonesExposure;
  28222. /**
  28223. * Gets the midtones Hue value.
  28224. * 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).
  28225. */
  28226. /**
  28227. * Sets the midtones Hue value.
  28228. * 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).
  28229. */
  28230. midtonesHue: number;
  28231. /**
  28232. * Gets the midtones Density value.
  28233. * 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.
  28234. * Values less than zero provide a filter of opposite hue.
  28235. */
  28236. /**
  28237. * Sets the midtones Density value.
  28238. * 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.
  28239. * Values less than zero provide a filter of opposite hue.
  28240. */
  28241. midtonesDensity: number;
  28242. /**
  28243. * Gets the midtones Saturation value.
  28244. * 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.
  28245. */
  28246. /**
  28247. * Sets the midtones Saturation value.
  28248. * 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.
  28249. */
  28250. midtonesSaturation: number;
  28251. /**
  28252. * Gets the midtones Exposure value.
  28253. * 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.
  28254. */
  28255. /**
  28256. * Sets the midtones Exposure value.
  28257. * 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.
  28258. */
  28259. midtonesExposure: number;
  28260. private _shadowsHue;
  28261. private _shadowsDensity;
  28262. private _shadowsSaturation;
  28263. private _shadowsExposure;
  28264. /**
  28265. * Gets the shadows Hue value.
  28266. * 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).
  28267. */
  28268. /**
  28269. * Sets the shadows Hue value.
  28270. * 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).
  28271. */
  28272. shadowsHue: number;
  28273. /**
  28274. * Gets the shadows Density value.
  28275. * 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.
  28276. * Values less than zero provide a filter of opposite hue.
  28277. */
  28278. /**
  28279. * Sets the shadows Density value.
  28280. * 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.
  28281. * Values less than zero provide a filter of opposite hue.
  28282. */
  28283. shadowsDensity: number;
  28284. /**
  28285. * Gets the shadows Saturation value.
  28286. * 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.
  28287. */
  28288. /**
  28289. * Sets the shadows Saturation value.
  28290. * 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.
  28291. */
  28292. shadowsSaturation: number;
  28293. /**
  28294. * Gets the shadows Exposure value.
  28295. * 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.
  28296. */
  28297. /**
  28298. * Sets the shadows Exposure value.
  28299. * 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.
  28300. */
  28301. shadowsExposure: number;
  28302. /**
  28303. * Returns the class name
  28304. * @returns The class name
  28305. */
  28306. getClassName(): string;
  28307. /**
  28308. * Binds the color curves to the shader.
  28309. * @param colorCurves The color curve to bind
  28310. * @param effect The effect to bind to
  28311. * @param positiveUniform The positive uniform shader parameter
  28312. * @param neutralUniform The neutral uniform shader parameter
  28313. * @param negativeUniform The negative uniform shader parameter
  28314. */
  28315. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  28316. /**
  28317. * Prepare the list of uniforms associated with the ColorCurves effects.
  28318. * @param uniformsList The list of uniforms used in the effect
  28319. */
  28320. static PrepareUniforms(uniformsList: string[]): void;
  28321. /**
  28322. * Returns color grading data based on a hue, density, saturation and exposure value.
  28323. * @param filterHue The hue of the color filter.
  28324. * @param filterDensity The density of the color filter.
  28325. * @param saturation The saturation.
  28326. * @param exposure The exposure.
  28327. * @param result The result data container.
  28328. */
  28329. private getColorGradingDataToRef;
  28330. /**
  28331. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  28332. * @param value The input slider value in range [-100,100].
  28333. * @returns Adjusted value.
  28334. */
  28335. private static applyColorGradingSliderNonlinear;
  28336. /**
  28337. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  28338. * @param hue The hue (H) input.
  28339. * @param saturation The saturation (S) input.
  28340. * @param brightness The brightness (B) input.
  28341. * @result An RGBA color represented as Vector4.
  28342. */
  28343. private static fromHSBToRef;
  28344. /**
  28345. * Returns a value clamped between min and max
  28346. * @param value The value to clamp
  28347. * @param min The minimum of value
  28348. * @param max The maximum of value
  28349. * @returns The clamped value.
  28350. */
  28351. private static clamp;
  28352. /**
  28353. * Clones the current color curve instance.
  28354. * @return The cloned curves
  28355. */
  28356. clone(): ColorCurves;
  28357. /**
  28358. * Serializes the current color curve instance to a json representation.
  28359. * @return a JSON representation
  28360. */
  28361. serialize(): any;
  28362. /**
  28363. * Parses the color curve from a json representation.
  28364. * @param source the JSON source to parse
  28365. * @return The parsed curves
  28366. */
  28367. static Parse(source: any): ColorCurves;
  28368. }
  28369. }
  28370. declare module BABYLON {
  28371. /**
  28372. * Interface to follow in your material defines to integrate easily the
  28373. * Image proccessing functions.
  28374. * @hidden
  28375. */
  28376. export interface IImageProcessingConfigurationDefines {
  28377. IMAGEPROCESSING: boolean;
  28378. VIGNETTE: boolean;
  28379. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28380. VIGNETTEBLENDMODEOPAQUE: boolean;
  28381. TONEMAPPING: boolean;
  28382. TONEMAPPING_ACES: boolean;
  28383. CONTRAST: boolean;
  28384. EXPOSURE: boolean;
  28385. COLORCURVES: boolean;
  28386. COLORGRADING: boolean;
  28387. COLORGRADING3D: boolean;
  28388. SAMPLER3DGREENDEPTH: boolean;
  28389. SAMPLER3DBGRMAP: boolean;
  28390. IMAGEPROCESSINGPOSTPROCESS: boolean;
  28391. }
  28392. /**
  28393. * @hidden
  28394. */
  28395. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  28396. IMAGEPROCESSING: boolean;
  28397. VIGNETTE: boolean;
  28398. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28399. VIGNETTEBLENDMODEOPAQUE: boolean;
  28400. TONEMAPPING: boolean;
  28401. TONEMAPPING_ACES: boolean;
  28402. CONTRAST: boolean;
  28403. COLORCURVES: boolean;
  28404. COLORGRADING: boolean;
  28405. COLORGRADING3D: boolean;
  28406. SAMPLER3DGREENDEPTH: boolean;
  28407. SAMPLER3DBGRMAP: boolean;
  28408. IMAGEPROCESSINGPOSTPROCESS: boolean;
  28409. EXPOSURE: boolean;
  28410. constructor();
  28411. }
  28412. /**
  28413. * This groups together the common properties used for image processing either in direct forward pass
  28414. * or through post processing effect depending on the use of the image processing pipeline in your scene
  28415. * or not.
  28416. */
  28417. export class ImageProcessingConfiguration {
  28418. /**
  28419. * Default tone mapping applied in BabylonJS.
  28420. */
  28421. static readonly TONEMAPPING_STANDARD: number;
  28422. /**
  28423. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  28424. * to other engines rendering to increase portability.
  28425. */
  28426. static readonly TONEMAPPING_ACES: number;
  28427. /**
  28428. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  28429. */
  28430. colorCurves: Nullable<ColorCurves>;
  28431. private _colorCurvesEnabled;
  28432. /**
  28433. * Gets wether the color curves effect is enabled.
  28434. */
  28435. /**
  28436. * Sets wether the color curves effect is enabled.
  28437. */
  28438. colorCurvesEnabled: boolean;
  28439. private _colorGradingTexture;
  28440. /**
  28441. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  28442. */
  28443. /**
  28444. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  28445. */
  28446. colorGradingTexture: Nullable<BaseTexture>;
  28447. private _colorGradingEnabled;
  28448. /**
  28449. * Gets wether the color grading effect is enabled.
  28450. */
  28451. /**
  28452. * Sets wether the color grading effect is enabled.
  28453. */
  28454. colorGradingEnabled: boolean;
  28455. private _colorGradingWithGreenDepth;
  28456. /**
  28457. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  28458. */
  28459. /**
  28460. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  28461. */
  28462. colorGradingWithGreenDepth: boolean;
  28463. private _colorGradingBGR;
  28464. /**
  28465. * Gets wether the color grading texture contains BGR values.
  28466. */
  28467. /**
  28468. * Sets wether the color grading texture contains BGR values.
  28469. */
  28470. colorGradingBGR: boolean;
  28471. /** @hidden */ exposure: number;
  28472. /**
  28473. * Gets the Exposure used in the effect.
  28474. */
  28475. /**
  28476. * Sets the Exposure used in the effect.
  28477. */
  28478. exposure: number;
  28479. private _toneMappingEnabled;
  28480. /**
  28481. * Gets wether the tone mapping effect is enabled.
  28482. */
  28483. /**
  28484. * Sets wether the tone mapping effect is enabled.
  28485. */
  28486. toneMappingEnabled: boolean;
  28487. private _toneMappingType;
  28488. /**
  28489. * Gets the type of tone mapping effect.
  28490. */
  28491. /**
  28492. * Sets the type of tone mapping effect used in BabylonJS.
  28493. */
  28494. toneMappingType: number;
  28495. protected _contrast: number;
  28496. /**
  28497. * Gets the contrast used in the effect.
  28498. */
  28499. /**
  28500. * Sets the contrast used in the effect.
  28501. */
  28502. contrast: number;
  28503. /**
  28504. * Vignette stretch size.
  28505. */
  28506. vignetteStretch: number;
  28507. /**
  28508. * Vignette centre X Offset.
  28509. */
  28510. vignetteCentreX: number;
  28511. /**
  28512. * Vignette centre Y Offset.
  28513. */
  28514. vignetteCentreY: number;
  28515. /**
  28516. * Vignette weight or intensity of the vignette effect.
  28517. */
  28518. vignetteWeight: number;
  28519. /**
  28520. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28521. * if vignetteEnabled is set to true.
  28522. */
  28523. vignetteColor: Color4;
  28524. /**
  28525. * Camera field of view used by the Vignette effect.
  28526. */
  28527. vignetteCameraFov: number;
  28528. private _vignetteBlendMode;
  28529. /**
  28530. * Gets the vignette blend mode allowing different kind of effect.
  28531. */
  28532. /**
  28533. * Sets the vignette blend mode allowing different kind of effect.
  28534. */
  28535. vignetteBlendMode: number;
  28536. private _vignetteEnabled;
  28537. /**
  28538. * Gets wether the vignette effect is enabled.
  28539. */
  28540. /**
  28541. * Sets wether the vignette effect is enabled.
  28542. */
  28543. vignetteEnabled: boolean;
  28544. private _applyByPostProcess;
  28545. /**
  28546. * Gets wether the image processing is applied through a post process or not.
  28547. */
  28548. /**
  28549. * Sets wether the image processing is applied through a post process or not.
  28550. */
  28551. applyByPostProcess: boolean;
  28552. private _isEnabled;
  28553. /**
  28554. * Gets wether the image processing is enabled or not.
  28555. */
  28556. /**
  28557. * Sets wether the image processing is enabled or not.
  28558. */
  28559. isEnabled: boolean;
  28560. /**
  28561. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  28562. */
  28563. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  28564. /**
  28565. * Method called each time the image processing information changes requires to recompile the effect.
  28566. */
  28567. protected _updateParameters(): void;
  28568. /**
  28569. * Gets the current class name.
  28570. * @return "ImageProcessingConfiguration"
  28571. */
  28572. getClassName(): string;
  28573. /**
  28574. * Prepare the list of uniforms associated with the Image Processing effects.
  28575. * @param uniforms The list of uniforms used in the effect
  28576. * @param defines the list of defines currently in use
  28577. */
  28578. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  28579. /**
  28580. * Prepare the list of samplers associated with the Image Processing effects.
  28581. * @param samplersList The list of uniforms used in the effect
  28582. * @param defines the list of defines currently in use
  28583. */
  28584. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  28585. /**
  28586. * Prepare the list of defines associated to the shader.
  28587. * @param defines the list of defines to complete
  28588. * @param forPostProcess Define if we are currently in post process mode or not
  28589. */
  28590. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  28591. /**
  28592. * Returns true if all the image processing information are ready.
  28593. * @returns True if ready, otherwise, false
  28594. */
  28595. isReady(): boolean;
  28596. /**
  28597. * Binds the image processing to the shader.
  28598. * @param effect The effect to bind to
  28599. * @param aspectRatio Define the current aspect ratio of the effect
  28600. */
  28601. bind(effect: Effect, aspectRatio?: number): void;
  28602. /**
  28603. * Clones the current image processing instance.
  28604. * @return The cloned image processing
  28605. */
  28606. clone(): ImageProcessingConfiguration;
  28607. /**
  28608. * Serializes the current image processing instance to a json representation.
  28609. * @return a JSON representation
  28610. */
  28611. serialize(): any;
  28612. /**
  28613. * Parses the image processing from a json representation.
  28614. * @param source the JSON source to parse
  28615. * @return The parsed image processing
  28616. */
  28617. static Parse(source: any): ImageProcessingConfiguration;
  28618. private static _VIGNETTEMODE_MULTIPLY;
  28619. private static _VIGNETTEMODE_OPAQUE;
  28620. /**
  28621. * Used to apply the vignette as a mix with the pixel color.
  28622. */
  28623. static readonly VIGNETTEMODE_MULTIPLY: number;
  28624. /**
  28625. * Used to apply the vignette as a replacement of the pixel color.
  28626. */
  28627. static readonly VIGNETTEMODE_OPAQUE: number;
  28628. }
  28629. }
  28630. declare module BABYLON {
  28631. /**
  28632. * This represents all the required information to add a fresnel effect on a material:
  28633. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28634. */
  28635. export class FresnelParameters {
  28636. private _isEnabled;
  28637. /**
  28638. * Define if the fresnel effect is enable or not.
  28639. */
  28640. isEnabled: boolean;
  28641. /**
  28642. * Define the color used on edges (grazing angle)
  28643. */
  28644. leftColor: Color3;
  28645. /**
  28646. * Define the color used on center
  28647. */
  28648. rightColor: Color3;
  28649. /**
  28650. * Define bias applied to computed fresnel term
  28651. */
  28652. bias: number;
  28653. /**
  28654. * Defined the power exponent applied to fresnel term
  28655. */
  28656. power: number;
  28657. /**
  28658. * Clones the current fresnel and its valuues
  28659. * @returns a clone fresnel configuration
  28660. */
  28661. clone(): FresnelParameters;
  28662. /**
  28663. * Serializes the current fresnel parameters to a JSON representation.
  28664. * @return the JSON serialization
  28665. */
  28666. serialize(): any;
  28667. /**
  28668. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28669. * @param parsedFresnelParameters Define the JSON representation
  28670. * @returns the parsed parameters
  28671. */
  28672. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28673. }
  28674. }
  28675. declare module BABYLON {
  28676. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28677. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28678. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28679. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28680. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28681. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28682. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28683. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28684. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28685. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28686. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28687. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28688. /**
  28689. * Decorator used to define property that can be serialized as reference to a camera
  28690. * @param sourceName defines the name of the property to decorate
  28691. */
  28692. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28693. /**
  28694. * Class used to help serialization objects
  28695. */
  28696. export class SerializationHelper {
  28697. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  28698. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  28699. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  28700. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  28701. /**
  28702. * Appends the serialized animations from the source animations
  28703. * @param source Source containing the animations
  28704. * @param destination Target to store the animations
  28705. */
  28706. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28707. /**
  28708. * Static function used to serialized a specific entity
  28709. * @param entity defines the entity to serialize
  28710. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28711. * @returns a JSON compatible object representing the serialization of the entity
  28712. */
  28713. static Serialize<T>(entity: T, serializationObject?: any): any;
  28714. /**
  28715. * Creates a new entity from a serialization data object
  28716. * @param creationFunction defines a function used to instanciated the new entity
  28717. * @param source defines the source serialization data
  28718. * @param scene defines the hosting scene
  28719. * @param rootUrl defines the root url for resources
  28720. * @returns a new entity
  28721. */
  28722. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28723. /**
  28724. * Clones an object
  28725. * @param creationFunction defines the function used to instanciate the new object
  28726. * @param source defines the source object
  28727. * @returns the cloned object
  28728. */
  28729. static Clone<T>(creationFunction: () => T, source: T): T;
  28730. /**
  28731. * Instanciates a new object based on a source one (some data will be shared between both object)
  28732. * @param creationFunction defines the function used to instanciate the new object
  28733. * @param source defines the source object
  28734. * @returns the new object
  28735. */
  28736. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28737. }
  28738. }
  28739. declare module BABYLON {
  28740. /**
  28741. * This is the base class of all the camera used in the application.
  28742. * @see http://doc.babylonjs.com/features/cameras
  28743. */
  28744. export class Camera extends Node {
  28745. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28746. /**
  28747. * This is the default projection mode used by the cameras.
  28748. * It helps recreating a feeling of perspective and better appreciate depth.
  28749. * This is the best way to simulate real life cameras.
  28750. */
  28751. static readonly PERSPECTIVE_CAMERA: number;
  28752. /**
  28753. * This helps creating camera with an orthographic mode.
  28754. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  28755. */
  28756. static readonly ORTHOGRAPHIC_CAMERA: number;
  28757. /**
  28758. * This is the default FOV mode for perspective cameras.
  28759. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28760. */
  28761. static readonly FOVMODE_VERTICAL_FIXED: number;
  28762. /**
  28763. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28764. */
  28765. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28766. /**
  28767. * This specifies ther is no need for a camera rig.
  28768. * Basically only one eye is rendered corresponding to the camera.
  28769. */
  28770. static readonly RIG_MODE_NONE: number;
  28771. /**
  28772. * Simulates a camera Rig with one blue eye and one red eye.
  28773. * This can be use with 3d blue and red glasses.
  28774. */
  28775. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28776. /**
  28777. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28778. */
  28779. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28780. /**
  28781. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28782. */
  28783. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28784. /**
  28785. * Defines that both eyes of the camera will be rendered over under each other.
  28786. */
  28787. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28788. /**
  28789. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28790. */
  28791. static readonly RIG_MODE_VR: number;
  28792. /**
  28793. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28794. */
  28795. static readonly RIG_MODE_WEBVR: number;
  28796. /**
  28797. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28798. */
  28799. static readonly RIG_MODE_CUSTOM: number;
  28800. /**
  28801. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28802. */
  28803. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28804. /**
  28805. * @hidden
  28806. * Might be removed once multiview will be a thing
  28807. */
  28808. static UseAlternateWebVRRendering: boolean;
  28809. /**
  28810. * Define the input manager associated with the camera.
  28811. */
  28812. inputs: CameraInputsManager<Camera>;
  28813. /**
  28814. * Define the current local position of the camera in the scene
  28815. */
  28816. position: Vector3;
  28817. /**
  28818. * The vector the camera should consider as up.
  28819. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28820. */
  28821. upVector: Vector3;
  28822. /**
  28823. * Define the current limit on the left side for an orthographic camera
  28824. * In scene unit
  28825. */
  28826. orthoLeft: Nullable<number>;
  28827. /**
  28828. * Define the current limit on the right side for an orthographic camera
  28829. * In scene unit
  28830. */
  28831. orthoRight: Nullable<number>;
  28832. /**
  28833. * Define the current limit on the bottom side for an orthographic camera
  28834. * In scene unit
  28835. */
  28836. orthoBottom: Nullable<number>;
  28837. /**
  28838. * Define the current limit on the top side for an orthographic camera
  28839. * In scene unit
  28840. */
  28841. orthoTop: Nullable<number>;
  28842. /**
  28843. * Field Of View is set in Radians. (default is 0.8)
  28844. */
  28845. fov: number;
  28846. /**
  28847. * Define the minimum distance the camera can see from.
  28848. * This is important to note that the depth buffer are not infinite and the closer it starts
  28849. * the more your scene might encounter depth fighting issue.
  28850. */
  28851. minZ: number;
  28852. /**
  28853. * Define the maximum distance the camera can see to.
  28854. * This is important to note that the depth buffer are not infinite and the further it end
  28855. * the more your scene might encounter depth fighting issue.
  28856. */
  28857. maxZ: number;
  28858. /**
  28859. * Define the default inertia of the camera.
  28860. * This helps giving a smooth feeling to the camera movement.
  28861. */
  28862. inertia: number;
  28863. /**
  28864. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  28865. */
  28866. mode: number;
  28867. /**
  28868. * Define wether the camera is intermediate.
  28869. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28870. */
  28871. isIntermediate: boolean;
  28872. /**
  28873. * Define the viewport of the camera.
  28874. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28875. */
  28876. viewport: Viewport;
  28877. /**
  28878. * Restricts the camera to viewing objects with the same layerMask.
  28879. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28880. */
  28881. layerMask: number;
  28882. /**
  28883. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28884. */
  28885. fovMode: number;
  28886. /**
  28887. * Rig mode of the camera.
  28888. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28889. * This is normally controlled byt the camera themselves as internal use.
  28890. */
  28891. cameraRigMode: number;
  28892. /**
  28893. * Defines the distance between both "eyes" in case of a RIG
  28894. */
  28895. interaxialDistance: number;
  28896. /**
  28897. * Defines if stereoscopic rendering is done side by side or over under.
  28898. */
  28899. isStereoscopicSideBySide: boolean;
  28900. /**
  28901. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  28902. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28903. * else in the scene.
  28904. */
  28905. customRenderTargets: RenderTargetTexture[];
  28906. /**
  28907. * When set, the camera will render to this render target instead of the default canvas
  28908. */
  28909. outputRenderTarget: Nullable<RenderTargetTexture>;
  28910. /**
  28911. * Observable triggered when the camera view matrix has changed.
  28912. */
  28913. onViewMatrixChangedObservable: Observable<Camera>;
  28914. /**
  28915. * Observable triggered when the camera Projection matrix has changed.
  28916. */
  28917. onProjectionMatrixChangedObservable: Observable<Camera>;
  28918. /**
  28919. * Observable triggered when the inputs have been processed.
  28920. */
  28921. onAfterCheckInputsObservable: Observable<Camera>;
  28922. /**
  28923. * Observable triggered when reset has been called and applied to the camera.
  28924. */
  28925. onRestoreStateObservable: Observable<Camera>;
  28926. /** @hidden */ cameraRigParams: any;
  28927. /** @hidden */ rigCameras: Camera[];
  28928. /** @hidden */ rigPostProcess: Nullable<PostProcess>;
  28929. protected _webvrViewMatrix: Matrix;
  28930. /** @hidden */ skipRendering: boolean;
  28931. /** @hidden */ alternateCamera: Camera;
  28932. /** @hidden */ projectionMatrix: Matrix;
  28933. /** @hidden */ postProcesses: Nullable<PostProcess>[];
  28934. /** @hidden */ activeMeshes: SmartArray<AbstractMesh>;
  28935. protected _globalPosition: Vector3;
  28936. /** hidden */ computedViewMatrix: Matrix;
  28937. private _doNotComputeProjectionMatrix;
  28938. private _transformMatrix;
  28939. private _frustumPlanes;
  28940. private _refreshFrustumPlanes;
  28941. private _storedFov;
  28942. private _stateStored;
  28943. /**
  28944. * Instantiates a new camera object.
  28945. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28946. * @see http://doc.babylonjs.com/features/cameras
  28947. * @param name Defines the name of the camera in the scene
  28948. * @param position Defines the position of the camera
  28949. * @param scene Defines the scene the camera belongs too
  28950. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28951. */
  28952. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28953. /**
  28954. * Store current camera state (fov, position, etc..)
  28955. * @returns the camera
  28956. */
  28957. storeState(): Camera;
  28958. /**
  28959. * Restores the camera state values if it has been stored. You must call storeState() first
  28960. */
  28961. protected _restoreStateValues(): boolean;
  28962. /**
  28963. * Restored camera state. You must call storeState() first.
  28964. * @returns true if restored and false otherwise
  28965. */
  28966. restoreState(): boolean;
  28967. /**
  28968. * Gets the class name of the camera.
  28969. * @returns the class name
  28970. */
  28971. getClassName(): string;
  28972. /** @hidden */ protected readonly _isCamera: boolean;
  28973. /**
  28974. * Gets a string representation of the camera useful for debug purpose.
  28975. * @param fullDetails Defines that a more verboe level of logging is required
  28976. * @returns the string representation
  28977. */
  28978. toString(fullDetails?: boolean): string;
  28979. /**
  28980. * Gets the current world space position of the camera.
  28981. */
  28982. readonly globalPosition: Vector3;
  28983. /**
  28984. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28985. * @returns the active meshe list
  28986. */
  28987. getActiveMeshes(): SmartArray<AbstractMesh>;
  28988. /**
  28989. * Check wether a mesh is part of the current active mesh list of the camera
  28990. * @param mesh Defines the mesh to check
  28991. * @returns true if active, false otherwise
  28992. */
  28993. isActiveMesh(mesh: Mesh): boolean;
  28994. /**
  28995. * Is this camera ready to be used/rendered
  28996. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28997. * @return true if the camera is ready
  28998. */
  28999. isReady(completeCheck?: boolean): boolean;
  29000. /** @hidden */ initCache(): void;
  29001. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  29002. /** @hidden */ isSynchronized(): boolean;
  29003. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  29004. /** @hidden */ isSynchronizedProjectionMatrix(): boolean;
  29005. /**
  29006. * Attach the input controls to a specific dom element to get the input from.
  29007. * @param element Defines the element the controls should be listened from
  29008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29009. */
  29010. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29011. /**
  29012. * Detach the current controls from the specified dom element.
  29013. * @param element Defines the element to stop listening the inputs from
  29014. */
  29015. detachControl(element: HTMLElement): void;
  29016. /**
  29017. * Update the camera state according to the different inputs gathered during the frame.
  29018. */
  29019. update(): void;
  29020. /** @hidden */ checkInputs(): void;
  29021. /** @hidden */
  29022. readonly rigCameras: Camera[];
  29023. /**
  29024. * Gets the post process used by the rig cameras
  29025. */
  29026. readonly rigPostProcess: Nullable<PostProcess>;
  29027. /**
  29028. * Internal, gets the first post proces.
  29029. * @returns the first post process to be run on this camera.
  29030. */ getFirstPostProcess(): Nullable<PostProcess>;
  29031. private _cascadePostProcessesToRigCams;
  29032. /**
  29033. * Attach a post process to the camera.
  29034. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29035. * @param postProcess The post process to attach to the camera
  29036. * @param insertAt The position of the post process in case several of them are in use in the scene
  29037. * @returns the position the post process has been inserted at
  29038. */
  29039. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29040. /**
  29041. * Detach a post process to the camera.
  29042. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29043. * @param postProcess The post process to detach from the camera
  29044. */
  29045. detachPostProcess(postProcess: PostProcess): void;
  29046. /**
  29047. * Gets the current world matrix of the camera
  29048. */
  29049. getWorldMatrix(): Matrix;
  29050. /** @hidden */ getViewMatrix(): Matrix;
  29051. /**
  29052. * Gets the current view matrix of the camera.
  29053. * @param force forces the camera to recompute the matrix without looking at the cached state
  29054. * @returns the view matrix
  29055. */
  29056. getViewMatrix(force?: boolean): Matrix;
  29057. /**
  29058. * Freeze the projection matrix.
  29059. * It will prevent the cache check of the camera projection compute and can speed up perf
  29060. * if no parameter of the camera are meant to change
  29061. * @param projection Defines manually a projection if necessary
  29062. */
  29063. freezeProjectionMatrix(projection?: Matrix): void;
  29064. /**
  29065. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29066. */
  29067. unfreezeProjectionMatrix(): void;
  29068. /**
  29069. * Gets the current projection matrix of the camera.
  29070. * @param force forces the camera to recompute the matrix without looking at the cached state
  29071. * @returns the projection matrix
  29072. */
  29073. getProjectionMatrix(force?: boolean): Matrix;
  29074. /**
  29075. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29076. * @returns a Matrix
  29077. */
  29078. getTransformationMatrix(): Matrix;
  29079. private _updateFrustumPlanes;
  29080. /**
  29081. * Checks if a cullable object (mesh...) is in the camera frustum
  29082. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29083. * @param target The object to check
  29084. * @returns true if the object is in frustum otherwise false
  29085. */
  29086. isInFrustum(target: ICullable): boolean;
  29087. /**
  29088. * Checks if a cullable object (mesh...) is in the camera frustum
  29089. * Unlike isInFrustum this cheks the full bounding box
  29090. * @param target The object to check
  29091. * @returns true if the object is in frustum otherwise false
  29092. */
  29093. isCompletelyInFrustum(target: ICullable): boolean;
  29094. /**
  29095. * Gets a ray in the forward direction from the camera.
  29096. * @param length Defines the length of the ray to create
  29097. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29098. * @param origin Defines the start point of the ray which defaults to the camera position
  29099. * @returns the forward ray
  29100. */
  29101. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29102. /**
  29103. * Releases resources associated with this node.
  29104. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29105. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29106. */
  29107. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29108. /**
  29109. * Gets the left camera of a rig setup in case of Rigged Camera
  29110. */
  29111. readonly leftCamera: Nullable<FreeCamera>;
  29112. /**
  29113. * Gets the right camera of a rig setup in case of Rigged Camera
  29114. */
  29115. readonly rightCamera: Nullable<FreeCamera>;
  29116. /**
  29117. * Gets the left camera target of a rig setup in case of Rigged Camera
  29118. * @returns the target position
  29119. */
  29120. getLeftTarget(): Nullable<Vector3>;
  29121. /**
  29122. * Gets the right camera target of a rig setup in case of Rigged Camera
  29123. * @returns the target position
  29124. */
  29125. getRightTarget(): Nullable<Vector3>;
  29126. /**
  29127. * @hidden
  29128. */
  29129. setCameraRigMode(mode: number, rigParams: any): void;
  29130. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  29131. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29132. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  29133. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29134. /** @hidden */ getVRProjectionMatrix(): Matrix;
  29135. protected _updateCameraRotationMatrix(): void;
  29136. protected _updateWebVRCameraRotationMatrix(): void;
  29137. /**
  29138. * This function MUST be overwritten by the different WebVR cameras available.
  29139. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29140. * @hidden
  29141. */ getWebVRProjectionMatrix(): Matrix;
  29142. /**
  29143. * This function MUST be overwritten by the different WebVR cameras available.
  29144. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29145. * @hidden
  29146. */ getWebVRViewMatrix(): Matrix;
  29147. /** @hidden */
  29148. setCameraRigParameter(name: string, value: any): void;
  29149. /**
  29150. * needs to be overridden by children so sub has required properties to be copied
  29151. * @hidden
  29152. */
  29153. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29154. /**
  29155. * May need to be overridden by children
  29156. * @hidden
  29157. */ updateRigCameras(): void;
  29158. /** @hidden */ setupInputs(): void;
  29159. /**
  29160. * Serialiaze the camera setup to a json represention
  29161. * @returns the JSON representation
  29162. */
  29163. serialize(): any;
  29164. /**
  29165. * Clones the current camera.
  29166. * @param name The cloned camera name
  29167. * @returns the cloned camera
  29168. */
  29169. clone(name: string): Camera;
  29170. /**
  29171. * Gets the direction of the camera relative to a given local axis.
  29172. * @param localAxis Defines the reference axis to provide a relative direction.
  29173. * @return the direction
  29174. */
  29175. getDirection(localAxis: Vector3): Vector3;
  29176. /**
  29177. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29178. * @param localAxis Defines the reference axis to provide a relative direction.
  29179. * @param result Defines the vector to store the result in
  29180. */
  29181. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29182. /**
  29183. * Gets a camera constructor for a given camera type
  29184. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29185. * @param name The name of the camera the result will be able to instantiate
  29186. * @param scene The scene the result will construct the camera in
  29187. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29188. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29189. * @returns a factory method to construc the camera
  29190. */
  29191. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29192. /**
  29193. * Compute the world matrix of the camera.
  29194. * @returns the camera workd matrix
  29195. */
  29196. computeWorldMatrix(): Matrix;
  29197. /**
  29198. * Parse a JSON and creates the camera from the parsed information
  29199. * @param parsedCamera The JSON to parse
  29200. * @param scene The scene to instantiate the camera in
  29201. * @returns the newly constructed camera
  29202. */
  29203. static Parse(parsedCamera: any, scene: Scene): Camera;
  29204. }
  29205. }
  29206. declare module BABYLON {
  29207. /**
  29208. * Interface for any object that can request an animation frame
  29209. */
  29210. export interface ICustomAnimationFrameRequester {
  29211. /**
  29212. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29213. */
  29214. renderFunction?: Function;
  29215. /**
  29216. * Called to request the next frame to render to
  29217. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29218. */
  29219. requestAnimationFrame: Function;
  29220. /**
  29221. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29222. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29223. */
  29224. requestID?: number;
  29225. }
  29226. /**
  29227. * Interface containing an array of animations
  29228. */
  29229. export interface IAnimatable {
  29230. /**
  29231. * Array of animations
  29232. */
  29233. animations: Array<Animation>;
  29234. }
  29235. /** Interface used by value gradients (color, factor, ...) */
  29236. export interface IValueGradient {
  29237. /**
  29238. * Gets or sets the gradient value (between 0 and 1)
  29239. */
  29240. gradient: number;
  29241. }
  29242. /** Class used to store color4 gradient */
  29243. export class ColorGradient implements IValueGradient {
  29244. /**
  29245. * Gets or sets the gradient value (between 0 and 1)
  29246. */
  29247. gradient: number;
  29248. /**
  29249. * Gets or sets first associated color
  29250. */
  29251. color1: Color4;
  29252. /**
  29253. * Gets or sets second associated color
  29254. */
  29255. color2?: Color4;
  29256. /**
  29257. * Will get a color picked randomly between color1 and color2.
  29258. * If color2 is undefined then color1 will be used
  29259. * @param result defines the target Color4 to store the result in
  29260. */
  29261. getColorToRef(result: Color4): void;
  29262. }
  29263. /** Class used to store color 3 gradient */
  29264. export class Color3Gradient implements IValueGradient {
  29265. /**
  29266. * Gets or sets the gradient value (between 0 and 1)
  29267. */
  29268. gradient: number;
  29269. /**
  29270. * Gets or sets the associated color
  29271. */
  29272. color: Color3;
  29273. }
  29274. /** Class used to store factor gradient */
  29275. export class FactorGradient implements IValueGradient {
  29276. /**
  29277. * Gets or sets the gradient value (between 0 and 1)
  29278. */
  29279. gradient: number;
  29280. /**
  29281. * Gets or sets first associated factor
  29282. */
  29283. factor1: number;
  29284. /**
  29285. * Gets or sets second associated factor
  29286. */
  29287. factor2?: number;
  29288. /**
  29289. * Will get a number picked randomly between factor1 and factor2.
  29290. * If factor2 is undefined then factor1 will be used
  29291. * @returns the picked number
  29292. */
  29293. getFactor(): number;
  29294. }
  29295. /**
  29296. * @ignore
  29297. * Application error to support additional information when loading a file
  29298. */
  29299. export class LoadFileError extends Error {
  29300. /** defines the optional XHR request */
  29301. request?: XMLHttpRequest | undefined;
  29302. private static _setPrototypeOf;
  29303. /**
  29304. * Creates a new LoadFileError
  29305. * @param message defines the message of the error
  29306. * @param request defines the optional XHR request
  29307. */
  29308. constructor(message: string,
  29309. /** defines the optional XHR request */
  29310. request?: XMLHttpRequest | undefined);
  29311. }
  29312. /**
  29313. * Class used to define a retry strategy when error happens while loading assets
  29314. */
  29315. export class RetryStrategy {
  29316. /**
  29317. * Function used to defines an exponential back off strategy
  29318. * @param maxRetries defines the maximum number of retries (3 by default)
  29319. * @param baseInterval defines the interval between retries
  29320. * @returns the strategy function to use
  29321. */
  29322. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29323. }
  29324. /**
  29325. * File request interface
  29326. */
  29327. export interface IFileRequest {
  29328. /**
  29329. * Raised when the request is complete (success or error).
  29330. */
  29331. onCompleteObservable: Observable<IFileRequest>;
  29332. /**
  29333. * Aborts the request for a file.
  29334. */
  29335. abort: () => void;
  29336. }
  29337. /**
  29338. * Class containing a set of static utilities functions
  29339. */
  29340. export class Tools {
  29341. /**
  29342. * Gets or sets the base URL to use to load assets
  29343. */
  29344. static BaseUrl: string;
  29345. /**
  29346. * Enable/Disable Custom HTTP Request Headers globally.
  29347. * default = false
  29348. * @see CustomRequestHeaders
  29349. */
  29350. static UseCustomRequestHeaders: boolean;
  29351. /**
  29352. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  29353. * i.e. when loading files, where the server/service expects an Authorization header.
  29354. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  29355. */
  29356. static CustomRequestHeaders: {
  29357. [key: string]: string;
  29358. };
  29359. /**
  29360. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  29361. */
  29362. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29363. /**
  29364. * Default behaviour for cors in the application.
  29365. * It can be a string if the expected behavior is identical in the entire app.
  29366. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  29367. */
  29368. static CorsBehavior: string | ((url: string | string[]) => string);
  29369. /**
  29370. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  29371. * @ignorenaming
  29372. */
  29373. static UseFallbackTexture: boolean;
  29374. /**
  29375. * Use this object to register external classes like custom textures or material
  29376. * to allow the laoders to instantiate them
  29377. */
  29378. static RegisteredExternalClasses: {
  29379. [key: string]: Object;
  29380. };
  29381. /**
  29382. * Texture content used if a texture cannot loaded
  29383. * @ignorenaming
  29384. */
  29385. static fallbackTexture: string;
  29386. /**
  29387. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  29388. * @param u defines the coordinate on X axis
  29389. * @param v defines the coordinate on Y axis
  29390. * @param width defines the width of the source data
  29391. * @param height defines the height of the source data
  29392. * @param pixels defines the source byte array
  29393. * @param color defines the output color
  29394. */
  29395. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  29396. /**
  29397. * Interpolates between a and b via alpha
  29398. * @param a The lower value (returned when alpha = 0)
  29399. * @param b The upper value (returned when alpha = 1)
  29400. * @param alpha The interpolation-factor
  29401. * @return The mixed value
  29402. */
  29403. static Mix(a: number, b: number, alpha: number): number;
  29404. /**
  29405. * Tries to instantiate a new object from a given class name
  29406. * @param className defines the class name to instantiate
  29407. * @returns the new object or null if the system was not able to do the instantiation
  29408. */
  29409. static Instantiate(className: string): any;
  29410. /**
  29411. * Provides a slice function that will work even on IE
  29412. * @param data defines the array to slice
  29413. * @param start defines the start of the data (optional)
  29414. * @param end defines the end of the data (optional)
  29415. * @returns the new sliced array
  29416. */
  29417. static Slice<T>(data: T, start?: number, end?: number): T;
  29418. /**
  29419. * Polyfill for setImmediate
  29420. * @param action defines the action to execute after the current execution block
  29421. */
  29422. static SetImmediate(action: () => void): void;
  29423. /**
  29424. * Function indicating if a number is an exponent of 2
  29425. * @param value defines the value to test
  29426. * @returns true if the value is an exponent of 2
  29427. */
  29428. static IsExponentOfTwo(value: number): boolean;
  29429. private static _tmpFloatArray;
  29430. /**
  29431. * Returns the nearest 32-bit single precision float representation of a Number
  29432. * @param value A Number. If the parameter is of a different type, it will get converted
  29433. * to a number or to NaN if it cannot be converted
  29434. * @returns number
  29435. */
  29436. static FloatRound(value: number): number;
  29437. /**
  29438. * Find the next highest power of two.
  29439. * @param x Number to start search from.
  29440. * @return Next highest power of two.
  29441. */
  29442. static CeilingPOT(x: number): number;
  29443. /**
  29444. * Find the next lowest power of two.
  29445. * @param x Number to start search from.
  29446. * @return Next lowest power of two.
  29447. */
  29448. static FloorPOT(x: number): number;
  29449. /**
  29450. * Find the nearest power of two.
  29451. * @param x Number to start search from.
  29452. * @return Next nearest power of two.
  29453. */
  29454. static NearestPOT(x: number): number;
  29455. /**
  29456. * Get the closest exponent of two
  29457. * @param value defines the value to approximate
  29458. * @param max defines the maximum value to return
  29459. * @param mode defines how to define the closest value
  29460. * @returns closest exponent of two of the given value
  29461. */
  29462. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29463. /**
  29464. * Extracts the filename from a path
  29465. * @param path defines the path to use
  29466. * @returns the filename
  29467. */
  29468. static GetFilename(path: string): string;
  29469. /**
  29470. * Extracts the "folder" part of a path (everything before the filename).
  29471. * @param uri The URI to extract the info from
  29472. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  29473. * @returns The "folder" part of the path
  29474. */
  29475. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  29476. /**
  29477. * Extracts text content from a DOM element hierarchy
  29478. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  29479. */
  29480. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  29481. /**
  29482. * Convert an angle in radians to degrees
  29483. * @param angle defines the angle to convert
  29484. * @returns the angle in degrees
  29485. */
  29486. static ToDegrees(angle: number): number;
  29487. /**
  29488. * Convert an angle in degrees to radians
  29489. * @param angle defines the angle to convert
  29490. * @returns the angle in radians
  29491. */
  29492. static ToRadians(angle: number): number;
  29493. /**
  29494. * Encode a buffer to a base64 string
  29495. * @param buffer defines the buffer to encode
  29496. * @returns the encoded string
  29497. */
  29498. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  29499. /**
  29500. * Extracts minimum and maximum values from a list of indexed positions
  29501. * @param positions defines the positions to use
  29502. * @param indices defines the indices to the positions
  29503. * @param indexStart defines the start index
  29504. * @param indexCount defines the end index
  29505. * @param bias defines bias value to add to the result
  29506. * @return minimum and maximum values
  29507. */
  29508. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  29509. minimum: Vector3;
  29510. maximum: Vector3;
  29511. };
  29512. /**
  29513. * Extracts minimum and maximum values from a list of positions
  29514. * @param positions defines the positions to use
  29515. * @param start defines the start index in the positions array
  29516. * @param count defines the number of positions to handle
  29517. * @param bias defines bias value to add to the result
  29518. * @param stride defines the stride size to use (distance between two positions in the positions array)
  29519. * @return minimum and maximum values
  29520. */
  29521. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  29522. minimum: Vector3;
  29523. maximum: Vector3;
  29524. };
  29525. /**
  29526. * Returns an array if obj is not an array
  29527. * @param obj defines the object to evaluate as an array
  29528. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  29529. * @returns either obj directly if obj is an array or a new array containing obj
  29530. */
  29531. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  29532. /**
  29533. * Gets the pointer prefix to use
  29534. * @returns "pointer" if touch is enabled. Else returns "mouse"
  29535. */
  29536. static GetPointerPrefix(): string;
  29537. /**
  29538. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  29539. * @param func - the function to be called
  29540. * @param requester - the object that will request the next frame. Falls back to window.
  29541. * @returns frame number
  29542. */
  29543. static QueueNewFrame(func: () => void, requester?: any): number;
  29544. /**
  29545. * Ask the browser to promote the current element to fullscreen rendering mode
  29546. * @param element defines the DOM element to promote
  29547. */
  29548. static RequestFullscreen(element: HTMLElement): void;
  29549. /**
  29550. * Asks the browser to exit fullscreen mode
  29551. */
  29552. static ExitFullscreen(): void;
  29553. /**
  29554. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  29555. * @param url define the url we are trying
  29556. * @param element define the dom element where to configure the cors policy
  29557. */
  29558. static SetCorsBehavior(url: string | string[], element: {
  29559. crossOrigin: string | null;
  29560. }): void;
  29561. /**
  29562. * Removes unwanted characters from an url
  29563. * @param url defines the url to clean
  29564. * @returns the cleaned url
  29565. */
  29566. static CleanUrl(url: string): string;
  29567. /**
  29568. * Gets or sets a function used to pre-process url before using them to load assets
  29569. */
  29570. static PreprocessUrl: (url: string) => string;
  29571. /**
  29572. * Loads an image as an HTMLImageElement.
  29573. * @param input url string, ArrayBuffer, or Blob to load
  29574. * @param onLoad callback called when the image successfully loads
  29575. * @param onError callback called when the image fails to load
  29576. * @param offlineProvider offline provider for caching
  29577. * @returns the HTMLImageElement of the loaded image
  29578. */
  29579. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  29580. /**
  29581. * Loads a file
  29582. * @param url url string, ArrayBuffer, or Blob to load
  29583. * @param onSuccess callback called when the file successfully loads
  29584. * @param onProgress callback called while file is loading (if the server supports this mode)
  29585. * @param offlineProvider defines the offline provider for caching
  29586. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  29587. * @param onError callback called when the file fails to load
  29588. * @returns a file request object
  29589. */
  29590. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  29591. /**
  29592. * Load a script (identified by an url). When the url returns, the
  29593. * content of this file is added into a new script element, attached to the DOM (body element)
  29594. * @param scriptUrl defines the url of the script to laod
  29595. * @param onSuccess defines the callback called when the script is loaded
  29596. * @param onError defines the callback to call if an error occurs
  29597. */
  29598. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  29599. /**
  29600. * Loads a file from a blob
  29601. * @param fileToLoad defines the blob to use
  29602. * @param callback defines the callback to call when data is loaded
  29603. * @param progressCallback defines the callback to call during loading process
  29604. * @returns a file request object
  29605. */
  29606. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  29607. /**
  29608. * Loads a file
  29609. * @param fileToLoad defines the file to load
  29610. * @param callback defines the callback to call when data is loaded
  29611. * @param progressCallBack defines the callback to call during loading process
  29612. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  29613. * @returns a file request object
  29614. */
  29615. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  29616. /**
  29617. * Creates a data url from a given string content
  29618. * @param content defines the content to convert
  29619. * @returns the new data url link
  29620. */
  29621. static FileAsURL(content: string): string;
  29622. /**
  29623. * Format the given number to a specific decimal format
  29624. * @param value defines the number to format
  29625. * @param decimals defines the number of decimals to use
  29626. * @returns the formatted string
  29627. */
  29628. static Format(value: number, decimals?: number): string;
  29629. /**
  29630. * Checks if a given vector is inside a specific range
  29631. * @param v defines the vector to test
  29632. * @param min defines the minimum range
  29633. * @param max defines the maximum range
  29634. */
  29635. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  29636. /**
  29637. * Tries to copy an object by duplicating every property
  29638. * @param source defines the source object
  29639. * @param destination defines the target object
  29640. * @param doNotCopyList defines a list of properties to avoid
  29641. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  29642. */
  29643. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  29644. /**
  29645. * Gets a boolean indicating if the given object has no own property
  29646. * @param obj defines the object to test
  29647. * @returns true if object has no own property
  29648. */
  29649. static IsEmpty(obj: any): boolean;
  29650. /**
  29651. * Function used to register events at window level
  29652. * @param events defines the events to register
  29653. */
  29654. static RegisterTopRootEvents(events: {
  29655. name: string;
  29656. handler: Nullable<(e: FocusEvent) => any>;
  29657. }[]): void;
  29658. /**
  29659. * Function used to unregister events from window level
  29660. * @param events defines the events to unregister
  29661. */
  29662. static UnregisterTopRootEvents(events: {
  29663. name: string;
  29664. handler: Nullable<(e: FocusEvent) => any>;
  29665. }[]): void;
  29666. /**
  29667. * Dumps the current bound framebuffer
  29668. * @param width defines the rendering width
  29669. * @param height defines the rendering height
  29670. * @param engine defines the hosting engine
  29671. * @param successCallback defines the callback triggered once the data are available
  29672. * @param mimeType defines the mime type of the result
  29673. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  29674. */
  29675. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29676. /**
  29677. * Converts the canvas data to blob.
  29678. * This acts as a polyfill for browsers not supporting the to blob function.
  29679. * @param canvas Defines the canvas to extract the data from
  29680. * @param successCallback Defines the callback triggered once the data are available
  29681. * @param mimeType Defines the mime type of the result
  29682. */
  29683. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  29684. /**
  29685. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  29686. * @param successCallback defines the callback triggered once the data are available
  29687. * @param mimeType defines the mime type of the result
  29688. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  29689. */
  29690. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29691. /**
  29692. * Downloads a blob in the browser
  29693. * @param blob defines the blob to download
  29694. * @param fileName defines the name of the downloaded file
  29695. */
  29696. static Download(blob: Blob, fileName: string): void;
  29697. /**
  29698. * Captures a screenshot of the current rendering
  29699. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  29700. * @param engine defines the rendering engine
  29701. * @param camera defines the source camera
  29702. * @param size This parameter can be set to a single number or to an object with the
  29703. * following (optional) properties: precision, width, height. If a single number is passed,
  29704. * it will be used for both width and height. If an object is passed, the screenshot size
  29705. * will be derived from the parameters. The precision property is a multiplier allowing
  29706. * rendering at a higher or lower resolution
  29707. * @param successCallback defines the callback receives a single parameter which contains the
  29708. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  29709. * src parameter of an <img> to display it
  29710. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  29711. * Check your browser for supported MIME types
  29712. */
  29713. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  29714. /**
  29715. * Generates an image screenshot from the specified camera.
  29716. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  29717. * @param engine The engine to use for rendering
  29718. * @param camera The camera to use for rendering
  29719. * @param size This parameter can be set to a single number or to an object with the
  29720. * following (optional) properties: precision, width, height. If a single number is passed,
  29721. * it will be used for both width and height. If an object is passed, the screenshot size
  29722. * will be derived from the parameters. The precision property is a multiplier allowing
  29723. * rendering at a higher or lower resolution
  29724. * @param successCallback The callback receives a single parameter which contains the
  29725. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  29726. * src parameter of an <img> to display it
  29727. * @param mimeType The MIME type of the screenshot image (default: image/png).
  29728. * Check your browser for supported MIME types
  29729. * @param samples Texture samples (default: 1)
  29730. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  29731. * @param fileName A name for for the downloaded file.
  29732. */
  29733. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  29734. /**
  29735. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29736. * Be aware Math.random() could cause collisions, but:
  29737. * "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"
  29738. * @returns a pseudo random id
  29739. */
  29740. static RandomId(): string;
  29741. /**
  29742. * Test if the given uri is a base64 string
  29743. * @param uri The uri to test
  29744. * @return True if the uri is a base64 string or false otherwise
  29745. */
  29746. static IsBase64(uri: string): boolean;
  29747. /**
  29748. * Decode the given base64 uri.
  29749. * @param uri The uri to decode
  29750. * @return The decoded base64 data.
  29751. */
  29752. static DecodeBase64(uri: string): ArrayBuffer;
  29753. /**
  29754. * No log
  29755. */
  29756. static readonly NoneLogLevel: number;
  29757. /**
  29758. * Only message logs
  29759. */
  29760. static readonly MessageLogLevel: number;
  29761. /**
  29762. * Only warning logs
  29763. */
  29764. static readonly WarningLogLevel: number;
  29765. /**
  29766. * Only error logs
  29767. */
  29768. static readonly ErrorLogLevel: number;
  29769. /**
  29770. * All logs
  29771. */
  29772. static readonly AllLogLevel: number;
  29773. /**
  29774. * Gets a value indicating the number of loading errors
  29775. * @ignorenaming
  29776. */
  29777. static readonly errorsCount: number;
  29778. /**
  29779. * Callback called when a new log is added
  29780. */
  29781. static OnNewCacheEntry: (entry: string) => void;
  29782. /**
  29783. * Log a message to the console
  29784. * @param message defines the message to log
  29785. */
  29786. static Log(message: string): void;
  29787. /**
  29788. * Write a warning message to the console
  29789. * @param message defines the message to log
  29790. */
  29791. static Warn(message: string): void;
  29792. /**
  29793. * Write an error message to the console
  29794. * @param message defines the message to log
  29795. */
  29796. static Error(message: string): void;
  29797. /**
  29798. * Gets current log cache (list of logs)
  29799. */
  29800. static readonly LogCache: string;
  29801. /**
  29802. * Clears the log cache
  29803. */
  29804. static ClearLogCache(): void;
  29805. /**
  29806. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  29807. */
  29808. static LogLevels: number;
  29809. /**
  29810. * Checks if the loaded document was accessed via `file:`-Protocol.
  29811. * @returns boolean
  29812. */
  29813. static IsFileURL(): boolean;
  29814. /**
  29815. * Checks if the window object exists
  29816. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  29817. */
  29818. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  29819. /**
  29820. * No performance log
  29821. */
  29822. static readonly PerformanceNoneLogLevel: number;
  29823. /**
  29824. * Use user marks to log performance
  29825. */
  29826. static readonly PerformanceUserMarkLogLevel: number;
  29827. /**
  29828. * Log performance to the console
  29829. */
  29830. static readonly PerformanceConsoleLogLevel: number;
  29831. private static _performance;
  29832. /**
  29833. * Sets the current performance log level
  29834. */
  29835. static PerformanceLogLevel: number;
  29836. private static _StartPerformanceCounterDisabled;
  29837. private static _EndPerformanceCounterDisabled;
  29838. private static _StartUserMark;
  29839. private static _EndUserMark;
  29840. private static _StartPerformanceConsole;
  29841. private static _EndPerformanceConsole;
  29842. /**
  29843. * Injects the @see CustomRequestHeaders into the given request
  29844. * @param request the request that should be used for injection
  29845. */
  29846. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  29847. /**
  29848. * Starts a performance counter
  29849. */
  29850. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29851. /**
  29852. * Ends a specific performance coutner
  29853. */
  29854. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29855. /**
  29856. * Gets either window.performance.now() if supported or Date.now() else
  29857. */
  29858. static readonly Now: number;
  29859. /**
  29860. * This method will return the name of the class used to create the instance of the given object.
  29861. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  29862. * @param object the object to get the class name from
  29863. * @param isType defines if the object is actually a type
  29864. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  29865. */
  29866. static GetClassName(object: any, isType?: boolean): string;
  29867. /**
  29868. * Gets the first element of an array satisfying a given predicate
  29869. * @param array defines the array to browse
  29870. * @param predicate defines the predicate to use
  29871. * @returns null if not found or the element
  29872. */
  29873. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  29874. /**
  29875. * This method will return the name of the full name of the class, including its owning module (if any).
  29876. * 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).
  29877. * @param object the object to get the class name from
  29878. * @param isType defines if the object is actually a type
  29879. * @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.
  29880. * @ignorenaming
  29881. */
  29882. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  29883. /**
  29884. * Returns a promise that resolves after the given amount of time.
  29885. * @param delay Number of milliseconds to delay
  29886. * @returns Promise that resolves after the given amount of time
  29887. */
  29888. static DelayAsync(delay: number): Promise<void>;
  29889. /**
  29890. * Gets the current gradient from an array of IValueGradient
  29891. * @param ratio defines the current ratio to get
  29892. * @param gradients defines the array of IValueGradient
  29893. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  29894. */
  29895. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  29896. }
  29897. /**
  29898. * This class is used to track a performance counter which is number based.
  29899. * The user has access to many properties which give statistics of different nature.
  29900. *
  29901. * The implementer can track two kinds of Performance Counter: time and count.
  29902. * 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.
  29903. * 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.
  29904. */
  29905. export class PerfCounter {
  29906. /**
  29907. * Gets or sets a global boolean to turn on and off all the counters
  29908. */
  29909. static Enabled: boolean;
  29910. /**
  29911. * Returns the smallest value ever
  29912. */
  29913. readonly min: number;
  29914. /**
  29915. * Returns the biggest value ever
  29916. */
  29917. readonly max: number;
  29918. /**
  29919. * Returns the average value since the performance counter is running
  29920. */
  29921. readonly average: number;
  29922. /**
  29923. * Returns the average value of the last second the counter was monitored
  29924. */
  29925. readonly lastSecAverage: number;
  29926. /**
  29927. * Returns the current value
  29928. */
  29929. readonly current: number;
  29930. /**
  29931. * Gets the accumulated total
  29932. */
  29933. readonly total: number;
  29934. /**
  29935. * Gets the total value count
  29936. */
  29937. readonly count: number;
  29938. /**
  29939. * Creates a new counter
  29940. */
  29941. constructor();
  29942. /**
  29943. * Call this method to start monitoring a new frame.
  29944. * 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.
  29945. */
  29946. fetchNewFrame(): void;
  29947. /**
  29948. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29949. * @param newCount the count value to add to the monitored count
  29950. * @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.
  29951. */
  29952. addCount(newCount: number, fetchResult: boolean): void;
  29953. /**
  29954. * Start monitoring this performance counter
  29955. */
  29956. beginMonitoring(): void;
  29957. /**
  29958. * Compute the time lapsed since the previous beginMonitoring() call.
  29959. * @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
  29960. */
  29961. endMonitoring(newFrame?: boolean): void;
  29962. private _fetchResult;
  29963. private _startMonitoringTime;
  29964. private _min;
  29965. private _max;
  29966. private _average;
  29967. private _current;
  29968. private _totalValueCount;
  29969. private _totalAccumulated;
  29970. private _lastSecAverage;
  29971. private _lastSecAccumulated;
  29972. private _lastSecTime;
  29973. private _lastSecValueCount;
  29974. }
  29975. /**
  29976. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  29977. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  29978. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  29979. * @param name The name of the class, case should be preserved
  29980. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  29981. */
  29982. export function className(name: string, module?: string): (target: Object) => void;
  29983. /**
  29984. * An implementation of a loop for asynchronous functions.
  29985. */
  29986. export class AsyncLoop {
  29987. /**
  29988. * Defines the number of iterations for the loop
  29989. */
  29990. iterations: number;
  29991. /**
  29992. * Defines the current index of the loop.
  29993. */
  29994. index: number;
  29995. private _done;
  29996. private _fn;
  29997. private _successCallback;
  29998. /**
  29999. * Constructor.
  30000. * @param iterations the number of iterations.
  30001. * @param func the function to run each iteration
  30002. * @param successCallback the callback that will be called upon succesful execution
  30003. * @param offset starting offset.
  30004. */
  30005. constructor(
  30006. /**
  30007. * Defines the number of iterations for the loop
  30008. */
  30009. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30010. /**
  30011. * Execute the next iteration. Must be called after the last iteration was finished.
  30012. */
  30013. executeNext(): void;
  30014. /**
  30015. * Break the loop and run the success callback.
  30016. */
  30017. breakLoop(): void;
  30018. /**
  30019. * Create and run an async loop.
  30020. * @param iterations the number of iterations.
  30021. * @param fn the function to run each iteration
  30022. * @param successCallback the callback that will be called upon succesful execution
  30023. * @param offset starting offset.
  30024. * @returns the created async loop object
  30025. */
  30026. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30027. /**
  30028. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30029. * @param iterations total number of iterations
  30030. * @param syncedIterations number of synchronous iterations in each async iteration.
  30031. * @param fn the function to call each iteration.
  30032. * @param callback a success call back that will be called when iterating stops.
  30033. * @param breakFunction a break condition (optional)
  30034. * @param timeout timeout settings for the setTimeout function. default - 0.
  30035. * @returns the created async loop object
  30036. */
  30037. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30038. }
  30039. }
  30040. declare module BABYLON {
  30041. /**
  30042. * This class defines the direct association between an animation and a target
  30043. */
  30044. export class TargetedAnimation {
  30045. /**
  30046. * Animation to perform
  30047. */
  30048. animation: Animation;
  30049. /**
  30050. * Target to animate
  30051. */
  30052. target: any;
  30053. }
  30054. /**
  30055. * Use this class to create coordinated animations on multiple targets
  30056. */
  30057. export class AnimationGroup implements IDisposable {
  30058. /** The name of the animation group */
  30059. name: string;
  30060. private _scene;
  30061. private _targetedAnimations;
  30062. private _animatables;
  30063. private _from;
  30064. private _to;
  30065. private _isStarted;
  30066. private _isPaused;
  30067. private _speedRatio;
  30068. /**
  30069. * Gets or sets the unique id of the node
  30070. */
  30071. uniqueId: number;
  30072. /**
  30073. * This observable will notify when one animation have ended
  30074. */
  30075. onAnimationEndObservable: Observable<TargetedAnimation>;
  30076. /**
  30077. * Observer raised when one animation loops
  30078. */
  30079. onAnimationLoopObservable: Observable<TargetedAnimation>;
  30080. /**
  30081. * This observable will notify when all animations have ended.
  30082. */
  30083. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  30084. /**
  30085. * This observable will notify when all animations have paused.
  30086. */
  30087. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  30088. /**
  30089. * This observable will notify when all animations are playing.
  30090. */
  30091. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  30092. /**
  30093. * Gets the first frame
  30094. */
  30095. readonly from: number;
  30096. /**
  30097. * Gets the last frame
  30098. */
  30099. readonly to: number;
  30100. /**
  30101. * Define if the animations are started
  30102. */
  30103. readonly isStarted: boolean;
  30104. /**
  30105. * Gets a value indicating that the current group is playing
  30106. */
  30107. readonly isPlaying: boolean;
  30108. /**
  30109. * Gets or sets the speed ratio to use for all animations
  30110. */
  30111. /**
  30112. * Gets or sets the speed ratio to use for all animations
  30113. */
  30114. speedRatio: number;
  30115. /**
  30116. * Gets the targeted animations for this animation group
  30117. */
  30118. readonly targetedAnimations: Array<TargetedAnimation>;
  30119. /**
  30120. * returning the list of animatables controlled by this animation group.
  30121. */
  30122. readonly animatables: Array<Animatable>;
  30123. /**
  30124. * Instantiates a new Animation Group.
  30125. * This helps managing several animations at once.
  30126. * @see http://doc.babylonjs.com/how_to/group
  30127. * @param name Defines the name of the group
  30128. * @param scene Defines the scene the group belongs to
  30129. */
  30130. constructor(
  30131. /** The name of the animation group */
  30132. name: string, scene?: Nullable<Scene>);
  30133. /**
  30134. * Add an animation (with its target) in the group
  30135. * @param animation defines the animation we want to add
  30136. * @param target defines the target of the animation
  30137. * @returns the TargetedAnimation object
  30138. */
  30139. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  30140. /**
  30141. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  30142. * It can add constant keys at begin or end
  30143. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  30144. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  30145. * @returns the animation group
  30146. */
  30147. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  30148. /**
  30149. * Start all animations on given targets
  30150. * @param loop defines if animations must loop
  30151. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  30152. * @param from defines the from key (optional)
  30153. * @param to defines the to key (optional)
  30154. * @returns the current animation group
  30155. */
  30156. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  30157. /**
  30158. * Pause all animations
  30159. * @returns the animation group
  30160. */
  30161. pause(): AnimationGroup;
  30162. /**
  30163. * Play all animations to initial state
  30164. * This function will start() the animations if they were not started or will restart() them if they were paused
  30165. * @param loop defines if animations must loop
  30166. * @returns the animation group
  30167. */
  30168. play(loop?: boolean): AnimationGroup;
  30169. /**
  30170. * Reset all animations to initial state
  30171. * @returns the animation group
  30172. */
  30173. reset(): AnimationGroup;
  30174. /**
  30175. * Restart animations from key 0
  30176. * @returns the animation group
  30177. */
  30178. restart(): AnimationGroup;
  30179. /**
  30180. * Stop all animations
  30181. * @returns the animation group
  30182. */
  30183. stop(): AnimationGroup;
  30184. /**
  30185. * Set animation weight for all animatables
  30186. * @param weight defines the weight to use
  30187. * @return the animationGroup
  30188. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30189. */
  30190. setWeightForAllAnimatables(weight: number): AnimationGroup;
  30191. /**
  30192. * Synchronize and normalize all animatables with a source animatable
  30193. * @param root defines the root animatable to synchronize with
  30194. * @return the animationGroup
  30195. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30196. */
  30197. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  30198. /**
  30199. * Goes to a specific frame in this animation group
  30200. * @param frame the frame number to go to
  30201. * @return the animationGroup
  30202. */
  30203. goToFrame(frame: number): AnimationGroup;
  30204. /**
  30205. * Dispose all associated resources
  30206. */
  30207. dispose(): void;
  30208. private _checkAnimationGroupEnded;
  30209. /**
  30210. * Returns a new AnimationGroup object parsed from the source provided.
  30211. * @param parsedAnimationGroup defines the source
  30212. * @param scene defines the scene that will receive the animationGroup
  30213. * @returns a new AnimationGroup
  30214. */
  30215. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  30216. /**
  30217. * Returns the string "AnimationGroup"
  30218. * @returns "AnimationGroup"
  30219. */
  30220. getClassName(): string;
  30221. /**
  30222. * Creates a detailled string about the object
  30223. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  30224. * @returns a string representing the object
  30225. */
  30226. toString(fullDetails?: boolean): string;
  30227. }
  30228. }
  30229. declare module BABYLON {
  30230. /** @hidden */
  30231. export interface ICollisionCoordinator {
  30232. createCollider(): Collider;
  30233. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30234. init(scene: Scene): void;
  30235. }
  30236. /** @hidden */
  30237. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30238. private _scene;
  30239. private _scaledPosition;
  30240. private _scaledVelocity;
  30241. private _finalPosition;
  30242. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30243. createCollider(): Collider;
  30244. init(scene: Scene): void;
  30245. private _collideWithWorld;
  30246. }
  30247. }
  30248. declare module BABYLON {
  30249. /**
  30250. * Define an interface for all classes that will hold resources
  30251. */
  30252. export interface IDisposable {
  30253. /**
  30254. * Releases all held resources
  30255. */
  30256. dispose(): void;
  30257. }
  30258. /** Interface defining initialization parameters for Scene class */
  30259. export interface SceneOptions {
  30260. /**
  30261. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  30262. * It will improve performance when the number of geometries becomes important.
  30263. */
  30264. useGeometryUniqueIdsMap?: boolean;
  30265. /**
  30266. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  30267. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30268. */
  30269. useMaterialMeshMap?: boolean;
  30270. /**
  30271. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  30272. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30273. */
  30274. useClonedMeshhMap?: boolean;
  30275. }
  30276. /**
  30277. * Represents a scene to be rendered by the engine.
  30278. * @see http://doc.babylonjs.com/features/scene
  30279. */
  30280. export class Scene extends AbstractScene implements IAnimatable {
  30281. private static _uniqueIdCounter;
  30282. /** The fog is deactivated */
  30283. static readonly FOGMODE_NONE: number;
  30284. /** The fog density is following an exponential function */
  30285. static readonly FOGMODE_EXP: number;
  30286. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  30287. static readonly FOGMODE_EXP2: number;
  30288. /** The fog density is following a linear function. */
  30289. static readonly FOGMODE_LINEAR: number;
  30290. /**
  30291. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  30292. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30293. */
  30294. static MinDeltaTime: number;
  30295. /**
  30296. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  30297. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30298. */
  30299. static MaxDeltaTime: number;
  30300. /**
  30301. * Factory used to create the default material.
  30302. * @param name The name of the material to create
  30303. * @param scene The scene to create the material for
  30304. * @returns The default material
  30305. */
  30306. static DefaultMaterialFactory(scene: Scene): Material;
  30307. /**
  30308. * Factory used to create the a collision coordinator.
  30309. * @returns The collision coordinator
  30310. */
  30311. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  30312. /** @hidden */ protected readonly _isScene: boolean;
  30313. /**
  30314. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  30315. */
  30316. autoClear: boolean;
  30317. /**
  30318. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  30319. */
  30320. autoClearDepthAndStencil: boolean;
  30321. /**
  30322. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  30323. */
  30324. clearColor: Color4;
  30325. /**
  30326. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  30327. */
  30328. ambientColor: Color3;
  30329. /** @hidden */ environmentBRDFTexture: BaseTexture;
  30330. /** @hidden */
  30331. protected _environmentTexture: Nullable<BaseTexture>;
  30332. /**
  30333. * Texture used in all pbr material as the reflection texture.
  30334. * As in the majority of the scene they are the same (exception for multi room and so on),
  30335. * this is easier to reference from here than from all the materials.
  30336. */
  30337. /**
  30338. * Texture used in all pbr material as the reflection texture.
  30339. * As in the majority of the scene they are the same (exception for multi room and so on),
  30340. * this is easier to set here than in all the materials.
  30341. */
  30342. environmentTexture: Nullable<BaseTexture>;
  30343. /** @hidden */
  30344. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30345. /**
  30346. * Default image processing configuration used either in the rendering
  30347. * Forward main pass or through the imageProcessingPostProcess if present.
  30348. * As in the majority of the scene they are the same (exception for multi camera),
  30349. * this is easier to reference from here than from all the materials and post process.
  30350. *
  30351. * No setter as we it is a shared configuration, you can set the values instead.
  30352. */
  30353. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  30354. private _forceWireframe;
  30355. /**
  30356. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  30357. */
  30358. forceWireframe: boolean;
  30359. private _forcePointsCloud;
  30360. /**
  30361. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  30362. */
  30363. forcePointsCloud: boolean;
  30364. /**
  30365. * Gets or sets the active clipplane 1
  30366. */
  30367. clipPlane: Nullable<Plane>;
  30368. /**
  30369. * Gets or sets the active clipplane 2
  30370. */
  30371. clipPlane2: Nullable<Plane>;
  30372. /**
  30373. * Gets or sets the active clipplane 3
  30374. */
  30375. clipPlane3: Nullable<Plane>;
  30376. /**
  30377. * Gets or sets the active clipplane 4
  30378. */
  30379. clipPlane4: Nullable<Plane>;
  30380. /**
  30381. * Gets or sets a boolean indicating if animations are enabled
  30382. */
  30383. animationsEnabled: boolean;
  30384. private _animationPropertiesOverride;
  30385. /**
  30386. * Gets or sets the animation properties override
  30387. */
  30388. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  30389. /**
  30390. * Gets or sets a boolean indicating if a constant deltatime has to be used
  30391. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  30392. */
  30393. useConstantAnimationDeltaTime: boolean;
  30394. /**
  30395. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  30396. * Please note that it requires to run a ray cast through the scene on every frame
  30397. */
  30398. constantlyUpdateMeshUnderPointer: boolean;
  30399. /**
  30400. * Defines the HTML cursor to use when hovering over interactive elements
  30401. */
  30402. hoverCursor: string;
  30403. /**
  30404. * Defines the HTML default cursor to use (empty by default)
  30405. */
  30406. defaultCursor: string;
  30407. /**
  30408. * This is used to call preventDefault() on pointer down
  30409. * in order to block unwanted artifacts like system double clicks
  30410. */
  30411. preventDefaultOnPointerDown: boolean;
  30412. /**
  30413. * This is used to call preventDefault() on pointer up
  30414. * in order to block unwanted artifacts like system double clicks
  30415. */
  30416. preventDefaultOnPointerUp: boolean;
  30417. /**
  30418. * Gets or sets user defined metadata
  30419. */
  30420. metadata: any;
  30421. /**
  30422. * For internal use only. Please do not use.
  30423. */
  30424. reservedDataStore: any;
  30425. /**
  30426. * Gets the name of the plugin used to load this scene (null by default)
  30427. */
  30428. loadingPluginName: string;
  30429. /**
  30430. * Use this array to add regular expressions used to disable offline support for specific urls
  30431. */
  30432. disableOfflineSupportExceptionRules: RegExp[];
  30433. /**
  30434. * An event triggered when the scene is disposed.
  30435. */
  30436. onDisposeObservable: Observable<Scene>;
  30437. private _onDisposeObserver;
  30438. /** Sets a function to be executed when this scene is disposed. */
  30439. onDispose: () => void;
  30440. /**
  30441. * An event triggered before rendering the scene (right after animations and physics)
  30442. */
  30443. onBeforeRenderObservable: Observable<Scene>;
  30444. private _onBeforeRenderObserver;
  30445. /** Sets a function to be executed before rendering this scene */
  30446. beforeRender: Nullable<() => void>;
  30447. /**
  30448. * An event triggered after rendering the scene
  30449. */
  30450. onAfterRenderObservable: Observable<Scene>;
  30451. private _onAfterRenderObserver;
  30452. /** Sets a function to be executed after rendering this scene */
  30453. afterRender: Nullable<() => void>;
  30454. /**
  30455. * An event triggered before animating the scene
  30456. */
  30457. onBeforeAnimationsObservable: Observable<Scene>;
  30458. /**
  30459. * An event triggered after animations processing
  30460. */
  30461. onAfterAnimationsObservable: Observable<Scene>;
  30462. /**
  30463. * An event triggered before draw calls are ready to be sent
  30464. */
  30465. onBeforeDrawPhaseObservable: Observable<Scene>;
  30466. /**
  30467. * An event triggered after draw calls have been sent
  30468. */
  30469. onAfterDrawPhaseObservable: Observable<Scene>;
  30470. /**
  30471. * An event triggered when the scene is ready
  30472. */
  30473. onReadyObservable: Observable<Scene>;
  30474. /**
  30475. * An event triggered before rendering a camera
  30476. */
  30477. onBeforeCameraRenderObservable: Observable<Camera>;
  30478. private _onBeforeCameraRenderObserver;
  30479. /** Sets a function to be executed before rendering a camera*/
  30480. beforeCameraRender: () => void;
  30481. /**
  30482. * An event triggered after rendering a camera
  30483. */
  30484. onAfterCameraRenderObservable: Observable<Camera>;
  30485. private _onAfterCameraRenderObserver;
  30486. /** Sets a function to be executed after rendering a camera*/
  30487. afterCameraRender: () => void;
  30488. /**
  30489. * An event triggered when active meshes evaluation is about to start
  30490. */
  30491. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  30492. /**
  30493. * An event triggered when active meshes evaluation is done
  30494. */
  30495. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  30496. /**
  30497. * An event triggered when particles rendering is about to start
  30498. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  30499. */
  30500. onBeforeParticlesRenderingObservable: Observable<Scene>;
  30501. /**
  30502. * An event triggered when particles rendering is done
  30503. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  30504. */
  30505. onAfterParticlesRenderingObservable: Observable<Scene>;
  30506. /**
  30507. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  30508. */
  30509. onDataLoadedObservable: Observable<Scene>;
  30510. /**
  30511. * An event triggered when a camera is created
  30512. */
  30513. onNewCameraAddedObservable: Observable<Camera>;
  30514. /**
  30515. * An event triggered when a camera is removed
  30516. */
  30517. onCameraRemovedObservable: Observable<Camera>;
  30518. /**
  30519. * An event triggered when a light is created
  30520. */
  30521. onNewLightAddedObservable: Observable<Light>;
  30522. /**
  30523. * An event triggered when a light is removed
  30524. */
  30525. onLightRemovedObservable: Observable<Light>;
  30526. /**
  30527. * An event triggered when a geometry is created
  30528. */
  30529. onNewGeometryAddedObservable: Observable<Geometry>;
  30530. /**
  30531. * An event triggered when a geometry is removed
  30532. */
  30533. onGeometryRemovedObservable: Observable<Geometry>;
  30534. /**
  30535. * An event triggered when a transform node is created
  30536. */
  30537. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  30538. /**
  30539. * An event triggered when a transform node is removed
  30540. */
  30541. onTransformNodeRemovedObservable: Observable<TransformNode>;
  30542. /**
  30543. * An event triggered when a mesh is created
  30544. */
  30545. onNewMeshAddedObservable: Observable<AbstractMesh>;
  30546. /**
  30547. * An event triggered when a mesh is removed
  30548. */
  30549. onMeshRemovedObservable: Observable<AbstractMesh>;
  30550. /**
  30551. * An event triggered when a material is created
  30552. */
  30553. onNewMaterialAddedObservable: Observable<Material>;
  30554. /**
  30555. * An event triggered when a material is removed
  30556. */
  30557. onMaterialRemovedObservable: Observable<Material>;
  30558. /**
  30559. * An event triggered when a texture is created
  30560. */
  30561. onNewTextureAddedObservable: Observable<BaseTexture>;
  30562. /**
  30563. * An event triggered when a texture is removed
  30564. */
  30565. onTextureRemovedObservable: Observable<BaseTexture>;
  30566. /**
  30567. * An event triggered when render targets are about to be rendered
  30568. * Can happen multiple times per frame.
  30569. */
  30570. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  30571. /**
  30572. * An event triggered when render targets were rendered.
  30573. * Can happen multiple times per frame.
  30574. */
  30575. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  30576. /**
  30577. * An event triggered before calculating deterministic simulation step
  30578. */
  30579. onBeforeStepObservable: Observable<Scene>;
  30580. /**
  30581. * An event triggered after calculating deterministic simulation step
  30582. */
  30583. onAfterStepObservable: Observable<Scene>;
  30584. /**
  30585. * An event triggered when the activeCamera property is updated
  30586. */
  30587. onActiveCameraChanged: Observable<Scene>;
  30588. /**
  30589. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  30590. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  30591. * 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)
  30592. */
  30593. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  30594. /**
  30595. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  30596. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  30597. * 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)
  30598. */
  30599. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  30600. /**
  30601. * This Observable will when a mesh has been imported into the scene.
  30602. */
  30603. onMeshImportedObservable: Observable<AbstractMesh>;
  30604. private _registeredForLateAnimationBindings;
  30605. /**
  30606. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  30607. */
  30608. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  30609. /**
  30610. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  30611. */
  30612. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  30613. /**
  30614. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  30615. */
  30616. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  30617. private _onPointerMove;
  30618. private _onPointerDown;
  30619. private _onPointerUp;
  30620. /** Callback called when a pointer move is detected */
  30621. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  30622. /** Callback called when a pointer down is detected */
  30623. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  30624. /** Callback called when a pointer up is detected */
  30625. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  30626. /** Callback called when a pointer pick is detected */
  30627. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  30628. /**
  30629. * 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).
  30630. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  30631. */
  30632. onPrePointerObservable: Observable<PointerInfoPre>;
  30633. /**
  30634. * Observable event triggered each time an input event is received from the rendering canvas
  30635. */
  30636. onPointerObservable: Observable<PointerInfo>;
  30637. /**
  30638. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  30639. */
  30640. readonly unTranslatedPointer: Vector2;
  30641. /** The distance in pixel that you have to move to prevent some events */
  30642. static DragMovementThreshold: number;
  30643. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  30644. static LongPressDelay: number;
  30645. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  30646. static DoubleClickDelay: number;
  30647. /** If you need to check double click without raising a single click at first click, enable this flag */
  30648. static ExclusiveDoubleClickMode: boolean;
  30649. private _initClickEvent;
  30650. private _initActionManager;
  30651. private _delayedSimpleClick;
  30652. private _delayedSimpleClickTimeout;
  30653. private _previousDelayedSimpleClickTimeout;
  30654. private _meshPickProceed;
  30655. private _previousButtonPressed;
  30656. private _currentPickResult;
  30657. private _previousPickResult;
  30658. private _totalPointersPressed;
  30659. private _doubleClickOccured;
  30660. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  30661. cameraToUseForPointers: Nullable<Camera>;
  30662. private _pointerX;
  30663. private _pointerY;
  30664. private _unTranslatedPointerX;
  30665. private _unTranslatedPointerY;
  30666. private _startingPointerPosition;
  30667. private _previousStartingPointerPosition;
  30668. private _startingPointerTime;
  30669. private _previousStartingPointerTime;
  30670. private _pointerCaptures;
  30671. private _timeAccumulator;
  30672. private _currentStepId;
  30673. private _currentInternalStep;
  30674. /** @hidden */ mirroredCameraPosition: Nullable<Vector3>;
  30675. /**
  30676. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  30677. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  30678. */
  30679. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  30680. /**
  30681. * Observable event triggered each time an keyboard event is received from the hosting window
  30682. */
  30683. onKeyboardObservable: Observable<KeyboardInfo>;
  30684. private _onKeyDown;
  30685. private _onKeyUp;
  30686. private _onCanvasFocusObserver;
  30687. private _onCanvasBlurObserver;
  30688. private _useRightHandedSystem;
  30689. /**
  30690. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  30691. */
  30692. useRightHandedSystem: boolean;
  30693. /**
  30694. * Sets the step Id used by deterministic lock step
  30695. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30696. * @param newStepId defines the step Id
  30697. */
  30698. setStepId(newStepId: number): void;
  30699. /**
  30700. * Gets the step Id used by deterministic lock step
  30701. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30702. * @returns the step Id
  30703. */
  30704. getStepId(): number;
  30705. /**
  30706. * Gets the internal step used by deterministic lock step
  30707. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30708. * @returns the internal step
  30709. */
  30710. getInternalStep(): number;
  30711. private _fogEnabled;
  30712. /**
  30713. * Gets or sets a boolean indicating if fog is enabled on this scene
  30714. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30715. * (Default is true)
  30716. */
  30717. fogEnabled: boolean;
  30718. private _fogMode;
  30719. /**
  30720. * Gets or sets the fog mode to use
  30721. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30722. * | mode | value |
  30723. * | --- | --- |
  30724. * | FOGMODE_NONE | 0 |
  30725. * | FOGMODE_EXP | 1 |
  30726. * | FOGMODE_EXP2 | 2 |
  30727. * | FOGMODE_LINEAR | 3 |
  30728. */
  30729. fogMode: number;
  30730. /**
  30731. * Gets or sets the fog color to use
  30732. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30733. * (Default is Color3(0.2, 0.2, 0.3))
  30734. */
  30735. fogColor: Color3;
  30736. /**
  30737. * Gets or sets the fog density to use
  30738. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30739. * (Default is 0.1)
  30740. */
  30741. fogDensity: number;
  30742. /**
  30743. * Gets or sets the fog start distance to use
  30744. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30745. * (Default is 0)
  30746. */
  30747. fogStart: number;
  30748. /**
  30749. * Gets or sets the fog end distance to use
  30750. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30751. * (Default is 1000)
  30752. */
  30753. fogEnd: number;
  30754. private _shadowsEnabled;
  30755. /**
  30756. * Gets or sets a boolean indicating if shadows are enabled on this scene
  30757. */
  30758. shadowsEnabled: boolean;
  30759. private _lightsEnabled;
  30760. /**
  30761. * Gets or sets a boolean indicating if lights are enabled on this scene
  30762. */
  30763. lightsEnabled: boolean;
  30764. /** All of the active cameras added to this scene. */
  30765. activeCameras: Camera[];
  30766. private _activeCamera;
  30767. /** Gets or sets the current active camera */
  30768. activeCamera: Nullable<Camera>;
  30769. private _defaultMaterial;
  30770. /** The default material used on meshes when no material is affected */
  30771. /** The default material used on meshes when no material is affected */
  30772. defaultMaterial: Material;
  30773. private _texturesEnabled;
  30774. /**
  30775. * Gets or sets a boolean indicating if textures are enabled on this scene
  30776. */
  30777. texturesEnabled: boolean;
  30778. /**
  30779. * Gets or sets a boolean indicating if particles are enabled on this scene
  30780. */
  30781. particlesEnabled: boolean;
  30782. /**
  30783. * Gets or sets a boolean indicating if sprites are enabled on this scene
  30784. */
  30785. spritesEnabled: boolean;
  30786. private _skeletonsEnabled;
  30787. /**
  30788. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  30789. */
  30790. skeletonsEnabled: boolean;
  30791. /**
  30792. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  30793. */
  30794. lensFlaresEnabled: boolean;
  30795. /**
  30796. * Gets or sets a boolean indicating if collisions are enabled on this scene
  30797. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  30798. */
  30799. collisionsEnabled: boolean;
  30800. private _collisionCoordinator;
  30801. /** @hidden */
  30802. readonly collisionCoordinator: ICollisionCoordinator;
  30803. /**
  30804. * Defines the gravity applied to this scene (used only for collisions)
  30805. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  30806. */
  30807. gravity: Vector3;
  30808. /**
  30809. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  30810. */
  30811. postProcessesEnabled: boolean;
  30812. /**
  30813. * The list of postprocesses added to the scene
  30814. */
  30815. postProcesses: PostProcess[];
  30816. /**
  30817. * Gets the current postprocess manager
  30818. */
  30819. postProcessManager: PostProcessManager;
  30820. /**
  30821. * Gets or sets a boolean indicating if render targets are enabled on this scene
  30822. */
  30823. renderTargetsEnabled: boolean;
  30824. /**
  30825. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  30826. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  30827. */
  30828. dumpNextRenderTargets: boolean;
  30829. /**
  30830. * The list of user defined render targets added to the scene
  30831. */
  30832. customRenderTargets: RenderTargetTexture[];
  30833. /**
  30834. * Defines if texture loading must be delayed
  30835. * If true, textures will only be loaded when they need to be rendered
  30836. */
  30837. useDelayedTextureLoading: boolean;
  30838. /**
  30839. * Gets the list of meshes imported to the scene through SceneLoader
  30840. */
  30841. importedMeshesFiles: String[];
  30842. /**
  30843. * Gets or sets a boolean indicating if probes are enabled on this scene
  30844. */
  30845. probesEnabled: boolean;
  30846. /**
  30847. * Gets or sets the current offline provider to use to store scene data
  30848. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30849. */
  30850. offlineProvider: IOfflineProvider;
  30851. /**
  30852. * Gets or sets the action manager associated with the scene
  30853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  30854. */
  30855. actionManager: AbstractActionManager;
  30856. private _meshesForIntersections;
  30857. /**
  30858. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  30859. */
  30860. proceduralTexturesEnabled: boolean;
  30861. private _engine;
  30862. private _totalVertices;
  30863. /** @hidden */ activeIndices: PerfCounter;
  30864. /** @hidden */ activeParticles: PerfCounter;
  30865. /** @hidden */ activeBones: PerfCounter;
  30866. private _animationRatio;
  30867. private _animationTimeLast;
  30868. private _animationTime;
  30869. /**
  30870. * Gets or sets a general scale for animation speed
  30871. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  30872. */
  30873. animationTimeScale: number;
  30874. /** @hidden */ cachedMaterial: Nullable<Material>;
  30875. /** @hidden */ cachedEffect: Nullable<Effect>;
  30876. /** @hidden */ cachedVisibility: Nullable<number>;
  30877. private _renderId;
  30878. private _frameId;
  30879. private _executeWhenReadyTimeoutId;
  30880. private _intermediateRendering;
  30881. private _viewUpdateFlag;
  30882. private _projectionUpdateFlag;
  30883. private _alternateViewUpdateFlag;
  30884. private _alternateProjectionUpdateFlag;
  30885. /** @hidden */ toBeDisposed: Nullable<IDisposable>[];
  30886. private _activeRequests;
  30887. private _pendingData;
  30888. private _isDisposed;
  30889. /**
  30890. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  30891. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  30892. */
  30893. dispatchAllSubMeshesOfActiveMeshes: boolean;
  30894. private _activeMeshes;
  30895. private _processedMaterials;
  30896. private _renderTargets;
  30897. /** @hidden */ activeParticleSystems: SmartArray<IParticleSystem>;
  30898. private _activeSkeletons;
  30899. private _softwareSkinnedMeshes;
  30900. private _renderingManager;
  30901. /** @hidden */ activeAnimatables: Animatable[];
  30902. private _transformMatrix;
  30903. private _sceneUbo;
  30904. private _alternateSceneUbo;
  30905. private _pickWithRayInverseMatrix;
  30906. private _viewMatrix;
  30907. private _projectionMatrix;
  30908. private _alternateViewMatrix;
  30909. private _alternateProjectionMatrix;
  30910. private _alternateTransformMatrix;
  30911. private _useAlternateCameraConfiguration;
  30912. private _alternateRendering;
  30913. private _wheelEventName;
  30914. /** @hidden */ forcedViewPosition: Nullable<Vector3>;
  30915. /** @hidden */ protected readonly _isAlternateRenderingEnabled: boolean;
  30916. private _frustumPlanes;
  30917. /**
  30918. * Gets the list of frustum planes (built from the active camera)
  30919. */
  30920. readonly frustumPlanes: Plane[];
  30921. /**
  30922. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  30923. * This is useful if there are more lights that the maximum simulteanous authorized
  30924. */
  30925. requireLightSorting: boolean;
  30926. /** @hidden */
  30927. readonly useMaterialMeshMap: boolean;
  30928. /** @hidden */
  30929. readonly useClonedMeshhMap: boolean;
  30930. private _pointerOverMesh;
  30931. private _pickedDownMesh;
  30932. private _pickedUpMesh;
  30933. private _externalData;
  30934. private _uid;
  30935. /**
  30936. * @hidden
  30937. * Backing store of defined scene components.
  30938. */ components: ISceneComponent[];
  30939. /**
  30940. * @hidden
  30941. * Backing store of defined scene components.
  30942. */ serializableComponents: ISceneSerializableComponent[];
  30943. /**
  30944. * List of components to register on the next registration step.
  30945. */
  30946. private _transientComponents;
  30947. /**
  30948. * Registers the transient components if needed.
  30949. */
  30950. private _registerTransientComponents;
  30951. /**
  30952. * @hidden
  30953. * Add a component to the scene.
  30954. * Note that the ccomponent could be registered on th next frame if this is called after
  30955. * the register component stage.
  30956. * @param component Defines the component to add to the scene
  30957. */ addComponent(component: ISceneComponent): void;
  30958. /**
  30959. * @hidden
  30960. * Gets a component from the scene.
  30961. * @param name defines the name of the component to retrieve
  30962. * @returns the component or null if not present
  30963. */ getComponent(name: string): Nullable<ISceneComponent>;
  30964. /**
  30965. * @hidden
  30966. * Defines the actions happening before camera updates.
  30967. */ beforeCameraUpdateStage: Stage<SimpleStageAction>;
  30968. /**
  30969. * @hidden
  30970. * Defines the actions happening before clear the canvas.
  30971. */ beforeClearStage: Stage<SimpleStageAction>;
  30972. /**
  30973. * @hidden
  30974. * Defines the actions when collecting render targets for the frame.
  30975. */ gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  30976. /**
  30977. * @hidden
  30978. * Defines the actions happening for one camera in the frame.
  30979. */ gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  30980. /**
  30981. * @hidden
  30982. * Defines the actions happening during the per mesh ready checks.
  30983. */ isReadyForMeshStage: Stage<MeshStageAction>;
  30984. /**
  30985. * @hidden
  30986. * Defines the actions happening before evaluate active mesh checks.
  30987. */ beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  30988. /**
  30989. * @hidden
  30990. * Defines the actions happening during the evaluate sub mesh checks.
  30991. */ evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  30992. /**
  30993. * @hidden
  30994. * Defines the actions happening during the active mesh stage.
  30995. */ activeMeshStage: Stage<ActiveMeshStageAction>;
  30996. /**
  30997. * @hidden
  30998. * Defines the actions happening during the per camera render target step.
  30999. */ cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  31000. /**
  31001. * @hidden
  31002. * Defines the actions happening just before the active camera is drawing.
  31003. */ beforeCameraDrawStage: Stage<CameraStageAction>;
  31004. /**
  31005. * @hidden
  31006. * Defines the actions happening just before a render target is drawing.
  31007. */ beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31008. /**
  31009. * @hidden
  31010. * Defines the actions happening just before a rendering group is drawing.
  31011. */ beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31012. /**
  31013. * @hidden
  31014. * Defines the actions happening just before a mesh is drawing.
  31015. */ beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31016. /**
  31017. * @hidden
  31018. * Defines the actions happening just after a mesh has been drawn.
  31019. */ afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31020. /**
  31021. * @hidden
  31022. * Defines the actions happening just after a rendering group has been drawn.
  31023. */ afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31024. /**
  31025. * @hidden
  31026. * Defines the actions happening just after the active camera has been drawn.
  31027. */ afterCameraDrawStage: Stage<CameraStageAction>;
  31028. /**
  31029. * @hidden
  31030. * Defines the actions happening just after a render target has been drawn.
  31031. */ afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31032. /**
  31033. * @hidden
  31034. * Defines the actions happening just after rendering all cameras and computing intersections.
  31035. */ afterRenderStage: Stage<SimpleStageAction>;
  31036. /**
  31037. * @hidden
  31038. * Defines the actions happening when a pointer move event happens.
  31039. */ pointerMoveStage: Stage<PointerMoveStageAction>;
  31040. /**
  31041. * @hidden
  31042. * Defines the actions happening when a pointer down event happens.
  31043. */ pointerDownStage: Stage<PointerUpDownStageAction>;
  31044. /**
  31045. * @hidden
  31046. * Defines the actions happening when a pointer up event happens.
  31047. */ pointerUpStage: Stage<PointerUpDownStageAction>;
  31048. /**
  31049. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  31050. */
  31051. private geometriesByUniqueId;
  31052. /**
  31053. * Creates a new Scene
  31054. * @param engine defines the engine to use to render this scene
  31055. * @param options defines the scene options
  31056. */
  31057. constructor(engine: Engine, options?: SceneOptions);
  31058. private _defaultMeshCandidates;
  31059. /**
  31060. * @hidden
  31061. */ getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  31062. private _defaultSubMeshCandidates;
  31063. /**
  31064. * @hidden
  31065. */ getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  31066. /**
  31067. * Sets the default candidate providers for the scene.
  31068. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  31069. * and getCollidingSubMeshCandidates to their default function
  31070. */
  31071. setDefaultCandidateProviders(): void;
  31072. /**
  31073. * Gets the mesh that is currently under the pointer
  31074. */
  31075. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31076. /**
  31077. * Gets or sets the current on-screen X position of the pointer
  31078. */
  31079. pointerX: number;
  31080. /**
  31081. * Gets or sets the current on-screen Y position of the pointer
  31082. */
  31083. pointerY: number;
  31084. /**
  31085. * Gets the cached material (ie. the latest rendered one)
  31086. * @returns the cached material
  31087. */
  31088. getCachedMaterial(): Nullable<Material>;
  31089. /**
  31090. * Gets the cached effect (ie. the latest rendered one)
  31091. * @returns the cached effect
  31092. */
  31093. getCachedEffect(): Nullable<Effect>;
  31094. /**
  31095. * Gets the cached visibility state (ie. the latest rendered one)
  31096. * @returns the cached visibility state
  31097. */
  31098. getCachedVisibility(): Nullable<number>;
  31099. /**
  31100. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  31101. * @param material defines the current material
  31102. * @param effect defines the current effect
  31103. * @param visibility defines the current visibility state
  31104. * @returns true if one parameter is not cached
  31105. */
  31106. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  31107. /**
  31108. * Gets the engine associated with the scene
  31109. * @returns an Engine
  31110. */
  31111. getEngine(): Engine;
  31112. /**
  31113. * Gets the total number of vertices rendered per frame
  31114. * @returns the total number of vertices rendered per frame
  31115. */
  31116. getTotalVertices(): number;
  31117. /**
  31118. * Gets the performance counter for total vertices
  31119. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31120. */
  31121. readonly totalVerticesPerfCounter: PerfCounter;
  31122. /**
  31123. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  31124. * @returns the total number of active indices rendered per frame
  31125. */
  31126. getActiveIndices(): number;
  31127. /**
  31128. * Gets the performance counter for active indices
  31129. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31130. */
  31131. readonly totalActiveIndicesPerfCounter: PerfCounter;
  31132. /**
  31133. * Gets the total number of active particles rendered per frame
  31134. * @returns the total number of active particles rendered per frame
  31135. */
  31136. getActiveParticles(): number;
  31137. /**
  31138. * Gets the performance counter for active particles
  31139. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31140. */
  31141. readonly activeParticlesPerfCounter: PerfCounter;
  31142. /**
  31143. * Gets the total number of active bones rendered per frame
  31144. * @returns the total number of active bones rendered per frame
  31145. */
  31146. getActiveBones(): number;
  31147. /**
  31148. * Gets the performance counter for active bones
  31149. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31150. */
  31151. readonly activeBonesPerfCounter: PerfCounter;
  31152. /**
  31153. * Gets the array of active meshes
  31154. * @returns an array of AbstractMesh
  31155. */
  31156. getActiveMeshes(): SmartArray<AbstractMesh>;
  31157. /**
  31158. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  31159. * @returns a number
  31160. */
  31161. getAnimationRatio(): number;
  31162. /**
  31163. * Gets an unique Id for the current render phase
  31164. * @returns a number
  31165. */
  31166. getRenderId(): number;
  31167. /**
  31168. * Gets an unique Id for the current frame
  31169. * @returns a number
  31170. */
  31171. getFrameId(): number;
  31172. /** Call this function if you want to manually increment the render Id*/
  31173. incrementRenderId(): void;
  31174. private _updatePointerPosition;
  31175. private _createUbo;
  31176. private _createAlternateUbo;
  31177. private _setRayOnPointerInfo;
  31178. /**
  31179. * Use this method to simulate a pointer move on a mesh
  31180. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31181. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31182. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31183. * @returns the current scene
  31184. */
  31185. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31186. private _processPointerMove;
  31187. private _checkPrePointerObservable;
  31188. /**
  31189. * Use this method to simulate a pointer down on a mesh
  31190. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31191. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31192. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31193. * @returns the current scene
  31194. */
  31195. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31196. private _processPointerDown;
  31197. /**
  31198. * Use this method to simulate a pointer up on a mesh
  31199. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31200. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31201. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31202. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31203. * @returns the current scene
  31204. */
  31205. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  31206. private _processPointerUp;
  31207. /**
  31208. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31209. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31210. * @returns true if the pointer was captured
  31211. */
  31212. isPointerCaptured(pointerId?: number): boolean;
  31213. /** @hidden */ isPointerSwiping(): boolean;
  31214. /**
  31215. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31216. * @param attachUp defines if you want to attach events to pointerup
  31217. * @param attachDown defines if you want to attach events to pointerdown
  31218. * @param attachMove defines if you want to attach events to pointermove
  31219. */
  31220. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31221. /** Detaches all event handlers*/
  31222. detachControl(): void;
  31223. /**
  31224. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  31225. * Delay loaded resources are not taking in account
  31226. * @return true if all required resources are ready
  31227. */
  31228. isReady(): boolean;
  31229. /** Resets all cached information relative to material (including effect and visibility) */
  31230. resetCachedMaterial(): void;
  31231. /**
  31232. * Registers a function to be called before every frame render
  31233. * @param func defines the function to register
  31234. */
  31235. registerBeforeRender(func: () => void): void;
  31236. /**
  31237. * Unregisters a function called before every frame render
  31238. * @param func defines the function to unregister
  31239. */
  31240. unregisterBeforeRender(func: () => void): void;
  31241. /**
  31242. * Registers a function to be called after every frame render
  31243. * @param func defines the function to register
  31244. */
  31245. registerAfterRender(func: () => void): void;
  31246. /**
  31247. * Unregisters a function called after every frame render
  31248. * @param func defines the function to unregister
  31249. */
  31250. unregisterAfterRender(func: () => void): void;
  31251. private _executeOnceBeforeRender;
  31252. /**
  31253. * The provided function will run before render once and will be disposed afterwards.
  31254. * A timeout delay can be provided so that the function will be executed in N ms.
  31255. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  31256. * @param func The function to be executed.
  31257. * @param timeout optional delay in ms
  31258. */
  31259. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  31260. /** @hidden */ addPendingData(data: any): void;
  31261. /** @hidden */ removePendingData(data: any): void;
  31262. /**
  31263. * Returns the number of items waiting to be loaded
  31264. * @returns the number of items waiting to be loaded
  31265. */
  31266. getWaitingItemsCount(): number;
  31267. /**
  31268. * Returns a boolean indicating if the scene is still loading data
  31269. */
  31270. readonly isLoading: boolean;
  31271. /**
  31272. * Registers a function to be executed when the scene is ready
  31273. * @param {Function} func - the function to be executed
  31274. */
  31275. executeWhenReady(func: () => void): void;
  31276. /**
  31277. * Returns a promise that resolves when the scene is ready
  31278. * @returns A promise that resolves when the scene is ready
  31279. */
  31280. whenReadyAsync(): Promise<void>;
  31281. /** @hidden */ checkIsReady(): void;
  31282. /**
  31283. * Will start the animation sequence of a given target
  31284. * @param target defines the target
  31285. * @param from defines from which frame should animation start
  31286. * @param to defines until which frame should animation run.
  31287. * @param weight defines the weight to apply to the animation (1.0 by default)
  31288. * @param loop defines if the animation loops
  31289. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  31290. * @param onAnimationEnd defines the function to be executed when the animation ends
  31291. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  31292. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  31293. * @param onAnimationLoop defines the callback to call when an animation loops
  31294. * @returns the animatable object created for this animation
  31295. */
  31296. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  31297. /**
  31298. * Will start the animation sequence of a given target
  31299. * @param target defines the target
  31300. * @param from defines from which frame should animation start
  31301. * @param to defines until which frame should animation run.
  31302. * @param loop defines if the animation loops
  31303. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  31304. * @param onAnimationEnd defines the function to be executed when the animation ends
  31305. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  31306. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  31307. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  31308. * @param onAnimationLoop defines the callback to call when an animation loops
  31309. * @returns the animatable object created for this animation
  31310. */
  31311. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  31312. /**
  31313. * Will start the animation sequence of a given target and its hierarchy
  31314. * @param target defines the target
  31315. * @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.
  31316. * @param from defines from which frame should animation start
  31317. * @param to defines until which frame should animation run.
  31318. * @param loop defines if the animation loops
  31319. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  31320. * @param onAnimationEnd defines the function to be executed when the animation ends
  31321. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  31322. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  31323. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  31324. * @param onAnimationLoop defines the callback to call when an animation loops
  31325. * @returns the list of created animatables
  31326. */
  31327. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  31328. /**
  31329. * Begin a new animation on a given node
  31330. * @param target defines the target where the animation will take place
  31331. * @param animations defines the list of animations to start
  31332. * @param from defines the initial value
  31333. * @param to defines the final value
  31334. * @param loop defines if you want animation to loop (off by default)
  31335. * @param speedRatio defines the speed ratio to apply to all animations
  31336. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  31337. * @param onAnimationLoop defines the callback to call when an animation loops
  31338. * @returns the list of created animatables
  31339. */
  31340. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  31341. /**
  31342. * Begin a new animation on a given node and its hierarchy
  31343. * @param target defines the root node where the animation will take place
  31344. * @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.
  31345. * @param animations defines the list of animations to start
  31346. * @param from defines the initial value
  31347. * @param to defines the final value
  31348. * @param loop defines if you want animation to loop (off by default)
  31349. * @param speedRatio defines the speed ratio to apply to all animations
  31350. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  31351. * @param onAnimationLoop defines the callback to call when an animation loops
  31352. * @returns the list of animatables created for all nodes
  31353. */
  31354. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  31355. /**
  31356. * Gets the animatable associated with a specific target
  31357. * @param target defines the target of the animatable
  31358. * @returns the required animatable if found
  31359. */
  31360. getAnimatableByTarget(target: any): Nullable<Animatable>;
  31361. /**
  31362. * Gets all animatables associated with a given target
  31363. * @param target defines the target to look animatables for
  31364. * @returns an array of Animatables
  31365. */
  31366. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  31367. /**
  31368. * Gets all animatable attached to the scene
  31369. */
  31370. readonly animatables: Animatable[];
  31371. /**
  31372. * Will stop the animation of the given target
  31373. * @param target - the target
  31374. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  31375. * @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)
  31376. */
  31377. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  31378. /**
  31379. * Stops and removes all animations that have been applied to the scene
  31380. */
  31381. stopAllAnimations(): void;
  31382. /**
  31383. * Resets the last animation time frame.
  31384. * Useful to override when animations start running when loading a scene for the first time.
  31385. */
  31386. resetLastAnimationTimeFrame(): void;
  31387. private _animate;
  31388. /** @hidden */ registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  31389. private _processLateAnimationBindingsForMatrices;
  31390. private _processLateAnimationBindingsForQuaternions;
  31391. private _processLateAnimationBindings;
  31392. /** @hidden */ switchToAlternateCameraConfiguration(active: boolean): void;
  31393. /**
  31394. * Gets the current view matrix
  31395. * @returns a Matrix
  31396. */
  31397. getViewMatrix(): Matrix;
  31398. /**
  31399. * Gets the current projection matrix
  31400. * @returns a Matrix
  31401. */
  31402. getProjectionMatrix(): Matrix;
  31403. /**
  31404. * Gets the current transform matrix
  31405. * @returns a Matrix made of View * Projection
  31406. */
  31407. getTransformMatrix(): Matrix;
  31408. /**
  31409. * Sets the current transform matrix
  31410. * @param view defines the View matrix to use
  31411. * @param projection defines the Projection matrix to use
  31412. */
  31413. setTransformMatrix(view: Matrix, projection: Matrix): void;
  31414. /** @hidden */ setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  31415. /**
  31416. * Gets the uniform buffer used to store scene data
  31417. * @returns a UniformBuffer
  31418. */
  31419. getSceneUniformBuffer(): UniformBuffer;
  31420. /**
  31421. * Gets an unique (relatively to the current scene) Id
  31422. * @returns an unique number for the scene
  31423. */
  31424. getUniqueId(): number;
  31425. /**
  31426. * Add a mesh to the list of scene's meshes
  31427. * @param newMesh defines the mesh to add
  31428. * @param recursive if all child meshes should also be added to the scene
  31429. */
  31430. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  31431. /**
  31432. * Remove a mesh for the list of scene's meshes
  31433. * @param toRemove defines the mesh to remove
  31434. * @param recursive if all child meshes should also be removed from the scene
  31435. * @returns the index where the mesh was in the mesh list
  31436. */
  31437. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  31438. /**
  31439. * Add a transform node to the list of scene's transform nodes
  31440. * @param newTransformNode defines the transform node to add
  31441. */
  31442. addTransformNode(newTransformNode: TransformNode): void;
  31443. /**
  31444. * Remove a transform node for the list of scene's transform nodes
  31445. * @param toRemove defines the transform node to remove
  31446. * @returns the index where the transform node was in the transform node list
  31447. */
  31448. removeTransformNode(toRemove: TransformNode): number;
  31449. /**
  31450. * Remove a skeleton for the list of scene's skeletons
  31451. * @param toRemove defines the skeleton to remove
  31452. * @returns the index where the skeleton was in the skeleton list
  31453. */
  31454. removeSkeleton(toRemove: Skeleton): number;
  31455. /**
  31456. * Remove a morph target for the list of scene's morph targets
  31457. * @param toRemove defines the morph target to remove
  31458. * @returns the index where the morph target was in the morph target list
  31459. */
  31460. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  31461. /**
  31462. * Remove a light for the list of scene's lights
  31463. * @param toRemove defines the light to remove
  31464. * @returns the index where the light was in the light list
  31465. */
  31466. removeLight(toRemove: Light): number;
  31467. /**
  31468. * Remove a camera for the list of scene's cameras
  31469. * @param toRemove defines the camera to remove
  31470. * @returns the index where the camera was in the camera list
  31471. */
  31472. removeCamera(toRemove: Camera): number;
  31473. /**
  31474. * Remove a particle system for the list of scene's particle systems
  31475. * @param toRemove defines the particle system to remove
  31476. * @returns the index where the particle system was in the particle system list
  31477. */
  31478. removeParticleSystem(toRemove: IParticleSystem): number;
  31479. /**
  31480. * Remove a animation for the list of scene's animations
  31481. * @param toRemove defines the animation to remove
  31482. * @returns the index where the animation was in the animation list
  31483. */
  31484. removeAnimation(toRemove: Animation): number;
  31485. /**
  31486. * Removes the given animation group from this scene.
  31487. * @param toRemove The animation group to remove
  31488. * @returns The index of the removed animation group
  31489. */
  31490. removeAnimationGroup(toRemove: AnimationGroup): number;
  31491. /**
  31492. * Removes the given multi-material from this scene.
  31493. * @param toRemove The multi-material to remove
  31494. * @returns The index of the removed multi-material
  31495. */
  31496. removeMultiMaterial(toRemove: MultiMaterial): number;
  31497. /**
  31498. * Removes the given material from this scene.
  31499. * @param toRemove The material to remove
  31500. * @returns The index of the removed material
  31501. */
  31502. removeMaterial(toRemove: Material): number;
  31503. /**
  31504. * Removes the given action manager from this scene.
  31505. * @param toRemove The action manager to remove
  31506. * @returns The index of the removed action manager
  31507. */
  31508. removeActionManager(toRemove: AbstractActionManager): number;
  31509. /**
  31510. * Removes the given texture from this scene.
  31511. * @param toRemove The texture to remove
  31512. * @returns The index of the removed texture
  31513. */
  31514. removeTexture(toRemove: BaseTexture): number;
  31515. /**
  31516. * Adds the given light to this scene
  31517. * @param newLight The light to add
  31518. */
  31519. addLight(newLight: Light): void;
  31520. /**
  31521. * Sorts the list list based on light priorities
  31522. */
  31523. sortLightsByPriority(): void;
  31524. /**
  31525. * Adds the given camera to this scene
  31526. * @param newCamera The camera to add
  31527. */
  31528. addCamera(newCamera: Camera): void;
  31529. /**
  31530. * Adds the given skeleton to this scene
  31531. * @param newSkeleton The skeleton to add
  31532. */
  31533. addSkeleton(newSkeleton: Skeleton): void;
  31534. /**
  31535. * Adds the given particle system to this scene
  31536. * @param newParticleSystem The particle system to add
  31537. */
  31538. addParticleSystem(newParticleSystem: IParticleSystem): void;
  31539. /**
  31540. * Adds the given animation to this scene
  31541. * @param newAnimation The animation to add
  31542. */
  31543. addAnimation(newAnimation: Animation): void;
  31544. /**
  31545. * Adds the given animation group to this scene.
  31546. * @param newAnimationGroup The animation group to add
  31547. */
  31548. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  31549. /**
  31550. * Adds the given multi-material to this scene
  31551. * @param newMultiMaterial The multi-material to add
  31552. */
  31553. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  31554. /**
  31555. * Adds the given material to this scene
  31556. * @param newMaterial The material to add
  31557. */
  31558. addMaterial(newMaterial: Material): void;
  31559. /**
  31560. * Adds the given morph target to this scene
  31561. * @param newMorphTargetManager The morph target to add
  31562. */
  31563. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  31564. /**
  31565. * Adds the given geometry to this scene
  31566. * @param newGeometry The geometry to add
  31567. */
  31568. addGeometry(newGeometry: Geometry): void;
  31569. /**
  31570. * Adds the given action manager to this scene
  31571. * @param newActionManager The action manager to add
  31572. */
  31573. addActionManager(newActionManager: AbstractActionManager): void;
  31574. /**
  31575. * Adds the given texture to this scene.
  31576. * @param newTexture The texture to add
  31577. */
  31578. addTexture(newTexture: BaseTexture): void;
  31579. /**
  31580. * Switch active camera
  31581. * @param newCamera defines the new active camera
  31582. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  31583. */
  31584. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  31585. /**
  31586. * sets the active camera of the scene using its ID
  31587. * @param id defines the camera's ID
  31588. * @return the new active camera or null if none found.
  31589. */
  31590. setActiveCameraByID(id: string): Nullable<Camera>;
  31591. /**
  31592. * sets the active camera of the scene using its name
  31593. * @param name defines the camera's name
  31594. * @returns the new active camera or null if none found.
  31595. */
  31596. setActiveCameraByName(name: string): Nullable<Camera>;
  31597. /**
  31598. * get an animation group using its name
  31599. * @param name defines the material's name
  31600. * @return the animation group or null if none found.
  31601. */
  31602. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  31603. /**
  31604. * get a material using its id
  31605. * @param id defines the material's ID
  31606. * @return the material or null if none found.
  31607. */
  31608. getMaterialByID(id: string): Nullable<Material>;
  31609. /**
  31610. * Gets a material using its name
  31611. * @param name defines the material's name
  31612. * @return the material or null if none found.
  31613. */
  31614. getMaterialByName(name: string): Nullable<Material>;
  31615. /**
  31616. * Gets a camera using its id
  31617. * @param id defines the id to look for
  31618. * @returns the camera or null if not found
  31619. */
  31620. getCameraByID(id: string): Nullable<Camera>;
  31621. /**
  31622. * Gets a camera using its unique id
  31623. * @param uniqueId defines the unique id to look for
  31624. * @returns the camera or null if not found
  31625. */
  31626. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  31627. /**
  31628. * Gets a camera using its name
  31629. * @param name defines the camera's name
  31630. * @return the camera or null if none found.
  31631. */
  31632. getCameraByName(name: string): Nullable<Camera>;
  31633. /**
  31634. * Gets a bone using its id
  31635. * @param id defines the bone's id
  31636. * @return the bone or null if not found
  31637. */
  31638. getBoneByID(id: string): Nullable<Bone>;
  31639. /**
  31640. * Gets a bone using its id
  31641. * @param name defines the bone's name
  31642. * @return the bone or null if not found
  31643. */
  31644. getBoneByName(name: string): Nullable<Bone>;
  31645. /**
  31646. * Gets a light node using its name
  31647. * @param name defines the the light's name
  31648. * @return the light or null if none found.
  31649. */
  31650. getLightByName(name: string): Nullable<Light>;
  31651. /**
  31652. * Gets a light node using its id
  31653. * @param id defines the light's id
  31654. * @return the light or null if none found.
  31655. */
  31656. getLightByID(id: string): Nullable<Light>;
  31657. /**
  31658. * Gets a light node using its scene-generated unique ID
  31659. * @param uniqueId defines the light's unique id
  31660. * @return the light or null if none found.
  31661. */
  31662. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  31663. /**
  31664. * Gets a particle system by id
  31665. * @param id defines the particle system id
  31666. * @return the corresponding system or null if none found
  31667. */
  31668. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  31669. /**
  31670. * Gets a geometry using its ID
  31671. * @param id defines the geometry's id
  31672. * @return the geometry or null if none found.
  31673. */
  31674. getGeometryByID(id: string): Nullable<Geometry>;
  31675. private _getGeometryByUniqueID;
  31676. /**
  31677. * Add a new geometry to this scene
  31678. * @param geometry defines the geometry to be added to the scene.
  31679. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  31680. * @return a boolean defining if the geometry was added or not
  31681. */
  31682. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  31683. /**
  31684. * Removes an existing geometry
  31685. * @param geometry defines the geometry to be removed from the scene
  31686. * @return a boolean defining if the geometry was removed or not
  31687. */
  31688. removeGeometry(geometry: Geometry): boolean;
  31689. /**
  31690. * Gets the list of geometries attached to the scene
  31691. * @returns an array of Geometry
  31692. */
  31693. getGeometries(): Geometry[];
  31694. /**
  31695. * Gets the first added mesh found of a given ID
  31696. * @param id defines the id to search for
  31697. * @return the mesh found or null if not found at all
  31698. */
  31699. getMeshByID(id: string): Nullable<AbstractMesh>;
  31700. /**
  31701. * Gets a list of meshes using their id
  31702. * @param id defines the id to search for
  31703. * @returns a list of meshes
  31704. */
  31705. getMeshesByID(id: string): Array<AbstractMesh>;
  31706. /**
  31707. * Gets the first added transform node found of a given ID
  31708. * @param id defines the id to search for
  31709. * @return the found transform node or null if not found at all.
  31710. */
  31711. getTransformNodeByID(id: string): Nullable<TransformNode>;
  31712. /**
  31713. * Gets a list of transform nodes using their id
  31714. * @param id defines the id to search for
  31715. * @returns a list of transform nodes
  31716. */
  31717. getTransformNodesByID(id: string): Array<TransformNode>;
  31718. /**
  31719. * Gets a mesh with its auto-generated unique id
  31720. * @param uniqueId defines the unique id to search for
  31721. * @return the found mesh or null if not found at all.
  31722. */
  31723. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  31724. /**
  31725. * Gets a the last added mesh using a given id
  31726. * @param id defines the id to search for
  31727. * @return the found mesh or null if not found at all.
  31728. */
  31729. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  31730. /**
  31731. * Gets a the last added node (Mesh, Camera, Light) using a given id
  31732. * @param id defines the id to search for
  31733. * @return the found node or null if not found at all
  31734. */
  31735. getLastEntryByID(id: string): Nullable<Node>;
  31736. /**
  31737. * Gets a node (Mesh, Camera, Light) using a given id
  31738. * @param id defines the id to search for
  31739. * @return the found node or null if not found at all
  31740. */
  31741. getNodeByID(id: string): Nullable<Node>;
  31742. /**
  31743. * Gets a node (Mesh, Camera, Light) using a given name
  31744. * @param name defines the name to search for
  31745. * @return the found node or null if not found at all.
  31746. */
  31747. getNodeByName(name: string): Nullable<Node>;
  31748. /**
  31749. * Gets a mesh using a given name
  31750. * @param name defines the name to search for
  31751. * @return the found mesh or null if not found at all.
  31752. */
  31753. getMeshByName(name: string): Nullable<AbstractMesh>;
  31754. /**
  31755. * Gets a transform node using a given name
  31756. * @param name defines the name to search for
  31757. * @return the found transform node or null if not found at all.
  31758. */
  31759. getTransformNodeByName(name: string): Nullable<TransformNode>;
  31760. /**
  31761. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  31762. * @param id defines the id to search for
  31763. * @return the found skeleton or null if not found at all.
  31764. */
  31765. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  31766. /**
  31767. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  31768. * @param id defines the id to search for
  31769. * @return the found skeleton or null if not found at all.
  31770. */
  31771. getSkeletonById(id: string): Nullable<Skeleton>;
  31772. /**
  31773. * Gets a skeleton using a given name
  31774. * @param name defines the name to search for
  31775. * @return the found skeleton or null if not found at all.
  31776. */
  31777. getSkeletonByName(name: string): Nullable<Skeleton>;
  31778. /**
  31779. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  31780. * @param id defines the id to search for
  31781. * @return the found morph target manager or null if not found at all.
  31782. */
  31783. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  31784. /**
  31785. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  31786. * @param id defines the id to search for
  31787. * @return the found morph target or null if not found at all.
  31788. */
  31789. getMorphTargetById(id: string): Nullable<MorphTarget>;
  31790. /**
  31791. * Gets a boolean indicating if the given mesh is active
  31792. * @param mesh defines the mesh to look for
  31793. * @returns true if the mesh is in the active list
  31794. */
  31795. isActiveMesh(mesh: AbstractMesh): boolean;
  31796. /**
  31797. * Return a unique id as a string which can serve as an identifier for the scene
  31798. */
  31799. readonly uid: string;
  31800. /**
  31801. * Add an externaly attached data from its key.
  31802. * This method call will fail and return false, if such key already exists.
  31803. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31804. * @param key the unique key that identifies the data
  31805. * @param data the data object to associate to the key for this Engine instance
  31806. * @return true if no such key were already present and the data was added successfully, false otherwise
  31807. */
  31808. addExternalData<T>(key: string, data: T): boolean;
  31809. /**
  31810. * Get an externaly attached data from its key
  31811. * @param key the unique key that identifies the data
  31812. * @return the associated data, if present (can be null), or undefined if not present
  31813. */
  31814. getExternalData<T>(key: string): Nullable<T>;
  31815. /**
  31816. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31817. * @param key the unique key that identifies the data
  31818. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31819. * @return the associated data, can be null if the factory returned null.
  31820. */
  31821. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31822. /**
  31823. * Remove an externaly attached data from the Engine instance
  31824. * @param key the unique key that identifies the data
  31825. * @return true if the data was successfully removed, false if it doesn't exist
  31826. */
  31827. removeExternalData(key: string): boolean;
  31828. private _evaluateSubMesh;
  31829. /**
  31830. * Clear the processed materials smart array preventing retention point in material dispose.
  31831. */
  31832. freeProcessedMaterials(): void;
  31833. private _preventFreeActiveMeshesAndRenderingGroups;
  31834. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  31835. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  31836. * when disposing several meshes in a row or a hierarchy of meshes.
  31837. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  31838. */
  31839. blockfreeActiveMeshesAndRenderingGroups: boolean;
  31840. /**
  31841. * Clear the active meshes smart array preventing retention point in mesh dispose.
  31842. */
  31843. freeActiveMeshes(): void;
  31844. /**
  31845. * Clear the info related to rendering groups preventing retention points during dispose.
  31846. */
  31847. freeRenderingGroups(): void;
  31848. /** @hidden */ isInIntermediateRendering(): boolean;
  31849. /**
  31850. * Lambda returning the list of potentially active meshes.
  31851. */
  31852. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  31853. /**
  31854. * Lambda returning the list of potentially active sub meshes.
  31855. */
  31856. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  31857. /**
  31858. * Lambda returning the list of potentially intersecting sub meshes.
  31859. */
  31860. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  31861. /**
  31862. * Lambda returning the list of potentially colliding sub meshes.
  31863. */
  31864. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  31865. private _activeMeshesFrozen;
  31866. /**
  31867. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  31868. * @returns the current scene
  31869. */
  31870. freezeActiveMeshes(): Scene;
  31871. /**
  31872. * Use this function to restart evaluating active meshes on every frame
  31873. * @returns the current scene
  31874. */
  31875. unfreezeActiveMeshes(): Scene;
  31876. private _evaluateActiveMeshes;
  31877. private _activeMesh;
  31878. /**
  31879. * Update the transform matrix to update from the current active camera
  31880. * @param force defines a boolean used to force the update even if cache is up to date
  31881. */
  31882. updateTransformMatrix(force?: boolean): void;
  31883. /**
  31884. * 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)
  31885. * @param alternateCamera defines the camera to use
  31886. */
  31887. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  31888. /** @hidden */ allowPostProcessClearColor: boolean;
  31889. private _renderForCamera;
  31890. private _processSubCameras;
  31891. private _checkIntersections;
  31892. /** @hidden */ advancePhysicsEngineStep(step: number): void;
  31893. /**
  31894. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  31895. */
  31896. getDeterministicFrameTime: () => number;
  31897. /**
  31898. * Render the scene
  31899. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  31900. */
  31901. render(updateCameras?: boolean): void;
  31902. /**
  31903. * Freeze all materials
  31904. * A frozen material will not be updatable but should be faster to render
  31905. */
  31906. freezeMaterials(): void;
  31907. /**
  31908. * Unfreeze all materials
  31909. * A frozen material will not be updatable but should be faster to render
  31910. */
  31911. unfreezeMaterials(): void;
  31912. /**
  31913. * Releases all held ressources
  31914. */
  31915. dispose(): void;
  31916. /**
  31917. * Gets if the scene is already disposed
  31918. */
  31919. readonly isDisposed: boolean;
  31920. /**
  31921. * Call this function to reduce memory footprint of the scene.
  31922. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  31923. */
  31924. clearCachedVertexData(): void;
  31925. /**
  31926. * This function will remove the local cached buffer data from texture.
  31927. * It will save memory but will prevent the texture from being rebuilt
  31928. */
  31929. cleanCachedTextureBuffer(): void;
  31930. /**
  31931. * Get the world extend vectors with an optional filter
  31932. *
  31933. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  31934. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  31935. */
  31936. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  31937. min: Vector3;
  31938. max: Vector3;
  31939. };
  31940. /**
  31941. * Creates a ray that can be used to pick in the scene
  31942. * @param x defines the x coordinate of the origin (on-screen)
  31943. * @param y defines the y coordinate of the origin (on-screen)
  31944. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  31945. * @param camera defines the camera to use for the picking
  31946. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  31947. * @returns a Ray
  31948. */
  31949. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  31950. /**
  31951. * Creates a ray that can be used to pick in the scene
  31952. * @param x defines the x coordinate of the origin (on-screen)
  31953. * @param y defines the y coordinate of the origin (on-screen)
  31954. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  31955. * @param result defines the ray where to store the picking ray
  31956. * @param camera defines the camera to use for the picking
  31957. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  31958. * @returns the current scene
  31959. */
  31960. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  31961. /**
  31962. * Creates a ray that can be used to pick in the scene
  31963. * @param x defines the x coordinate of the origin (on-screen)
  31964. * @param y defines the y coordinate of the origin (on-screen)
  31965. * @param camera defines the camera to use for the picking
  31966. * @returns a Ray
  31967. */
  31968. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  31969. /**
  31970. * Creates a ray that can be used to pick in the scene
  31971. * @param x defines the x coordinate of the origin (on-screen)
  31972. * @param y defines the y coordinate of the origin (on-screen)
  31973. * @param result defines the ray where to store the picking ray
  31974. * @param camera defines the camera to use for the picking
  31975. * @returns the current scene
  31976. */
  31977. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  31978. private _internalPick;
  31979. private _internalMultiPick;
  31980. private _tempPickingRay;
  31981. /** Launch a ray to try to pick a mesh in the scene
  31982. * @param x position on screen
  31983. * @param y position on screen
  31984. * @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
  31985. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  31986. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  31987. * @returns a PickingInfo
  31988. */
  31989. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  31990. private _cachedRayForTransform;
  31991. /** Use the given ray to pick a mesh in the scene
  31992. * @param ray The ray to use to pick meshes
  31993. * @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
  31994. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  31995. * @returns a PickingInfo
  31996. */
  31997. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  31998. /**
  31999. * Launch a ray to try to pick a mesh in the scene
  32000. * @param x X position on screen
  32001. * @param y Y position on screen
  32002. * @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
  32003. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32004. * @returns an array of PickingInfo
  32005. */
  32006. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  32007. /**
  32008. * Launch a ray to try to pick a mesh in the scene
  32009. * @param ray Ray to use
  32010. * @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
  32011. * @returns an array of PickingInfo
  32012. */
  32013. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  32014. /**
  32015. * Force the value of meshUnderPointer
  32016. * @param mesh defines the mesh to use
  32017. */
  32018. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32019. /**
  32020. * Gets the mesh under the pointer
  32021. * @returns a Mesh or null if no mesh is under the pointer
  32022. */
  32023. getPointerOverMesh(): Nullable<AbstractMesh>;
  32024. /** @hidden */ rebuildGeometries(): void;
  32025. /** @hidden */ rebuildTextures(): void;
  32026. private _getByTags;
  32027. /**
  32028. * Get a list of meshes by tags
  32029. * @param tagsQuery defines the tags query to use
  32030. * @param forEach defines a predicate used to filter results
  32031. * @returns an array of Mesh
  32032. */
  32033. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32034. /**
  32035. * Get a list of cameras by tags
  32036. * @param tagsQuery defines the tags query to use
  32037. * @param forEach defines a predicate used to filter results
  32038. * @returns an array of Camera
  32039. */
  32040. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32041. /**
  32042. * Get a list of lights by tags
  32043. * @param tagsQuery defines the tags query to use
  32044. * @param forEach defines a predicate used to filter results
  32045. * @returns an array of Light
  32046. */
  32047. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32048. /**
  32049. * Get a list of materials by tags
  32050. * @param tagsQuery defines the tags query to use
  32051. * @param forEach defines a predicate used to filter results
  32052. * @returns an array of Material
  32053. */
  32054. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32055. /**
  32056. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32057. * This allowed control for front to back rendering or reversly depending of the special needs.
  32058. *
  32059. * @param renderingGroupId The rendering group id corresponding to its index
  32060. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32061. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32062. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32063. */
  32064. 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;
  32065. /**
  32066. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32067. *
  32068. * @param renderingGroupId The rendering group id corresponding to its index
  32069. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32070. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32071. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32072. */
  32073. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32074. /**
  32075. * Gets the current auto clear configuration for one rendering group of the rendering
  32076. * manager.
  32077. * @param index the rendering group index to get the information for
  32078. * @returns The auto clear setup for the requested rendering group
  32079. */
  32080. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32081. private _blockMaterialDirtyMechanism;
  32082. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32083. blockMaterialDirtyMechanism: boolean;
  32084. /**
  32085. * Will flag all materials as dirty to trigger new shader compilation
  32086. * @param flag defines the flag used to specify which material part must be marked as dirty
  32087. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  32088. */
  32089. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32090. /** @hidden */ loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  32091. /** @hidden */ loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32092. }
  32093. }
  32094. declare module BABYLON {
  32095. /**
  32096. * Set of assets to keep when moving a scene into an asset container.
  32097. */
  32098. export class KeepAssets extends AbstractScene {
  32099. }
  32100. /**
  32101. * Container with a set of assets that can be added or removed from a scene.
  32102. */
  32103. export class AssetContainer extends AbstractScene {
  32104. /**
  32105. * The scene the AssetContainer belongs to.
  32106. */
  32107. scene: Scene;
  32108. /**
  32109. * Instantiates an AssetContainer.
  32110. * @param scene The scene the AssetContainer belongs to.
  32111. */
  32112. constructor(scene: Scene);
  32113. /**
  32114. * Adds all the assets from the container to the scene.
  32115. */
  32116. addAllToScene(): void;
  32117. /**
  32118. * Removes all the assets in the container from the scene
  32119. */
  32120. removeAllFromScene(): void;
  32121. /**
  32122. * Disposes all the assets in the container
  32123. */
  32124. dispose(): void;
  32125. private _moveAssets;
  32126. /**
  32127. * Removes all the assets contained in the scene and adds them to the container.
  32128. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  32129. */
  32130. moveAllFromScene(keepAssets?: KeepAssets): void;
  32131. /**
  32132. * 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.
  32133. * @returns the root mesh
  32134. */
  32135. createRootMesh(): Mesh;
  32136. }
  32137. }
  32138. declare module BABYLON {
  32139. /**
  32140. * Defines how the parser contract is defined.
  32141. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  32142. */
  32143. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  32144. /**
  32145. * Defines how the individual parser contract is defined.
  32146. * These parser can parse an individual asset
  32147. */
  32148. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  32149. /**
  32150. * Base class of the scene acting as a container for the different elements composing a scene.
  32151. * This class is dynamically extended by the different components of the scene increasing
  32152. * flexibility and reducing coupling
  32153. */
  32154. export abstract class AbstractScene {
  32155. /**
  32156. * Stores the list of available parsers in the application.
  32157. */
  32158. private static _BabylonFileParsers;
  32159. /**
  32160. * Stores the list of available individual parsers in the application.
  32161. */
  32162. private static _IndividualBabylonFileParsers;
  32163. /**
  32164. * Adds a parser in the list of available ones
  32165. * @param name Defines the name of the parser
  32166. * @param parser Defines the parser to add
  32167. */
  32168. static AddParser(name: string, parser: BabylonFileParser): void;
  32169. /**
  32170. * Gets a general parser from the list of avaialble ones
  32171. * @param name Defines the name of the parser
  32172. * @returns the requested parser or null
  32173. */
  32174. static GetParser(name: string): Nullable<BabylonFileParser>;
  32175. /**
  32176. * Adds n individual parser in the list of available ones
  32177. * @param name Defines the name of the parser
  32178. * @param parser Defines the parser to add
  32179. */
  32180. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  32181. /**
  32182. * Gets an individual parser from the list of avaialble ones
  32183. * @param name Defines the name of the parser
  32184. * @returns the requested parser or null
  32185. */
  32186. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  32187. /**
  32188. * Parser json data and populate both a scene and its associated container object
  32189. * @param jsonData Defines the data to parse
  32190. * @param scene Defines the scene to parse the data for
  32191. * @param container Defines the container attached to the parsing sequence
  32192. * @param rootUrl Defines the root url of the data
  32193. */
  32194. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  32195. /**
  32196. * Gets the list of root nodes (ie. nodes with no parent)
  32197. */
  32198. rootNodes: Node[];
  32199. /** All of the cameras added to this scene
  32200. * @see http://doc.babylonjs.com/babylon101/cameras
  32201. */
  32202. cameras: Camera[];
  32203. /**
  32204. * All of the lights added to this scene
  32205. * @see http://doc.babylonjs.com/babylon101/lights
  32206. */
  32207. lights: Light[];
  32208. /**
  32209. * All of the (abstract) meshes added to this scene
  32210. */
  32211. meshes: AbstractMesh[];
  32212. /**
  32213. * The list of skeletons added to the scene
  32214. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32215. */
  32216. skeletons: Skeleton[];
  32217. /**
  32218. * All of the particle systems added to this scene
  32219. * @see http://doc.babylonjs.com/babylon101/particles
  32220. */
  32221. particleSystems: IParticleSystem[];
  32222. /**
  32223. * Gets a list of Animations associated with the scene
  32224. */
  32225. animations: Animation[];
  32226. /**
  32227. * All of the animation groups added to this scene
  32228. * @see http://doc.babylonjs.com/how_to/group
  32229. */
  32230. animationGroups: AnimationGroup[];
  32231. /**
  32232. * All of the multi-materials added to this scene
  32233. * @see http://doc.babylonjs.com/how_to/multi_materials
  32234. */
  32235. multiMaterials: MultiMaterial[];
  32236. /**
  32237. * All of the materials added to this scene
  32238. * In the context of a Scene, it is not supposed to be modified manually.
  32239. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  32240. * Note also that the order of the Material wihin the array is not significant and might change.
  32241. * @see http://doc.babylonjs.com/babylon101/materials
  32242. */
  32243. materials: Material[];
  32244. /**
  32245. * The list of morph target managers added to the scene
  32246. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  32247. */
  32248. morphTargetManagers: MorphTargetManager[];
  32249. /**
  32250. * The list of geometries used in the scene.
  32251. */
  32252. geometries: Geometry[];
  32253. /**
  32254. * All of the tranform nodes added to this scene
  32255. * In the context of a Scene, it is not supposed to be modified manually.
  32256. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  32257. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  32258. * @see http://doc.babylonjs.com/how_to/transformnode
  32259. */
  32260. transformNodes: TransformNode[];
  32261. /**
  32262. * ActionManagers available on the scene.
  32263. */
  32264. actionManagers: AbstractActionManager[];
  32265. /**
  32266. * Textures to keep.
  32267. */
  32268. textures: BaseTexture[];
  32269. }
  32270. }
  32271. declare module BABYLON {
  32272. /**
  32273. * Defines a sound that can be played in the application.
  32274. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  32275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32276. */
  32277. export class Sound {
  32278. /**
  32279. * The name of the sound in the scene.
  32280. */
  32281. name: string;
  32282. /**
  32283. * Does the sound autoplay once loaded.
  32284. */
  32285. autoplay: boolean;
  32286. /**
  32287. * Does the sound loop after it finishes playing once.
  32288. */
  32289. loop: boolean;
  32290. /**
  32291. * Does the sound use a custom attenuation curve to simulate the falloff
  32292. * happening when the source gets further away from the camera.
  32293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  32294. */
  32295. useCustomAttenuation: boolean;
  32296. /**
  32297. * The sound track id this sound belongs to.
  32298. */
  32299. soundTrackId: number;
  32300. /**
  32301. * Is this sound currently played.
  32302. */
  32303. isPlaying: boolean;
  32304. /**
  32305. * Is this sound currently paused.
  32306. */
  32307. isPaused: boolean;
  32308. /**
  32309. * Does this sound enables spatial sound.
  32310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32311. */
  32312. spatialSound: boolean;
  32313. /**
  32314. * Define the reference distance the sound should be heard perfectly.
  32315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32316. */
  32317. refDistance: number;
  32318. /**
  32319. * Define the roll off factor of spatial sounds.
  32320. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32321. */
  32322. rolloffFactor: number;
  32323. /**
  32324. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  32325. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32326. */
  32327. maxDistance: number;
  32328. /**
  32329. * Define the distance attenuation model the sound will follow.
  32330. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32331. */
  32332. distanceModel: string;
  32333. /**
  32334. * @hidden
  32335. * Back Compat
  32336. **/
  32337. onended: () => any;
  32338. /**
  32339. * Observable event when the current playing sound finishes.
  32340. */
  32341. onEndedObservable: Observable<Sound>;
  32342. private _panningModel;
  32343. private _playbackRate;
  32344. private _streaming;
  32345. private _startTime;
  32346. private _startOffset;
  32347. private _position;
  32348. /** @hidden */ positionInEmitterSpace: boolean;
  32349. private _localDirection;
  32350. private _volume;
  32351. private _isReadyToPlay;
  32352. private _isDirectional;
  32353. private _readyToPlayCallback;
  32354. private _audioBuffer;
  32355. private _soundSource;
  32356. private _streamingSource;
  32357. private _soundPanner;
  32358. private _soundGain;
  32359. private _inputAudioNode;
  32360. private _outputAudioNode;
  32361. private _coneInnerAngle;
  32362. private _coneOuterAngle;
  32363. private _coneOuterGain;
  32364. private _scene;
  32365. private _connectedTransformNode;
  32366. private _customAttenuationFunction;
  32367. private _registerFunc;
  32368. private _isOutputConnected;
  32369. private _htmlAudioElement;
  32370. private _urlType;
  32371. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  32372. /**
  32373. * Create a sound and attach it to a scene
  32374. * @param name Name of your sound
  32375. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  32376. * @param scene defines the scene the sound belongs to
  32377. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  32378. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  32379. */
  32380. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  32381. /**
  32382. * Release the sound and its associated resources
  32383. */
  32384. dispose(): void;
  32385. /**
  32386. * Gets if the sounds is ready to be played or not.
  32387. * @returns true if ready, otherwise false
  32388. */
  32389. isReady(): boolean;
  32390. private _soundLoaded;
  32391. /**
  32392. * Sets the data of the sound from an audiobuffer
  32393. * @param audioBuffer The audioBuffer containing the data
  32394. */
  32395. setAudioBuffer(audioBuffer: AudioBuffer): void;
  32396. /**
  32397. * Updates the current sounds options such as maxdistance, loop...
  32398. * @param options A JSON object containing values named as the object properties
  32399. */
  32400. updateOptions(options: any): void;
  32401. private _createSpatialParameters;
  32402. private _updateSpatialParameters;
  32403. /**
  32404. * Switch the panning model to HRTF:
  32405. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  32406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32407. */
  32408. switchPanningModelToHRTF(): void;
  32409. /**
  32410. * Switch the panning model to Equal Power:
  32411. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  32412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32413. */
  32414. switchPanningModelToEqualPower(): void;
  32415. private _switchPanningModel;
  32416. /**
  32417. * Connect this sound to a sound track audio node like gain...
  32418. * @param soundTrackAudioNode the sound track audio node to connect to
  32419. */
  32420. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  32421. /**
  32422. * Transform this sound into a directional source
  32423. * @param coneInnerAngle Size of the inner cone in degree
  32424. * @param coneOuterAngle Size of the outer cone in degree
  32425. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  32426. */
  32427. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  32428. /**
  32429. * Gets or sets the inner angle for the directional cone.
  32430. */
  32431. /**
  32432. * Gets or sets the inner angle for the directional cone.
  32433. */
  32434. directionalConeInnerAngle: number;
  32435. /**
  32436. * Gets or sets the outer angle for the directional cone.
  32437. */
  32438. /**
  32439. * Gets or sets the outer angle for the directional cone.
  32440. */
  32441. directionalConeOuterAngle: number;
  32442. /**
  32443. * Sets the position of the emitter if spatial sound is enabled
  32444. * @param newPosition Defines the new posisiton
  32445. */
  32446. setPosition(newPosition: Vector3): void;
  32447. /**
  32448. * Sets the local direction of the emitter if spatial sound is enabled
  32449. * @param newLocalDirection Defines the new local direction
  32450. */
  32451. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  32452. private _updateDirection;
  32453. /** @hidden */
  32454. updateDistanceFromListener(): void;
  32455. /**
  32456. * Sets a new custom attenuation function for the sound.
  32457. * @param callback Defines the function used for the attenuation
  32458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  32459. */
  32460. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  32461. /**
  32462. * Play the sound
  32463. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  32464. * @param offset (optional) Start the sound setting it at a specific time
  32465. */
  32466. play(time?: number, offset?: number): void;
  32467. private _onended;
  32468. /**
  32469. * Stop the sound
  32470. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  32471. */
  32472. stop(time?: number): void;
  32473. /**
  32474. * Put the sound in pause
  32475. */
  32476. pause(): void;
  32477. /**
  32478. * Sets a dedicated volume for this sounds
  32479. * @param newVolume Define the new volume of the sound
  32480. * @param time Define in how long the sound should be at this value
  32481. */
  32482. setVolume(newVolume: number, time?: number): void;
  32483. /**
  32484. * Set the sound play back rate
  32485. * @param newPlaybackRate Define the playback rate the sound should be played at
  32486. */
  32487. setPlaybackRate(newPlaybackRate: number): void;
  32488. /**
  32489. * Gets the volume of the sound.
  32490. * @returns the volume of the sound
  32491. */
  32492. getVolume(): number;
  32493. /**
  32494. * Attach the sound to a dedicated mesh
  32495. * @param transformNode The transform node to connect the sound with
  32496. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  32497. */
  32498. attachToMesh(transformNode: TransformNode): void;
  32499. /**
  32500. * Detach the sound from the previously attached mesh
  32501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  32502. */
  32503. detachFromMesh(): void;
  32504. private _onRegisterAfterWorldMatrixUpdate;
  32505. /**
  32506. * Clone the current sound in the scene.
  32507. * @returns the new sound clone
  32508. */
  32509. clone(): Nullable<Sound>;
  32510. /**
  32511. * Gets the current underlying audio buffer containing the data
  32512. * @returns the audio buffer
  32513. */
  32514. getAudioBuffer(): Nullable<AudioBuffer>;
  32515. /**
  32516. * Serializes the Sound in a JSON representation
  32517. * @returns the JSON representation of the sound
  32518. */
  32519. serialize(): any;
  32520. /**
  32521. * Parse a JSON representation of a sound to innstantiate in a given scene
  32522. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  32523. * @param scene Define the scene the new parsed sound should be created in
  32524. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  32525. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  32526. * @returns the newly parsed sound
  32527. */
  32528. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  32529. }
  32530. }
  32531. declare module BABYLON {
  32532. /**
  32533. * This defines an action helpful to play a defined sound on a triggered action.
  32534. */
  32535. export class PlaySoundAction extends Action {
  32536. private _sound;
  32537. /**
  32538. * Instantiate the action
  32539. * @param triggerOptions defines the trigger options
  32540. * @param sound defines the sound to play
  32541. * @param condition defines the trigger related conditions
  32542. */
  32543. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  32544. /** @hidden */ prepare(): void;
  32545. /**
  32546. * Execute the action and play the sound.
  32547. */
  32548. execute(): void;
  32549. /**
  32550. * Serializes the actions and its related information.
  32551. * @param parent defines the object to serialize in
  32552. * @returns the serialized object
  32553. */
  32554. serialize(parent: any): any;
  32555. }
  32556. /**
  32557. * This defines an action helpful to stop a defined sound on a triggered action.
  32558. */
  32559. export class StopSoundAction extends Action {
  32560. private _sound;
  32561. /**
  32562. * Instantiate the action
  32563. * @param triggerOptions defines the trigger options
  32564. * @param sound defines the sound to stop
  32565. * @param condition defines the trigger related conditions
  32566. */
  32567. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  32568. /** @hidden */ prepare(): void;
  32569. /**
  32570. * Execute the action and stop the sound.
  32571. */
  32572. execute(): void;
  32573. /**
  32574. * Serializes the actions and its related information.
  32575. * @param parent defines the object to serialize in
  32576. * @returns the serialized object
  32577. */
  32578. serialize(parent: any): any;
  32579. }
  32580. }
  32581. declare module BABYLON {
  32582. /**
  32583. * This defines an action responsible to change the value of a property
  32584. * by interpolating between its current value and the newly set one once triggered.
  32585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32586. */
  32587. export class InterpolateValueAction extends Action {
  32588. /**
  32589. * Defines the path of the property where the value should be interpolated
  32590. */
  32591. propertyPath: string;
  32592. /**
  32593. * Defines the target value at the end of the interpolation.
  32594. */
  32595. value: any;
  32596. /**
  32597. * Defines the time it will take for the property to interpolate to the value.
  32598. */
  32599. duration: number;
  32600. /**
  32601. * Defines if the other scene animations should be stopped when the action has been triggered
  32602. */
  32603. stopOtherAnimations?: boolean;
  32604. /**
  32605. * Defines a callback raised once the interpolation animation has been done.
  32606. */
  32607. onInterpolationDone?: () => void;
  32608. /**
  32609. * Observable triggered once the interpolation animation has been done.
  32610. */
  32611. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  32612. private _target;
  32613. private _effectiveTarget;
  32614. private _property;
  32615. /**
  32616. * Instantiate the action
  32617. * @param triggerOptions defines the trigger options
  32618. * @param target defines the object containing the value to interpolate
  32619. * @param propertyPath defines the path to the property in the target object
  32620. * @param value defines the target value at the end of the interpolation
  32621. * @param duration deines the time it will take for the property to interpolate to the value.
  32622. * @param condition defines the trigger related conditions
  32623. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  32624. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  32625. */
  32626. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  32627. /** @hidden */ prepare(): void;
  32628. /**
  32629. * Execute the action starts the value interpolation.
  32630. */
  32631. execute(): void;
  32632. /**
  32633. * Serializes the actions and its related information.
  32634. * @param parent defines the object to serialize in
  32635. * @returns the serialized object
  32636. */
  32637. serialize(parent: any): any;
  32638. }
  32639. }
  32640. declare module BABYLON {
  32641. /**
  32642. * Options allowed during the creation of a sound track.
  32643. */
  32644. export interface ISoundTrackOptions {
  32645. /**
  32646. * The volume the sound track should take during creation
  32647. */
  32648. volume?: number;
  32649. /**
  32650. * Define if the sound track is the main sound track of the scene
  32651. */
  32652. mainTrack?: boolean;
  32653. }
  32654. /**
  32655. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  32656. * It will be also used in a future release to apply effects on a specific track.
  32657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  32658. */
  32659. export class SoundTrack {
  32660. /**
  32661. * The unique identifier of the sound track in the scene.
  32662. */
  32663. id: number;
  32664. /**
  32665. * The list of sounds included in the sound track.
  32666. */
  32667. soundCollection: Array<Sound>;
  32668. private _outputAudioNode;
  32669. private _scene;
  32670. private _isMainTrack;
  32671. private _connectedAnalyser;
  32672. private _options;
  32673. private _isInitialized;
  32674. /**
  32675. * Creates a new sound track.
  32676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  32677. * @param scene Define the scene the sound track belongs to
  32678. * @param options
  32679. */
  32680. constructor(scene: Scene, options?: ISoundTrackOptions);
  32681. private _initializeSoundTrackAudioGraph;
  32682. /**
  32683. * Release the sound track and its associated resources
  32684. */
  32685. dispose(): void;
  32686. /**
  32687. * Adds a sound to this sound track
  32688. * @param sound define the cound to add
  32689. * @ignoreNaming
  32690. */
  32691. AddSound(sound: Sound): void;
  32692. /**
  32693. * Removes a sound to this sound track
  32694. * @param sound define the cound to remove
  32695. * @ignoreNaming
  32696. */
  32697. RemoveSound(sound: Sound): void;
  32698. /**
  32699. * Set a global volume for the full sound track.
  32700. * @param newVolume Define the new volume of the sound track
  32701. */
  32702. setVolume(newVolume: number): void;
  32703. /**
  32704. * Switch the panning model to HRTF:
  32705. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  32706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32707. */
  32708. switchPanningModelToHRTF(): void;
  32709. /**
  32710. * Switch the panning model to Equal Power:
  32711. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  32712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32713. */
  32714. switchPanningModelToEqualPower(): void;
  32715. /**
  32716. * Connect the sound track to an audio analyser allowing some amazing
  32717. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32719. * @param analyser The analyser to connect to the engine
  32720. */
  32721. connectToAnalyser(analyser: Analyser): void;
  32722. }
  32723. }
  32724. declare module BABYLON {
  32725. interface AbstractScene {
  32726. /**
  32727. * The list of sounds used in the scene.
  32728. */
  32729. sounds: Nullable<Array<Sound>>;
  32730. }
  32731. interface Scene {
  32732. /**
  32733. * @hidden
  32734. * Backing field
  32735. */ mainSoundTrack: SoundTrack;
  32736. /**
  32737. * The main sound track played by the scene.
  32738. * It cotains your primary collection of sounds.
  32739. */
  32740. mainSoundTrack: SoundTrack;
  32741. /**
  32742. * The list of sound tracks added to the scene
  32743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32744. */
  32745. soundTracks: Nullable<Array<SoundTrack>>;
  32746. /**
  32747. * Gets a sound using a given name
  32748. * @param name defines the name to search for
  32749. * @return the found sound or null if not found at all.
  32750. */
  32751. getSoundByName(name: string): Nullable<Sound>;
  32752. /**
  32753. * Gets or sets if audio support is enabled
  32754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32755. */
  32756. audioEnabled: boolean;
  32757. /**
  32758. * Gets or sets if audio will be output to headphones
  32759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32760. */
  32761. headphone: boolean;
  32762. }
  32763. /**
  32764. * Defines the sound scene component responsible to manage any sounds
  32765. * in a given scene.
  32766. */
  32767. export class AudioSceneComponent implements ISceneSerializableComponent {
  32768. /**
  32769. * The component name helpfull to identify the component in the list of scene components.
  32770. */
  32771. readonly name: string;
  32772. /**
  32773. * The scene the component belongs to.
  32774. */
  32775. scene: Scene;
  32776. private _audioEnabled;
  32777. /**
  32778. * Gets whether audio is enabled or not.
  32779. * Please use related enable/disable method to switch state.
  32780. */
  32781. readonly audioEnabled: boolean;
  32782. private _headphone;
  32783. /**
  32784. * Gets whether audio is outputing to headphone or not.
  32785. * Please use the according Switch methods to change output.
  32786. */
  32787. readonly headphone: boolean;
  32788. /**
  32789. * Creates a new instance of the component for the given scene
  32790. * @param scene Defines the scene to register the component in
  32791. */
  32792. constructor(scene: Scene);
  32793. /**
  32794. * Registers the component in a given scene
  32795. */
  32796. register(): void;
  32797. /**
  32798. * Rebuilds the elements related to this component in case of
  32799. * context lost for instance.
  32800. */
  32801. rebuild(): void;
  32802. /**
  32803. * Serializes the component data to the specified json object
  32804. * @param serializationObject The object to serialize to
  32805. */
  32806. serialize(serializationObject: any): void;
  32807. /**
  32808. * Adds all the element from the container to the scene
  32809. * @param container the container holding the elements
  32810. */
  32811. addFromContainer(container: AbstractScene): void;
  32812. /**
  32813. * Removes all the elements in the container from the scene
  32814. * @param container contains the elements to remove
  32815. */
  32816. removeFromContainer(container: AbstractScene): void;
  32817. /**
  32818. * Disposes the component and the associated ressources.
  32819. */
  32820. dispose(): void;
  32821. /**
  32822. * Disables audio in the associated scene.
  32823. */
  32824. disableAudio(): void;
  32825. /**
  32826. * Enables audio in the associated scene.
  32827. */
  32828. enableAudio(): void;
  32829. /**
  32830. * Switch audio to headphone output.
  32831. */
  32832. switchAudioModeForHeadphones(): void;
  32833. /**
  32834. * Switch audio to normal speakers.
  32835. */
  32836. switchAudioModeForNormalSpeakers(): void;
  32837. private _afterRender;
  32838. }
  32839. }
  32840. declare module BABYLON {
  32841. /**
  32842. * Wraps one or more Sound objects and selects one with random weight for playback.
  32843. */
  32844. export class WeightedSound {
  32845. /** When true a Sound will be selected and played when the current playing Sound completes. */
  32846. loop: boolean;
  32847. private _coneInnerAngle;
  32848. private _coneOuterAngle;
  32849. private _volume;
  32850. /** A Sound is currently playing. */
  32851. isPlaying: boolean;
  32852. /** A Sound is currently paused. */
  32853. isPaused: boolean;
  32854. private _sounds;
  32855. private _weights;
  32856. private _currentIndex?;
  32857. /**
  32858. * Creates a new WeightedSound from the list of sounds given.
  32859. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  32860. * @param sounds Array of Sounds that will be selected from.
  32861. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  32862. */
  32863. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  32864. /**
  32865. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  32866. */
  32867. /**
  32868. * The size of cone in degress for a directional sound in which there will be no attenuation.
  32869. */
  32870. directionalConeInnerAngle: number;
  32871. /**
  32872. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  32873. * Listener angles between innerAngle and outerAngle will falloff linearly.
  32874. */
  32875. /**
  32876. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  32877. * Listener angles between innerAngle and outerAngle will falloff linearly.
  32878. */
  32879. directionalConeOuterAngle: number;
  32880. /**
  32881. * Playback volume.
  32882. */
  32883. /**
  32884. * Playback volume.
  32885. */
  32886. volume: number;
  32887. private _onended;
  32888. /**
  32889. * Suspend playback
  32890. */
  32891. pause(): void;
  32892. /**
  32893. * Stop playback
  32894. */
  32895. stop(): void;
  32896. /**
  32897. * Start playback.
  32898. * @param startOffset Position the clip head at a specific time in seconds.
  32899. */
  32900. play(startOffset?: number): void;
  32901. }
  32902. }
  32903. declare module BABYLON {
  32904. /**
  32905. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  32906. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  32907. */
  32908. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  32909. /**
  32910. * Gets the name of the behavior.
  32911. */
  32912. readonly name: string;
  32913. /**
  32914. * The easing function used by animations
  32915. */
  32916. static EasingFunction: BackEase;
  32917. /**
  32918. * The easing mode used by animations
  32919. */
  32920. static EasingMode: number;
  32921. /**
  32922. * The duration of the animation, in milliseconds
  32923. */
  32924. transitionDuration: number;
  32925. /**
  32926. * Length of the distance animated by the transition when lower radius is reached
  32927. */
  32928. lowerRadiusTransitionRange: number;
  32929. /**
  32930. * Length of the distance animated by the transition when upper radius is reached
  32931. */
  32932. upperRadiusTransitionRange: number;
  32933. private _autoTransitionRange;
  32934. /**
  32935. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32936. */
  32937. /**
  32938. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32939. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  32940. */
  32941. autoTransitionRange: boolean;
  32942. private _attachedCamera;
  32943. private _onAfterCheckInputsObserver;
  32944. private _onMeshTargetChangedObserver;
  32945. /**
  32946. * Initializes the behavior.
  32947. */
  32948. init(): void;
  32949. /**
  32950. * Attaches the behavior to its arc rotate camera.
  32951. * @param camera Defines the camera to attach the behavior to
  32952. */
  32953. attach(camera: ArcRotateCamera): void;
  32954. /**
  32955. * Detaches the behavior from its current arc rotate camera.
  32956. */
  32957. detach(): void;
  32958. private _radiusIsAnimating;
  32959. private _radiusBounceTransition;
  32960. private _animatables;
  32961. private _cachedWheelPrecision;
  32962. /**
  32963. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  32964. * @param radiusLimit The limit to check against.
  32965. * @return Bool to indicate if at limit.
  32966. */
  32967. private _isRadiusAtLimit;
  32968. /**
  32969. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  32970. * @param radiusDelta The delta by which to animate to. Can be negative.
  32971. */
  32972. private _applyBoundRadiusAnimation;
  32973. /**
  32974. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  32975. */
  32976. protected _clearAnimationLocks(): void;
  32977. /**
  32978. * Stops and removes all animations that have been applied to the camera
  32979. */
  32980. stopAllAnimations(): void;
  32981. }
  32982. }
  32983. declare module BABYLON {
  32984. /**
  32985. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  32986. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  32987. */
  32988. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  32989. /**
  32990. * Gets the name of the behavior.
  32991. */
  32992. readonly name: string;
  32993. private _mode;
  32994. private _radiusScale;
  32995. private _positionScale;
  32996. private _defaultElevation;
  32997. private _elevationReturnTime;
  32998. private _elevationReturnWaitTime;
  32999. private _zoomStopsAnimation;
  33000. private _framingTime;
  33001. /**
  33002. * The easing function used by animations
  33003. */
  33004. static EasingFunction: ExponentialEase;
  33005. /**
  33006. * The easing mode used by animations
  33007. */
  33008. static EasingMode: number;
  33009. /**
  33010. * Sets the current mode used by the behavior
  33011. */
  33012. /**
  33013. * Gets current mode used by the behavior.
  33014. */
  33015. mode: number;
  33016. /**
  33017. * Sets the scale applied to the radius (1 by default)
  33018. */
  33019. /**
  33020. * Gets the scale applied to the radius
  33021. */
  33022. radiusScale: number;
  33023. /**
  33024. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33025. */
  33026. /**
  33027. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33028. */
  33029. positionScale: number;
  33030. /**
  33031. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33032. * behaviour is triggered, in radians.
  33033. */
  33034. /**
  33035. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33036. * behaviour is triggered, in radians.
  33037. */
  33038. defaultElevation: number;
  33039. /**
  33040. * Sets the time (in milliseconds) taken to return to the default beta position.
  33041. * Negative value indicates camera should not return to default.
  33042. */
  33043. /**
  33044. * Gets the time (in milliseconds) taken to return to the default beta position.
  33045. * Negative value indicates camera should not return to default.
  33046. */
  33047. elevationReturnTime: number;
  33048. /**
  33049. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33050. */
  33051. /**
  33052. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33053. */
  33054. elevationReturnWaitTime: number;
  33055. /**
  33056. * Sets the flag that indicates if user zooming should stop animation.
  33057. */
  33058. /**
  33059. * Gets the flag that indicates if user zooming should stop animation.
  33060. */
  33061. zoomStopsAnimation: boolean;
  33062. /**
  33063. * Sets the transition time when framing the mesh, in milliseconds
  33064. */
  33065. /**
  33066. * Gets the transition time when framing the mesh, in milliseconds
  33067. */
  33068. framingTime: number;
  33069. /**
  33070. * Define if the behavior should automatically change the configured
  33071. * camera limits and sensibilities.
  33072. */
  33073. autoCorrectCameraLimitsAndSensibility: boolean;
  33074. private _onPrePointerObservableObserver;
  33075. private _onAfterCheckInputsObserver;
  33076. private _onMeshTargetChangedObserver;
  33077. private _attachedCamera;
  33078. private _isPointerDown;
  33079. private _lastInteractionTime;
  33080. /**
  33081. * Initializes the behavior.
  33082. */
  33083. init(): void;
  33084. /**
  33085. * Attaches the behavior to its arc rotate camera.
  33086. * @param camera Defines the camera to attach the behavior to
  33087. */
  33088. attach(camera: ArcRotateCamera): void;
  33089. /**
  33090. * Detaches the behavior from its current arc rotate camera.
  33091. */
  33092. detach(): void;
  33093. private _animatables;
  33094. private _betaIsAnimating;
  33095. private _betaTransition;
  33096. private _radiusTransition;
  33097. private _vectorTransition;
  33098. /**
  33099. * Targets the given mesh and updates zoom level accordingly.
  33100. * @param mesh The mesh to target.
  33101. * @param radius Optional. If a cached radius position already exists, overrides default.
  33102. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33103. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33104. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33105. */
  33106. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33107. /**
  33108. * Targets the given mesh with its children and updates zoom level accordingly.
  33109. * @param mesh The mesh to target.
  33110. * @param radius Optional. If a cached radius position already exists, overrides default.
  33111. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33112. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33113. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33114. */
  33115. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33116. /**
  33117. * Targets the given meshes with their children and updates zoom level accordingly.
  33118. * @param meshes The mesh to target.
  33119. * @param radius Optional. If a cached radius position already exists, overrides default.
  33120. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33121. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33122. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33123. */
  33124. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33125. /**
  33126. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  33127. * @param minimumWorld Determines the smaller position of the bounding box extend
  33128. * @param maximumWorld Determines the bigger position of the bounding box extend
  33129. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33130. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33131. */
  33132. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33133. /**
  33134. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33135. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33136. * frustum width.
  33137. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33138. * to fully enclose the mesh in the viewing frustum.
  33139. */
  33140. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33141. /**
  33142. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33143. * is automatically returned to its default position (expected to be above ground plane).
  33144. */
  33145. private _maintainCameraAboveGround;
  33146. /**
  33147. * Returns the frustum slope based on the canvas ratio and camera FOV
  33148. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33149. */
  33150. private _getFrustumSlope;
  33151. /**
  33152. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33153. */
  33154. private _clearAnimationLocks;
  33155. /**
  33156. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33157. */
  33158. private _applyUserInteraction;
  33159. /**
  33160. * Stops and removes all animations that have been applied to the camera
  33161. */
  33162. stopAllAnimations(): void;
  33163. /**
  33164. * Gets a value indicating if the user is moving the camera
  33165. */
  33166. readonly isUserIsMoving: boolean;
  33167. /**
  33168. * The camera can move all the way towards the mesh.
  33169. */
  33170. static IgnoreBoundsSizeMode: number;
  33171. /**
  33172. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33173. */
  33174. static FitFrustumSidesMode: number;
  33175. }
  33176. }
  33177. declare module BABYLON {
  33178. /**
  33179. * Manage the pointers inputs to control an arc rotate camera.
  33180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33181. */
  33182. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  33183. /**
  33184. * Defines the camera the input is attached to.
  33185. */
  33186. camera: ArcRotateCamera;
  33187. /**
  33188. * Defines the buttons associated with the input to handle camera move.
  33189. */
  33190. buttons: number[];
  33191. /**
  33192. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  33193. */
  33194. angularSensibilityX: number;
  33195. /**
  33196. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  33197. */
  33198. angularSensibilityY: number;
  33199. /**
  33200. * Defines the pointer pinch precision or how fast is the camera zooming.
  33201. */
  33202. pinchPrecision: number;
  33203. /**
  33204. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  33205. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33206. */
  33207. pinchDeltaPercentage: number;
  33208. /**
  33209. * Defines the pointer panning sensibility or how fast is the camera moving.
  33210. */
  33211. panningSensibility: number;
  33212. /**
  33213. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  33214. */
  33215. multiTouchPanning: boolean;
  33216. /**
  33217. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  33218. */
  33219. multiTouchPanAndZoom: boolean;
  33220. /**
  33221. * Revers pinch action direction.
  33222. */
  33223. pinchInwards: boolean;
  33224. private _isPanClick;
  33225. private _pointerInput;
  33226. private _observer;
  33227. private _onMouseMove;
  33228. private _onGestureStart;
  33229. private _onGesture;
  33230. private _MSGestureHandler;
  33231. private _onLostFocus;
  33232. private _onContextMenu;
  33233. /**
  33234. * Attach the input controls to a specific dom element to get the input from.
  33235. * @param element Defines the element the controls should be listened from
  33236. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33237. */
  33238. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33239. /**
  33240. * Detach the current controls from the specified dom element.
  33241. * @param element Defines the element to stop listening the inputs from
  33242. */
  33243. detachControl(element: Nullable<HTMLElement>): void;
  33244. /**
  33245. * Gets the class name of the current intput.
  33246. * @returns the class name
  33247. */
  33248. getClassName(): string;
  33249. /**
  33250. * Get the friendly name associated with the input class.
  33251. * @returns the input friendly name
  33252. */
  33253. getSimpleName(): string;
  33254. }
  33255. }
  33256. declare module BABYLON {
  33257. /**
  33258. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  33259. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33260. */
  33261. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  33262. /**
  33263. * Defines the camera the input is attached to.
  33264. */
  33265. camera: ArcRotateCamera;
  33266. /**
  33267. * Defines the list of key codes associated with the up action (increase alpha)
  33268. */
  33269. keysUp: number[];
  33270. /**
  33271. * Defines the list of key codes associated with the down action (decrease alpha)
  33272. */
  33273. keysDown: number[];
  33274. /**
  33275. * Defines the list of key codes associated with the left action (increase beta)
  33276. */
  33277. keysLeft: number[];
  33278. /**
  33279. * Defines the list of key codes associated with the right action (decrease beta)
  33280. */
  33281. keysRight: number[];
  33282. /**
  33283. * Defines the list of key codes associated with the reset action.
  33284. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  33285. */
  33286. keysReset: number[];
  33287. /**
  33288. * Defines the panning sensibility of the inputs.
  33289. * (How fast is the camera paning)
  33290. */
  33291. panningSensibility: number;
  33292. /**
  33293. * Defines the zooming sensibility of the inputs.
  33294. * (How fast is the camera zooming)
  33295. */
  33296. zoomingSensibility: number;
  33297. /**
  33298. * Defines wether maintaining the alt key down switch the movement mode from
  33299. * orientation to zoom.
  33300. */
  33301. useAltToZoom: boolean;
  33302. /**
  33303. * Rotation speed of the camera
  33304. */
  33305. angularSpeed: number;
  33306. private _keys;
  33307. private _ctrlPressed;
  33308. private _altPressed;
  33309. private _onCanvasBlurObserver;
  33310. private _onKeyboardObserver;
  33311. private _engine;
  33312. private _scene;
  33313. /**
  33314. * Attach the input controls to a specific dom element to get the input from.
  33315. * @param element Defines the element the controls should be listened from
  33316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33317. */
  33318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33319. /**
  33320. * Detach the current controls from the specified dom element.
  33321. * @param element Defines the element to stop listening the inputs from
  33322. */
  33323. detachControl(element: Nullable<HTMLElement>): void;
  33324. /**
  33325. * Update the current camera state depending on the inputs that have been used this frame.
  33326. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  33327. */
  33328. checkInputs(): void;
  33329. /**
  33330. * Gets the class name of the current intput.
  33331. * @returns the class name
  33332. */
  33333. getClassName(): string;
  33334. /**
  33335. * Get the friendly name associated with the input class.
  33336. * @returns the input friendly name
  33337. */
  33338. getSimpleName(): string;
  33339. }
  33340. }
  33341. declare module BABYLON {
  33342. /**
  33343. * Manage the mouse wheel inputs to control an arc rotate camera.
  33344. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33345. */
  33346. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  33347. /**
  33348. * Defines the camera the input is attached to.
  33349. */
  33350. camera: ArcRotateCamera;
  33351. /**
  33352. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  33353. */
  33354. wheelPrecision: number;
  33355. /**
  33356. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  33357. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  33358. */
  33359. wheelDeltaPercentage: number;
  33360. private _wheel;
  33361. private _observer;
  33362. /**
  33363. * Attach the input controls to a specific dom element to get the input from.
  33364. * @param element Defines the element the controls should be listened from
  33365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33366. */
  33367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33368. /**
  33369. * Detach the current controls from the specified dom element.
  33370. * @param element Defines the element to stop listening the inputs from
  33371. */
  33372. detachControl(element: Nullable<HTMLElement>): void;
  33373. /**
  33374. * Gets the class name of the current intput.
  33375. * @returns the class name
  33376. */
  33377. getClassName(): string;
  33378. /**
  33379. * Get the friendly name associated with the input class.
  33380. * @returns the input friendly name
  33381. */
  33382. getSimpleName(): string;
  33383. }
  33384. }
  33385. declare module BABYLON {
  33386. /**
  33387. * Default Inputs manager for the ArcRotateCamera.
  33388. * It groups all the default supported inputs for ease of use.
  33389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33390. */
  33391. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  33392. /**
  33393. * Instantiates a new ArcRotateCameraInputsManager.
  33394. * @param camera Defines the camera the inputs belong to
  33395. */
  33396. constructor(camera: ArcRotateCamera);
  33397. /**
  33398. * Add mouse wheel input support to the input manager.
  33399. * @returns the current input manager
  33400. */
  33401. addMouseWheel(): ArcRotateCameraInputsManager;
  33402. /**
  33403. * Add pointers input support to the input manager.
  33404. * @returns the current input manager
  33405. */
  33406. addPointers(): ArcRotateCameraInputsManager;
  33407. /**
  33408. * Add keyboard input support to the input manager.
  33409. * @returns the current input manager
  33410. */
  33411. addKeyboard(): ArcRotateCameraInputsManager;
  33412. }
  33413. }
  33414. declare module BABYLON {
  33415. /**
  33416. * This represents an orbital type of camera.
  33417. *
  33418. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  33419. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  33420. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  33421. */
  33422. export class ArcRotateCamera extends TargetCamera {
  33423. /**
  33424. * Defines the rotation angle of the camera along the longitudinal axis.
  33425. */
  33426. alpha: number;
  33427. /**
  33428. * Defines the rotation angle of the camera along the latitudinal axis.
  33429. */
  33430. beta: number;
  33431. /**
  33432. * Defines the radius of the camera from it s target point.
  33433. */
  33434. radius: number;
  33435. protected _target: Vector3;
  33436. protected _targetHost: Nullable<AbstractMesh>;
  33437. /**
  33438. * Defines the target point of the camera.
  33439. * The camera looks towards it form the radius distance.
  33440. */
  33441. target: Vector3;
  33442. /**
  33443. * Current inertia value on the longitudinal axis.
  33444. * The bigger this number the longer it will take for the camera to stop.
  33445. */
  33446. inertialAlphaOffset: number;
  33447. /**
  33448. * Current inertia value on the latitudinal axis.
  33449. * The bigger this number the longer it will take for the camera to stop.
  33450. */
  33451. inertialBetaOffset: number;
  33452. /**
  33453. * Current inertia value on the radius axis.
  33454. * The bigger this number the longer it will take for the camera to stop.
  33455. */
  33456. inertialRadiusOffset: number;
  33457. /**
  33458. * Minimum allowed angle on the longitudinal axis.
  33459. * This can help limiting how the Camera is able to move in the scene.
  33460. */
  33461. lowerAlphaLimit: Nullable<number>;
  33462. /**
  33463. * Maximum allowed angle on the longitudinal axis.
  33464. * This can help limiting how the Camera is able to move in the scene.
  33465. */
  33466. upperAlphaLimit: Nullable<number>;
  33467. /**
  33468. * Minimum allowed angle on the latitudinal axis.
  33469. * This can help limiting how the Camera is able to move in the scene.
  33470. */
  33471. lowerBetaLimit: number;
  33472. /**
  33473. * Maximum allowed angle on the latitudinal axis.
  33474. * This can help limiting how the Camera is able to move in the scene.
  33475. */
  33476. upperBetaLimit: number;
  33477. /**
  33478. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  33479. * This can help limiting how the Camera is able to move in the scene.
  33480. */
  33481. lowerRadiusLimit: Nullable<number>;
  33482. /**
  33483. * Maximum allowed distance of the camera to the target (The camera can not get further).
  33484. * This can help limiting how the Camera is able to move in the scene.
  33485. */
  33486. upperRadiusLimit: Nullable<number>;
  33487. /**
  33488. * Defines the current inertia value used during panning of the camera along the X axis.
  33489. */
  33490. inertialPanningX: number;
  33491. /**
  33492. * Defines the current inertia value used during panning of the camera along the Y axis.
  33493. */
  33494. inertialPanningY: number;
  33495. /**
  33496. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  33497. * Basically if your fingers moves away from more than this distance you will be considered
  33498. * in pinch mode.
  33499. */
  33500. pinchToPanMaxDistance: number;
  33501. /**
  33502. * Defines the maximum distance the camera can pan.
  33503. * This could help keeping the cammera always in your scene.
  33504. */
  33505. panningDistanceLimit: Nullable<number>;
  33506. /**
  33507. * Defines the target of the camera before paning.
  33508. */
  33509. panningOriginTarget: Vector3;
  33510. /**
  33511. * Defines the value of the inertia used during panning.
  33512. * 0 would mean stop inertia and one would mean no decelleration at all.
  33513. */
  33514. panningInertia: number;
  33515. /**
  33516. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  33517. */
  33518. angularSensibilityX: number;
  33519. /**
  33520. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  33521. */
  33522. angularSensibilityY: number;
  33523. /**
  33524. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  33525. */
  33526. pinchPrecision: number;
  33527. /**
  33528. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  33529. * It will be used instead of pinchDeltaPrecision if different from 0.
  33530. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33531. */
  33532. pinchDeltaPercentage: number;
  33533. /**
  33534. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  33535. */
  33536. panningSensibility: number;
  33537. /**
  33538. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  33539. */
  33540. keysUp: number[];
  33541. /**
  33542. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  33543. */
  33544. keysDown: number[];
  33545. /**
  33546. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  33547. */
  33548. keysLeft: number[];
  33549. /**
  33550. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  33551. */
  33552. keysRight: number[];
  33553. /**
  33554. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  33555. */
  33556. wheelPrecision: number;
  33557. /**
  33558. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  33559. * It will be used instead of pinchDeltaPrecision if different from 0.
  33560. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33561. */
  33562. wheelDeltaPercentage: number;
  33563. /**
  33564. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  33565. */
  33566. zoomOnFactor: number;
  33567. /**
  33568. * Defines a screen offset for the camera position.
  33569. */
  33570. targetScreenOffset: Vector2;
  33571. /**
  33572. * Allows the camera to be completely reversed.
  33573. * If false the camera can not arrive upside down.
  33574. */
  33575. allowUpsideDown: boolean;
  33576. /**
  33577. * Define if double tap/click is used to restore the previously saved state of the camera.
  33578. */
  33579. useInputToRestoreState: boolean;
  33580. /** @hidden */ viewMatrix: Matrix;
  33581. /** @hidden */ useCtrlForPanning: boolean;
  33582. /** @hidden */ panningMouseButton: number;
  33583. /**
  33584. * Defines the input associated to the camera.
  33585. */
  33586. inputs: ArcRotateCameraInputsManager;
  33587. /** @hidden */ reset: () => void;
  33588. /**
  33589. * Defines the allowed panning axis.
  33590. */
  33591. panningAxis: Vector3;
  33592. protected _localDirection: Vector3;
  33593. protected _transformedDirection: Vector3;
  33594. private _bouncingBehavior;
  33595. /**
  33596. * Gets the bouncing behavior of the camera if it has been enabled.
  33597. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33598. */
  33599. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  33600. /**
  33601. * Defines if the bouncing behavior of the camera is enabled on the camera.
  33602. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33603. */
  33604. useBouncingBehavior: boolean;
  33605. private _framingBehavior;
  33606. /**
  33607. * Gets the framing behavior of the camera if it has been enabled.
  33608. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33609. */
  33610. readonly framingBehavior: Nullable<FramingBehavior>;
  33611. /**
  33612. * Defines if the framing behavior of the camera is enabled on the camera.
  33613. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33614. */
  33615. useFramingBehavior: boolean;
  33616. private _autoRotationBehavior;
  33617. /**
  33618. * Gets the auto rotation behavior of the camera if it has been enabled.
  33619. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  33620. */
  33621. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  33622. /**
  33623. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  33624. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  33625. */
  33626. useAutoRotationBehavior: boolean;
  33627. /**
  33628. * Observable triggered when the mesh target has been changed on the camera.
  33629. */
  33630. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  33631. /**
  33632. * Event raised when the camera is colliding with a mesh.
  33633. */
  33634. onCollide: (collidedMesh: AbstractMesh) => void;
  33635. /**
  33636. * Defines whether the camera should check collision with the objects oh the scene.
  33637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  33638. */
  33639. checkCollisions: boolean;
  33640. /**
  33641. * Defines the collision radius of the camera.
  33642. * This simulates a sphere around the camera.
  33643. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  33644. */
  33645. collisionRadius: Vector3;
  33646. protected _collider: Collider;
  33647. protected _previousPosition: Vector3;
  33648. protected _collisionVelocity: Vector3;
  33649. protected _newPosition: Vector3;
  33650. protected _previousAlpha: number;
  33651. protected _previousBeta: number;
  33652. protected _previousRadius: number;
  33653. protected _collisionTriggered: boolean;
  33654. protected _targetBoundingCenter: Nullable<Vector3>;
  33655. private _computationVector;
  33656. private _tempAxisVector;
  33657. private _tempAxisRotationMatrix;
  33658. /**
  33659. * Instantiates a new ArcRotateCamera in a given scene
  33660. * @param name Defines the name of the camera
  33661. * @param alpha Defines the camera rotation along the logitudinal axis
  33662. * @param beta Defines the camera rotation along the latitudinal axis
  33663. * @param radius Defines the camera distance from its target
  33664. * @param target Defines the camera target
  33665. * @param scene Defines the scene the camera belongs to
  33666. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  33667. */
  33668. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  33669. /** @hidden */ initCache(): void;
  33670. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  33671. protected _getTargetPosition(): Vector3;
  33672. private _storedAlpha;
  33673. private _storedBeta;
  33674. private _storedRadius;
  33675. private _storedTarget;
  33676. /**
  33677. * Stores the current state of the camera (alpha, beta, radius and target)
  33678. * @returns the camera itself
  33679. */
  33680. storeState(): Camera;
  33681. /**
  33682. * @hidden
  33683. * Restored camera state. You must call storeState() first
  33684. */ restoreStateValues(): boolean;
  33685. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  33686. /**
  33687. * Attached controls to the current camera.
  33688. * @param element Defines the element the controls should be listened from
  33689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33690. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  33691. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  33692. */
  33693. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  33694. /**
  33695. * Detach the current controls from the camera.
  33696. * The camera will stop reacting to inputs.
  33697. * @param element Defines the element to stop listening the inputs from
  33698. */
  33699. detachControl(element: HTMLElement): void;
  33700. /** @hidden */ checkInputs(): void;
  33701. protected _checkLimits(): void;
  33702. /**
  33703. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  33704. */
  33705. rebuildAnglesAndRadius(): void;
  33706. /**
  33707. * Use a position to define the current camera related information like aplha, beta and radius
  33708. * @param position Defines the position to set the camera at
  33709. */
  33710. setPosition(position: Vector3): void;
  33711. /**
  33712. * Defines the target the camera should look at.
  33713. * This will automatically adapt alpha beta and radius to fit within the new target.
  33714. * @param target Defines the new target as a Vector or a mesh
  33715. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  33716. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  33717. */
  33718. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  33719. /** @hidden */ getViewMatrix(): Matrix;
  33720. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  33721. /**
  33722. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  33723. * @param meshes Defines the mesh to zoom on
  33724. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  33725. */
  33726. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  33727. /**
  33728. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  33729. * The target will be changed but the radius
  33730. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  33731. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  33732. */
  33733. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  33734. min: Vector3;
  33735. max: Vector3;
  33736. distance: number;
  33737. }, doNotUpdateMaxZ?: boolean): void;
  33738. /**
  33739. * @override
  33740. * Override Camera.createRigCamera
  33741. */
  33742. createRigCamera(name: string, cameraIndex: number): Camera;
  33743. /**
  33744. * @hidden
  33745. * @override
  33746. * Override Camera._updateRigCameras
  33747. */ updateRigCameras(): void;
  33748. /**
  33749. * Destroy the camera and release the current resources hold by it.
  33750. */
  33751. dispose(): void;
  33752. /**
  33753. * Gets the current object class name.
  33754. * @return the class name
  33755. */
  33756. getClassName(): string;
  33757. }
  33758. }
  33759. declare module BABYLON {
  33760. /**
  33761. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  33762. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  33763. */
  33764. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  33765. /**
  33766. * Gets the name of the behavior.
  33767. */
  33768. readonly name: string;
  33769. private _zoomStopsAnimation;
  33770. private _idleRotationSpeed;
  33771. private _idleRotationWaitTime;
  33772. private _idleRotationSpinupTime;
  33773. /**
  33774. * Sets the flag that indicates if user zooming should stop animation.
  33775. */
  33776. /**
  33777. * Gets the flag that indicates if user zooming should stop animation.
  33778. */
  33779. zoomStopsAnimation: boolean;
  33780. /**
  33781. * Sets the default speed at which the camera rotates around the model.
  33782. */
  33783. /**
  33784. * Gets the default speed at which the camera rotates around the model.
  33785. */
  33786. idleRotationSpeed: number;
  33787. /**
  33788. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  33789. */
  33790. /**
  33791. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  33792. */
  33793. idleRotationWaitTime: number;
  33794. /**
  33795. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  33796. */
  33797. /**
  33798. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  33799. */
  33800. idleRotationSpinupTime: number;
  33801. /**
  33802. * Gets a value indicating if the camera is currently rotating because of this behavior
  33803. */
  33804. readonly rotationInProgress: boolean;
  33805. private _onPrePointerObservableObserver;
  33806. private _onAfterCheckInputsObserver;
  33807. private _attachedCamera;
  33808. private _isPointerDown;
  33809. private _lastFrameTime;
  33810. private _lastInteractionTime;
  33811. private _cameraRotationSpeed;
  33812. /**
  33813. * Initializes the behavior.
  33814. */
  33815. init(): void;
  33816. /**
  33817. * Attaches the behavior to its arc rotate camera.
  33818. * @param camera Defines the camera to attach the behavior to
  33819. */
  33820. attach(camera: ArcRotateCamera): void;
  33821. /**
  33822. * Detaches the behavior from its current arc rotate camera.
  33823. */
  33824. detach(): void;
  33825. /**
  33826. * Returns true if user is scrolling.
  33827. * @return true if user is scrolling.
  33828. */
  33829. private _userIsZooming;
  33830. private _lastFrameRadius;
  33831. private _shouldAnimationStopForInteraction;
  33832. /**
  33833. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33834. */
  33835. private _applyUserInteraction;
  33836. private _userIsMoving;
  33837. }
  33838. }
  33839. declare module BABYLON {
  33840. /**
  33841. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  33842. */
  33843. export class AttachToBoxBehavior implements Behavior<Mesh> {
  33844. private ui;
  33845. /**
  33846. * The name of the behavior
  33847. */
  33848. name: string;
  33849. /**
  33850. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  33851. */
  33852. distanceAwayFromFace: number;
  33853. /**
  33854. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  33855. */
  33856. distanceAwayFromBottomOfFace: number;
  33857. private _faceVectors;
  33858. private _target;
  33859. private _scene;
  33860. private _onRenderObserver;
  33861. private _tmpMatrix;
  33862. private _tmpVector;
  33863. /**
  33864. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  33865. * @param ui The transform node that should be attched to the mesh
  33866. */
  33867. constructor(ui: TransformNode);
  33868. /**
  33869. * Initializes the behavior
  33870. */
  33871. init(): void;
  33872. private _closestFace;
  33873. private _zeroVector;
  33874. private _lookAtTmpMatrix;
  33875. private _lookAtToRef;
  33876. /**
  33877. * Attaches the AttachToBoxBehavior to the passed in mesh
  33878. * @param target The mesh that the specified node will be attached to
  33879. */
  33880. attach(target: Mesh): void;
  33881. /**
  33882. * Detaches the behavior from the mesh
  33883. */
  33884. detach(): void;
  33885. }
  33886. }
  33887. declare module BABYLON {
  33888. /**
  33889. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  33890. */
  33891. export class FadeInOutBehavior implements Behavior<Mesh> {
  33892. /**
  33893. * Time in milliseconds to delay before fading in (Default: 0)
  33894. */
  33895. delay: number;
  33896. /**
  33897. * Time in milliseconds for the mesh to fade in (Default: 300)
  33898. */
  33899. fadeInTime: number;
  33900. private _millisecondsPerFrame;
  33901. private _hovered;
  33902. private _hoverValue;
  33903. private _ownerNode;
  33904. /**
  33905. * Instatiates the FadeInOutBehavior
  33906. */
  33907. constructor();
  33908. /**
  33909. * The name of the behavior
  33910. */
  33911. readonly name: string;
  33912. /**
  33913. * Initializes the behavior
  33914. */
  33915. init(): void;
  33916. /**
  33917. * Attaches the fade behavior on the passed in mesh
  33918. * @param ownerNode The mesh that will be faded in/out once attached
  33919. */
  33920. attach(ownerNode: Mesh): void;
  33921. /**
  33922. * Detaches the behavior from the mesh
  33923. */
  33924. detach(): void;
  33925. /**
  33926. * Triggers the mesh to begin fading in or out
  33927. * @param value if the object should fade in or out (true to fade in)
  33928. */
  33929. fadeIn(value: boolean): void;
  33930. private _update;
  33931. private _setAllVisibility;
  33932. }
  33933. }
  33934. declare module BABYLON {
  33935. /**
  33936. * Class containing a set of static utilities functions for managing Pivots
  33937. * @hidden
  33938. */
  33939. export class PivotTools {
  33940. private static _PivotCached;
  33941. private static _OldPivotPoint;
  33942. private static _PivotTranslation;
  33943. private static _PivotTmpVector;
  33944. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  33945. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  33946. }
  33947. }
  33948. declare module BABYLON {
  33949. /**
  33950. * Class containing static functions to help procedurally build meshes
  33951. */
  33952. export class PlaneBuilder {
  33953. /**
  33954. * Creates a plane mesh
  33955. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  33956. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  33957. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  33958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  33959. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  33960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33961. * @param name defines the name of the mesh
  33962. * @param options defines the options used to create the mesh
  33963. * @param scene defines the hosting scene
  33964. * @returns the plane mesh
  33965. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  33966. */
  33967. static CreatePlane(name: string, options: {
  33968. size?: number;
  33969. width?: number;
  33970. height?: number;
  33971. sideOrientation?: number;
  33972. frontUVs?: Vector4;
  33973. backUVs?: Vector4;
  33974. updatable?: boolean;
  33975. sourcePlane?: Plane;
  33976. }, scene: Scene): Mesh;
  33977. }
  33978. }
  33979. declare module BABYLON {
  33980. /**
  33981. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  33982. */
  33983. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  33984. private static _AnyMouseID;
  33985. private _attachedNode;
  33986. private _dragPlane;
  33987. private _scene;
  33988. private _pointerObserver;
  33989. private _beforeRenderObserver;
  33990. private static _planeScene;
  33991. /**
  33992. * 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)
  33993. */
  33994. maxDragAngle: number;
  33995. /**
  33996. * @hidden
  33997. */ useAlternatePickedPointAboveMaxDragAngle: boolean;
  33998. /**
  33999. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34000. */
  34001. currentDraggingPointerID: number;
  34002. /**
  34003. * The last position where the pointer hit the drag plane in world space
  34004. */
  34005. lastDragPosition: Vector3;
  34006. /**
  34007. * If the behavior is currently in a dragging state
  34008. */
  34009. dragging: boolean;
  34010. /**
  34011. * 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)
  34012. */
  34013. dragDeltaRatio: number;
  34014. /**
  34015. * If the drag plane orientation should be updated during the dragging (Default: true)
  34016. */
  34017. updateDragPlane: boolean;
  34018. private _debugMode;
  34019. private _moving;
  34020. /**
  34021. * Fires each time the attached mesh is dragged with the pointer
  34022. * * delta between last drag position and current drag position in world space
  34023. * * dragDistance along the drag axis
  34024. * * dragPlaneNormal normal of the current drag plane used during the drag
  34025. * * dragPlanePoint in world space where the drag intersects the drag plane
  34026. */
  34027. onDragObservable: Observable<{
  34028. delta: Vector3;
  34029. dragPlanePoint: Vector3;
  34030. dragPlaneNormal: Vector3;
  34031. dragDistance: number;
  34032. pointerId: number;
  34033. }>;
  34034. /**
  34035. * Fires each time a drag begins (eg. mouse down on mesh)
  34036. */
  34037. onDragStartObservable: Observable<{
  34038. dragPlanePoint: Vector3;
  34039. pointerId: number;
  34040. }>;
  34041. /**
  34042. * Fires each time a drag ends (eg. mouse release after drag)
  34043. */
  34044. onDragEndObservable: Observable<{
  34045. dragPlanePoint: Vector3;
  34046. pointerId: number;
  34047. }>;
  34048. /**
  34049. * If the attached mesh should be moved when dragged
  34050. */
  34051. moveAttached: boolean;
  34052. /**
  34053. * If the drag behavior will react to drag events (Default: true)
  34054. */
  34055. enabled: boolean;
  34056. /**
  34057. * If camera controls should be detached during the drag
  34058. */
  34059. detachCameraControls: boolean;
  34060. /**
  34061. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  34062. */
  34063. useObjectOrienationForDragging: boolean;
  34064. private _options;
  34065. /**
  34066. * Creates a pointer drag behavior that can be attached to a mesh
  34067. * @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)
  34068. */
  34069. constructor(options?: {
  34070. dragAxis?: Vector3;
  34071. dragPlaneNormal?: Vector3;
  34072. });
  34073. /**
  34074. * Predicate to determine if it is valid to move the object to a new position when it is moved
  34075. */
  34076. validateDrag: (targetPosition: Vector3) => boolean;
  34077. /**
  34078. * The name of the behavior
  34079. */
  34080. readonly name: string;
  34081. /**
  34082. * Initializes the behavior
  34083. */
  34084. init(): void;
  34085. private _tmpVector;
  34086. private _alternatePickedPoint;
  34087. private _worldDragAxis;
  34088. private _targetPosition;
  34089. private _attachedElement;
  34090. /**
  34091. * Attaches the drag behavior the passed in mesh
  34092. * @param ownerNode The mesh that will be dragged around once attached
  34093. */
  34094. attach(ownerNode: AbstractMesh): void;
  34095. /**
  34096. * Force relase the drag action by code.
  34097. */
  34098. releaseDrag(): void;
  34099. private _startDragRay;
  34100. private _lastPointerRay;
  34101. /**
  34102. * Simulates the start of a pointer drag event on the behavior
  34103. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  34104. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  34105. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  34106. */
  34107. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  34108. private _startDrag;
  34109. private _dragDelta;
  34110. private _moveDrag;
  34111. private _pickWithRayOnDragPlane;
  34112. private _pointA;
  34113. private _pointB;
  34114. private _pointC;
  34115. private _lineA;
  34116. private _lineB;
  34117. private _localAxis;
  34118. private _lookAt;
  34119. private _updateDragPlanePosition;
  34120. /**
  34121. * Detaches the behavior from the mesh
  34122. */
  34123. detach(): void;
  34124. }
  34125. }
  34126. declare module BABYLON {
  34127. /**
  34128. * A behavior that when attached to a mesh will allow the mesh to be scaled
  34129. */
  34130. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  34131. private _dragBehaviorA;
  34132. private _dragBehaviorB;
  34133. private _startDistance;
  34134. private _initialScale;
  34135. private _targetScale;
  34136. private _ownerNode;
  34137. private _sceneRenderObserver;
  34138. /**
  34139. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  34140. */
  34141. constructor();
  34142. /**
  34143. * The name of the behavior
  34144. */
  34145. readonly name: string;
  34146. /**
  34147. * Initializes the behavior
  34148. */
  34149. init(): void;
  34150. private _getCurrentDistance;
  34151. /**
  34152. * Attaches the scale behavior the passed in mesh
  34153. * @param ownerNode The mesh that will be scaled around once attached
  34154. */
  34155. attach(ownerNode: Mesh): void;
  34156. /**
  34157. * Detaches the behavior from the mesh
  34158. */
  34159. detach(): void;
  34160. }
  34161. }
  34162. declare module BABYLON {
  34163. /**
  34164. * 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
  34165. */
  34166. export class SixDofDragBehavior implements Behavior<Mesh> {
  34167. private static _virtualScene;
  34168. private _ownerNode;
  34169. private _sceneRenderObserver;
  34170. private _scene;
  34171. private _targetPosition;
  34172. private _virtualOriginMesh;
  34173. private _virtualDragMesh;
  34174. private _pointerObserver;
  34175. private _moving;
  34176. private _startingOrientation;
  34177. /**
  34178. * 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)
  34179. */
  34180. private zDragFactor;
  34181. /**
  34182. * If the object should rotate to face the drag origin
  34183. */
  34184. rotateDraggedObject: boolean;
  34185. /**
  34186. * If the behavior is currently in a dragging state
  34187. */
  34188. dragging: boolean;
  34189. /**
  34190. * 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)
  34191. */
  34192. dragDeltaRatio: number;
  34193. /**
  34194. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34195. */
  34196. currentDraggingPointerID: number;
  34197. /**
  34198. * If camera controls should be detached during the drag
  34199. */
  34200. detachCameraControls: boolean;
  34201. /**
  34202. * Fires each time a drag starts
  34203. */
  34204. onDragStartObservable: Observable<{}>;
  34205. /**
  34206. * Fires each time a drag ends (eg. mouse release after drag)
  34207. */
  34208. onDragEndObservable: Observable<{}>;
  34209. /**
  34210. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  34211. */
  34212. constructor();
  34213. /**
  34214. * The name of the behavior
  34215. */
  34216. readonly name: string;
  34217. /**
  34218. * Initializes the behavior
  34219. */
  34220. init(): void;
  34221. /**
  34222. * Attaches the scale behavior the passed in mesh
  34223. * @param ownerNode The mesh that will be scaled around once attached
  34224. */
  34225. attach(ownerNode: Mesh): void;
  34226. /**
  34227. * Detaches the behavior from the mesh
  34228. */
  34229. detach(): void;
  34230. }
  34231. }
  34232. declare module BABYLON {
  34233. /**
  34234. * Class used to apply inverse kinematics to bones
  34235. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  34236. */
  34237. export class BoneIKController {
  34238. private static _tmpVecs;
  34239. private static _tmpQuat;
  34240. private static _tmpMats;
  34241. /**
  34242. * Gets or sets the target mesh
  34243. */
  34244. targetMesh: AbstractMesh;
  34245. /** Gets or sets the mesh used as pole */
  34246. poleTargetMesh: AbstractMesh;
  34247. /**
  34248. * Gets or sets the bone used as pole
  34249. */
  34250. poleTargetBone: Nullable<Bone>;
  34251. /**
  34252. * Gets or sets the target position
  34253. */
  34254. targetPosition: Vector3;
  34255. /**
  34256. * Gets or sets the pole target position
  34257. */
  34258. poleTargetPosition: Vector3;
  34259. /**
  34260. * Gets or sets the pole target local offset
  34261. */
  34262. poleTargetLocalOffset: Vector3;
  34263. /**
  34264. * Gets or sets the pole angle
  34265. */
  34266. poleAngle: number;
  34267. /**
  34268. * Gets or sets the mesh associated with the controller
  34269. */
  34270. mesh: AbstractMesh;
  34271. /**
  34272. * 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)
  34273. */
  34274. slerpAmount: number;
  34275. private _bone1Quat;
  34276. private _bone1Mat;
  34277. private _bone2Ang;
  34278. private _bone1;
  34279. private _bone2;
  34280. private _bone1Length;
  34281. private _bone2Length;
  34282. private _maxAngle;
  34283. private _maxReach;
  34284. private _rightHandedSystem;
  34285. private _bendAxis;
  34286. private _slerping;
  34287. private _adjustRoll;
  34288. /**
  34289. * Gets or sets maximum allowed angle
  34290. */
  34291. maxAngle: number;
  34292. /**
  34293. * Creates a new BoneIKController
  34294. * @param mesh defines the mesh to control
  34295. * @param bone defines the bone to control
  34296. * @param options defines options to set up the controller
  34297. */
  34298. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  34299. targetMesh?: AbstractMesh;
  34300. poleTargetMesh?: AbstractMesh;
  34301. poleTargetBone?: Bone;
  34302. poleTargetLocalOffset?: Vector3;
  34303. poleAngle?: number;
  34304. bendAxis?: Vector3;
  34305. maxAngle?: number;
  34306. slerpAmount?: number;
  34307. });
  34308. private _setMaxAngle;
  34309. /**
  34310. * Force the controller to update the bones
  34311. */
  34312. update(): void;
  34313. }
  34314. }
  34315. declare module BABYLON {
  34316. /**
  34317. * Class used to make a bone look toward a point in space
  34318. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  34319. */
  34320. export class BoneLookController {
  34321. private static _tmpVecs;
  34322. private static _tmpQuat;
  34323. private static _tmpMats;
  34324. /**
  34325. * The target Vector3 that the bone will look at
  34326. */
  34327. target: Vector3;
  34328. /**
  34329. * The mesh that the bone is attached to
  34330. */
  34331. mesh: AbstractMesh;
  34332. /**
  34333. * The bone that will be looking to the target
  34334. */
  34335. bone: Bone;
  34336. /**
  34337. * The up axis of the coordinate system that is used when the bone is rotated
  34338. */
  34339. upAxis: Vector3;
  34340. /**
  34341. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  34342. */
  34343. upAxisSpace: Space;
  34344. /**
  34345. * Used to make an adjustment to the yaw of the bone
  34346. */
  34347. adjustYaw: number;
  34348. /**
  34349. * Used to make an adjustment to the pitch of the bone
  34350. */
  34351. adjustPitch: number;
  34352. /**
  34353. * Used to make an adjustment to the roll of the bone
  34354. */
  34355. adjustRoll: number;
  34356. /**
  34357. * 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)
  34358. */
  34359. slerpAmount: number;
  34360. private _minYaw;
  34361. private _maxYaw;
  34362. private _minPitch;
  34363. private _maxPitch;
  34364. private _minYawSin;
  34365. private _minYawCos;
  34366. private _maxYawSin;
  34367. private _maxYawCos;
  34368. private _midYawConstraint;
  34369. private _minPitchTan;
  34370. private _maxPitchTan;
  34371. private _boneQuat;
  34372. private _slerping;
  34373. private _transformYawPitch;
  34374. private _transformYawPitchInv;
  34375. private _firstFrameSkipped;
  34376. private _yawRange;
  34377. private _fowardAxis;
  34378. /**
  34379. * Gets or sets the minimum yaw angle that the bone can look to
  34380. */
  34381. minYaw: number;
  34382. /**
  34383. * Gets or sets the maximum yaw angle that the bone can look to
  34384. */
  34385. maxYaw: number;
  34386. /**
  34387. * Gets or sets the minimum pitch angle that the bone can look to
  34388. */
  34389. minPitch: number;
  34390. /**
  34391. * Gets or sets the maximum pitch angle that the bone can look to
  34392. */
  34393. maxPitch: number;
  34394. /**
  34395. * Create a BoneLookController
  34396. * @param mesh the mesh that the bone belongs to
  34397. * @param bone the bone that will be looking to the target
  34398. * @param target the target Vector3 to look at
  34399. * @param options optional settings:
  34400. * * maxYaw: the maximum angle the bone will yaw to
  34401. * * minYaw: the minimum angle the bone will yaw to
  34402. * * maxPitch: the maximum angle the bone will pitch to
  34403. * * minPitch: the minimum angle the bone will yaw to
  34404. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  34405. * * upAxis: the up axis of the coordinate system
  34406. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  34407. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  34408. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  34409. * * adjustYaw: used to make an adjustment to the yaw of the bone
  34410. * * adjustPitch: used to make an adjustment to the pitch of the bone
  34411. * * adjustRoll: used to make an adjustment to the roll of the bone
  34412. **/
  34413. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  34414. maxYaw?: number;
  34415. minYaw?: number;
  34416. maxPitch?: number;
  34417. minPitch?: number;
  34418. slerpAmount?: number;
  34419. upAxis?: Vector3;
  34420. upAxisSpace?: Space;
  34421. yawAxis?: Vector3;
  34422. pitchAxis?: Vector3;
  34423. adjustYaw?: number;
  34424. adjustPitch?: number;
  34425. adjustRoll?: number;
  34426. });
  34427. /**
  34428. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  34429. */
  34430. update(): void;
  34431. private _getAngleDiff;
  34432. private _getAngleBetween;
  34433. private _isAngleBetween;
  34434. }
  34435. }
  34436. declare module BABYLON {
  34437. /**
  34438. * Manage the gamepad inputs to control an arc rotate camera.
  34439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34440. */
  34441. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  34442. /**
  34443. * Defines the camera the input is attached to.
  34444. */
  34445. camera: ArcRotateCamera;
  34446. /**
  34447. * Defines the gamepad the input is gathering event from.
  34448. */
  34449. gamepad: Nullable<Gamepad>;
  34450. /**
  34451. * Defines the gamepad rotation sensiblity.
  34452. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  34453. */
  34454. gamepadRotationSensibility: number;
  34455. /**
  34456. * Defines the gamepad move sensiblity.
  34457. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  34458. */
  34459. gamepadMoveSensibility: number;
  34460. private _onGamepadConnectedObserver;
  34461. private _onGamepadDisconnectedObserver;
  34462. /**
  34463. * Attach the input controls to a specific dom element to get the input from.
  34464. * @param element Defines the element the controls should be listened from
  34465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34466. */
  34467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34468. /**
  34469. * Detach the current controls from the specified dom element.
  34470. * @param element Defines the element to stop listening the inputs from
  34471. */
  34472. detachControl(element: Nullable<HTMLElement>): void;
  34473. /**
  34474. * Update the current camera state depending on the inputs that have been used this frame.
  34475. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34476. */
  34477. checkInputs(): void;
  34478. /**
  34479. * Gets the class name of the current intput.
  34480. * @returns the class name
  34481. */
  34482. getClassName(): string;
  34483. /**
  34484. * Get the friendly name associated with the input class.
  34485. * @returns the input friendly name
  34486. */
  34487. getSimpleName(): string;
  34488. }
  34489. }
  34490. declare module BABYLON {
  34491. interface ArcRotateCameraInputsManager {
  34492. /**
  34493. * Add orientation input support to the input manager.
  34494. * @returns the current input manager
  34495. */
  34496. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  34497. }
  34498. /**
  34499. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  34500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34501. */
  34502. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  34503. /**
  34504. * Defines the camera the input is attached to.
  34505. */
  34506. camera: ArcRotateCamera;
  34507. /**
  34508. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  34509. */
  34510. alphaCorrection: number;
  34511. /**
  34512. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  34513. */
  34514. gammaCorrection: number;
  34515. private _alpha;
  34516. private _gamma;
  34517. private _dirty;
  34518. private _deviceOrientationHandler;
  34519. /**
  34520. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  34521. */
  34522. constructor();
  34523. /**
  34524. * Attach the input controls to a specific dom element to get the input from.
  34525. * @param element Defines the element the controls should be listened from
  34526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34527. */
  34528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34529. /** @hidden */ onOrientationEvent(evt: DeviceOrientationEvent): void;
  34530. /**
  34531. * Update the current camera state depending on the inputs that have been used this frame.
  34532. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34533. */
  34534. checkInputs(): void;
  34535. /**
  34536. * Detach the current controls from the specified dom element.
  34537. * @param element Defines the element to stop listening the inputs from
  34538. */
  34539. detachControl(element: Nullable<HTMLElement>): void;
  34540. /**
  34541. * Gets the class name of the current intput.
  34542. * @returns the class name
  34543. */
  34544. getClassName(): string;
  34545. /**
  34546. * Get the friendly name associated with the input class.
  34547. * @returns the input friendly name
  34548. */
  34549. getSimpleName(): string;
  34550. }
  34551. }
  34552. declare module BABYLON {
  34553. /**
  34554. * Listen to mouse events to control the camera.
  34555. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34556. */
  34557. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  34558. /**
  34559. * Defines the camera the input is attached to.
  34560. */
  34561. camera: FlyCamera;
  34562. /**
  34563. * Defines if touch is enabled. (Default is true.)
  34564. */
  34565. touchEnabled: boolean;
  34566. /**
  34567. * Defines the buttons associated with the input to handle camera rotation.
  34568. */
  34569. buttons: number[];
  34570. /**
  34571. * Assign buttons for Yaw control.
  34572. */
  34573. buttonsYaw: number[];
  34574. /**
  34575. * Assign buttons for Pitch control.
  34576. */
  34577. buttonsPitch: number[];
  34578. /**
  34579. * Assign buttons for Roll control.
  34580. */
  34581. buttonsRoll: number[];
  34582. /**
  34583. * Detect if any button is being pressed while mouse is moved.
  34584. * -1 = Mouse locked.
  34585. * 0 = Left button.
  34586. * 1 = Middle Button.
  34587. * 2 = Right Button.
  34588. */
  34589. activeButton: number;
  34590. /**
  34591. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  34592. * Higher values reduce its sensitivity.
  34593. */
  34594. angularSensibility: number;
  34595. private _mousemoveCallback;
  34596. private _observer;
  34597. private _rollObserver;
  34598. private previousPosition;
  34599. private noPreventDefault;
  34600. private element;
  34601. /**
  34602. * Listen to mouse events to control the camera.
  34603. * @param touchEnabled Define if touch is enabled. (Default is true.)
  34604. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34605. */
  34606. constructor(touchEnabled?: boolean);
  34607. /**
  34608. * Attach the mouse control to the HTML DOM element.
  34609. * @param element Defines the element that listens to the input events.
  34610. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  34611. */
  34612. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34613. /**
  34614. * Detach the current controls from the specified dom element.
  34615. * @param element Defines the element to stop listening the inputs from
  34616. */
  34617. detachControl(element: Nullable<HTMLElement>): void;
  34618. /**
  34619. * Gets the class name of the current input.
  34620. * @returns the class name.
  34621. */
  34622. getClassName(): string;
  34623. /**
  34624. * Get the friendly name associated with the input class.
  34625. * @returns the input's friendly name.
  34626. */
  34627. getSimpleName(): string;
  34628. private _pointerInput;
  34629. private _onMouseMove;
  34630. /**
  34631. * Rotate camera by mouse offset.
  34632. */
  34633. private rotateCamera;
  34634. }
  34635. }
  34636. declare module BABYLON {
  34637. /**
  34638. * Default Inputs manager for the FlyCamera.
  34639. * It groups all the default supported inputs for ease of use.
  34640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34641. */
  34642. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  34643. /**
  34644. * Instantiates a new FlyCameraInputsManager.
  34645. * @param camera Defines the camera the inputs belong to.
  34646. */
  34647. constructor(camera: FlyCamera);
  34648. /**
  34649. * Add keyboard input support to the input manager.
  34650. * @returns the new FlyCameraKeyboardMoveInput().
  34651. */
  34652. addKeyboard(): FlyCameraInputsManager;
  34653. /**
  34654. * Add mouse input support to the input manager.
  34655. * @param touchEnabled Enable touch screen support.
  34656. * @returns the new FlyCameraMouseInput().
  34657. */
  34658. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  34659. }
  34660. }
  34661. declare module BABYLON {
  34662. /**
  34663. * This is a flying camera, designed for 3D movement and rotation in all directions,
  34664. * such as in a 3D Space Shooter or a Flight Simulator.
  34665. */
  34666. export class FlyCamera extends TargetCamera {
  34667. /**
  34668. * Define the collision ellipsoid of the camera.
  34669. * This is helpful for simulating a camera body, like a player's body.
  34670. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34671. */
  34672. ellipsoid: Vector3;
  34673. /**
  34674. * Define an offset for the position of the ellipsoid around the camera.
  34675. * This can be helpful if the camera is attached away from the player's body center,
  34676. * such as at its head.
  34677. */
  34678. ellipsoidOffset: Vector3;
  34679. /**
  34680. * Enable or disable collisions of the camera with the rest of the scene objects.
  34681. */
  34682. checkCollisions: boolean;
  34683. /**
  34684. * Enable or disable gravity on the camera.
  34685. */
  34686. applyGravity: boolean;
  34687. /**
  34688. * Define the current direction the camera is moving to.
  34689. */
  34690. cameraDirection: Vector3;
  34691. /**
  34692. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  34693. * This overrides and empties cameraRotation.
  34694. */
  34695. rotationQuaternion: Quaternion;
  34696. /**
  34697. * Track Roll to maintain the wanted Rolling when looking around.
  34698. */ trackRoll: number;
  34699. /**
  34700. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  34701. */
  34702. rollCorrect: number;
  34703. /**
  34704. * Mimic a banked turn, Rolling the camera when Yawing.
  34705. * It's recommended to use rollCorrect = 10 for faster banking correction.
  34706. */
  34707. bankedTurn: boolean;
  34708. /**
  34709. * Limit in radians for how much Roll banking will add. (Default: 90°)
  34710. */
  34711. bankedTurnLimit: number;
  34712. /**
  34713. * Value of 0 disables the banked Roll.
  34714. * Value of 1 is equal to the Yaw angle in radians.
  34715. */
  34716. bankedTurnMultiplier: number;
  34717. /**
  34718. * The inputs manager loads all the input sources, such as keyboard and mouse.
  34719. */
  34720. inputs: FlyCameraInputsManager;
  34721. /**
  34722. * Gets the input sensibility for mouse input.
  34723. * Higher values reduce sensitivity.
  34724. */
  34725. /**
  34726. * Sets the input sensibility for a mouse input.
  34727. * Higher values reduce sensitivity.
  34728. */
  34729. angularSensibility: number;
  34730. /**
  34731. * Get the keys for camera movement forward.
  34732. */
  34733. /**
  34734. * Set the keys for camera movement forward.
  34735. */
  34736. keysForward: number[];
  34737. /**
  34738. * Get the keys for camera movement backward.
  34739. */
  34740. keysBackward: number[];
  34741. /**
  34742. * Get the keys for camera movement up.
  34743. */
  34744. /**
  34745. * Set the keys for camera movement up.
  34746. */
  34747. keysUp: number[];
  34748. /**
  34749. * Get the keys for camera movement down.
  34750. */
  34751. /**
  34752. * Set the keys for camera movement down.
  34753. */
  34754. keysDown: number[];
  34755. /**
  34756. * Get the keys for camera movement left.
  34757. */
  34758. /**
  34759. * Set the keys for camera movement left.
  34760. */
  34761. keysLeft: number[];
  34762. /**
  34763. * Set the keys for camera movement right.
  34764. */
  34765. /**
  34766. * Set the keys for camera movement right.
  34767. */
  34768. keysRight: number[];
  34769. /**
  34770. * Event raised when the camera collides with a mesh in the scene.
  34771. */
  34772. onCollide: (collidedMesh: AbstractMesh) => void;
  34773. private _collider;
  34774. private _needMoveForGravity;
  34775. private _oldPosition;
  34776. private _diffPosition;
  34777. private _newPosition;
  34778. /** @hidden */ localDirection: Vector3;
  34779. /** @hidden */ transformedDirection: Vector3;
  34780. /**
  34781. * Instantiates a FlyCamera.
  34782. * This is a flying camera, designed for 3D movement and rotation in all directions,
  34783. * such as in a 3D Space Shooter or a Flight Simulator.
  34784. * @param name Define the name of the camera in the scene.
  34785. * @param position Define the starting position of the camera in the scene.
  34786. * @param scene Define the scene the camera belongs to.
  34787. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  34788. */
  34789. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34790. /**
  34791. * Attach a control to the HTML DOM element.
  34792. * @param element Defines the element that listens to the input events.
  34793. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  34794. */
  34795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34796. /**
  34797. * Detach a control from the HTML DOM element.
  34798. * The camera will stop reacting to that input.
  34799. * @param element Defines the element that listens to the input events.
  34800. */
  34801. detachControl(element: HTMLElement): void;
  34802. private _collisionMask;
  34803. /**
  34804. * Get the mask that the camera ignores in collision events.
  34805. */
  34806. /**
  34807. * Set the mask that the camera ignores in collision events.
  34808. */
  34809. collisionMask: number;
  34810. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  34811. /** @hidden */
  34812. private _onCollisionPositionChange;
  34813. /** @hidden */ checkInputs(): void;
  34814. /** @hidden */ decideIfNeedsToMove(): boolean;
  34815. /** @hidden */ updatePosition(): void;
  34816. /**
  34817. * Restore the Roll to its target value at the rate specified.
  34818. * @param rate - Higher means slower restoring.
  34819. * @hidden
  34820. */
  34821. restoreRoll(rate: number): void;
  34822. /**
  34823. * Destroy the camera and release the current resources held by it.
  34824. */
  34825. dispose(): void;
  34826. /**
  34827. * Get the current object class name.
  34828. * @returns the class name.
  34829. */
  34830. getClassName(): string;
  34831. }
  34832. }
  34833. declare module BABYLON {
  34834. /**
  34835. * Listen to keyboard events to control the camera.
  34836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34837. */
  34838. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  34839. /**
  34840. * Defines the camera the input is attached to.
  34841. */
  34842. camera: FlyCamera;
  34843. /**
  34844. * The list of keyboard keys used to control the forward move of the camera.
  34845. */
  34846. keysForward: number[];
  34847. /**
  34848. * The list of keyboard keys used to control the backward move of the camera.
  34849. */
  34850. keysBackward: number[];
  34851. /**
  34852. * The list of keyboard keys used to control the forward move of the camera.
  34853. */
  34854. keysUp: number[];
  34855. /**
  34856. * The list of keyboard keys used to control the backward move of the camera.
  34857. */
  34858. keysDown: number[];
  34859. /**
  34860. * The list of keyboard keys used to control the right strafe move of the camera.
  34861. */
  34862. keysRight: number[];
  34863. /**
  34864. * The list of keyboard keys used to control the left strafe move of the camera.
  34865. */
  34866. keysLeft: number[];
  34867. private _keys;
  34868. private _onCanvasBlurObserver;
  34869. private _onKeyboardObserver;
  34870. private _engine;
  34871. private _scene;
  34872. /**
  34873. * Attach the input controls to a specific dom element to get the input from.
  34874. * @param element Defines the element the controls should be listened from
  34875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34876. */
  34877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34878. /**
  34879. * Detach the current controls from the specified dom element.
  34880. * @param element Defines the element to stop listening the inputs from
  34881. */
  34882. detachControl(element: Nullable<HTMLElement>): void;
  34883. /**
  34884. * Gets the class name of the current intput.
  34885. * @returns the class name
  34886. */
  34887. getClassName(): string;
  34888. /** @hidden */ onLostFocus(e: FocusEvent): void;
  34889. /**
  34890. * Get the friendly name associated with the input class.
  34891. * @returns the input friendly name
  34892. */
  34893. getSimpleName(): string;
  34894. /**
  34895. * Update the current camera state depending on the inputs that have been used this frame.
  34896. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34897. */
  34898. checkInputs(): void;
  34899. }
  34900. }
  34901. declare module BABYLON {
  34902. interface FreeCameraInputsManager {
  34903. /**
  34904. * Add orientation input support to the input manager.
  34905. * @returns the current input manager
  34906. */
  34907. addDeviceOrientation(): FreeCameraInputsManager;
  34908. }
  34909. /**
  34910. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  34911. * Screen rotation is taken into account.
  34912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34913. */
  34914. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  34915. private _camera;
  34916. private _screenOrientationAngle;
  34917. private _constantTranform;
  34918. private _screenQuaternion;
  34919. private _alpha;
  34920. private _beta;
  34921. private _gamma;
  34922. /**
  34923. * Instantiates a new input
  34924. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34925. */
  34926. constructor();
  34927. /**
  34928. * Define the camera controlled by the input.
  34929. */
  34930. camera: FreeCamera;
  34931. /**
  34932. * Attach the input controls to a specific dom element to get the input from.
  34933. * @param element Defines the element the controls should be listened from
  34934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34935. */
  34936. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34937. private _orientationChanged;
  34938. private _deviceOrientation;
  34939. /**
  34940. * Detach the current controls from the specified dom element.
  34941. * @param element Defines the element to stop listening the inputs from
  34942. */
  34943. detachControl(element: Nullable<HTMLElement>): void;
  34944. /**
  34945. * Update the current camera state depending on the inputs that have been used this frame.
  34946. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34947. */
  34948. checkInputs(): void;
  34949. /**
  34950. * Gets the class name of the current intput.
  34951. * @returns the class name
  34952. */
  34953. getClassName(): string;
  34954. /**
  34955. * Get the friendly name associated with the input class.
  34956. * @returns the input friendly name
  34957. */
  34958. getSimpleName(): string;
  34959. }
  34960. }
  34961. declare module BABYLON {
  34962. /**
  34963. * Manage the gamepad inputs to control a free camera.
  34964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34965. */
  34966. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  34967. /**
  34968. * Define the camera the input is attached to.
  34969. */
  34970. camera: FreeCamera;
  34971. /**
  34972. * Define the Gamepad controlling the input
  34973. */
  34974. gamepad: Nullable<Gamepad>;
  34975. /**
  34976. * Defines the gamepad rotation sensiblity.
  34977. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  34978. */
  34979. gamepadAngularSensibility: number;
  34980. /**
  34981. * Defines the gamepad move sensiblity.
  34982. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  34983. */
  34984. gamepadMoveSensibility: number;
  34985. private _onGamepadConnectedObserver;
  34986. private _onGamepadDisconnectedObserver;
  34987. private _cameraTransform;
  34988. private _deltaTransform;
  34989. private _vector3;
  34990. private _vector2;
  34991. /**
  34992. * Attach the input controls to a specific dom element to get the input from.
  34993. * @param element Defines the element the controls should be listened from
  34994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34995. */
  34996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34997. /**
  34998. * Detach the current controls from the specified dom element.
  34999. * @param element Defines the element to stop listening the inputs from
  35000. */
  35001. detachControl(element: Nullable<HTMLElement>): void;
  35002. /**
  35003. * Update the current camera state depending on the inputs that have been used this frame.
  35004. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35005. */
  35006. checkInputs(): void;
  35007. /**
  35008. * Gets the class name of the current intput.
  35009. * @returns the class name
  35010. */
  35011. getClassName(): string;
  35012. /**
  35013. * Get the friendly name associated with the input class.
  35014. * @returns the input friendly name
  35015. */
  35016. getSimpleName(): string;
  35017. }
  35018. }
  35019. declare module BABYLON {
  35020. /**
  35021. * Defines the potential axis of a Joystick
  35022. */
  35023. export enum JoystickAxis {
  35024. /** X axis */
  35025. X = 0,
  35026. /** Y axis */
  35027. Y = 1,
  35028. /** Z axis */
  35029. Z = 2
  35030. }
  35031. /**
  35032. * Class used to define virtual joystick (used in touch mode)
  35033. */
  35034. export class VirtualJoystick {
  35035. /**
  35036. * Gets or sets a boolean indicating that left and right values must be inverted
  35037. */
  35038. reverseLeftRight: boolean;
  35039. /**
  35040. * Gets or sets a boolean indicating that up and down values must be inverted
  35041. */
  35042. reverseUpDown: boolean;
  35043. /**
  35044. * Gets the offset value for the position (ie. the change of the position value)
  35045. */
  35046. deltaPosition: Vector3;
  35047. /**
  35048. * Gets a boolean indicating if the virtual joystick was pressed
  35049. */
  35050. pressed: boolean;
  35051. /**
  35052. * Canvas the virtual joystick will render onto, default z-index of this is 5
  35053. */
  35054. static Canvas: Nullable<HTMLCanvasElement>;
  35055. private static _globalJoystickIndex;
  35056. private static vjCanvasContext;
  35057. private static vjCanvasWidth;
  35058. private static vjCanvasHeight;
  35059. private static halfWidth;
  35060. private _action;
  35061. private _axisTargetedByLeftAndRight;
  35062. private _axisTargetedByUpAndDown;
  35063. private _joystickSensibility;
  35064. private _inversedSensibility;
  35065. private _joystickPointerID;
  35066. private _joystickColor;
  35067. private _joystickPointerPos;
  35068. private _joystickPreviousPointerPos;
  35069. private _joystickPointerStartPos;
  35070. private _deltaJoystickVector;
  35071. private _leftJoystick;
  35072. private _touches;
  35073. private _onPointerDownHandlerRef;
  35074. private _onPointerMoveHandlerRef;
  35075. private _onPointerUpHandlerRef;
  35076. private _onResize;
  35077. /**
  35078. * Creates a new virtual joystick
  35079. * @param leftJoystick defines that the joystick is for left hand (false by default)
  35080. */
  35081. constructor(leftJoystick?: boolean);
  35082. /**
  35083. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  35084. * @param newJoystickSensibility defines the new sensibility
  35085. */
  35086. setJoystickSensibility(newJoystickSensibility: number): void;
  35087. private _onPointerDown;
  35088. private _onPointerMove;
  35089. private _onPointerUp;
  35090. /**
  35091. * Change the color of the virtual joystick
  35092. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  35093. */
  35094. setJoystickColor(newColor: string): void;
  35095. /**
  35096. * Defines a callback to call when the joystick is touched
  35097. * @param action defines the callback
  35098. */
  35099. setActionOnTouch(action: () => any): void;
  35100. /**
  35101. * Defines which axis you'd like to control for left & right
  35102. * @param axis defines the axis to use
  35103. */
  35104. setAxisForLeftRight(axis: JoystickAxis): void;
  35105. /**
  35106. * Defines which axis you'd like to control for up & down
  35107. * @param axis defines the axis to use
  35108. */
  35109. setAxisForUpDown(axis: JoystickAxis): void;
  35110. private _drawVirtualJoystick;
  35111. /**
  35112. * Release internal HTML canvas
  35113. */
  35114. releaseCanvas(): void;
  35115. }
  35116. }
  35117. declare module BABYLON {
  35118. interface FreeCameraInputsManager {
  35119. /**
  35120. * Add virtual joystick input support to the input manager.
  35121. * @returns the current input manager
  35122. */
  35123. addVirtualJoystick(): FreeCameraInputsManager;
  35124. }
  35125. /**
  35126. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  35127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35128. */
  35129. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  35130. /**
  35131. * Defines the camera the input is attached to.
  35132. */
  35133. camera: FreeCamera;
  35134. private _leftjoystick;
  35135. private _rightjoystick;
  35136. /**
  35137. * Gets the left stick of the virtual joystick.
  35138. * @returns The virtual Joystick
  35139. */
  35140. getLeftJoystick(): VirtualJoystick;
  35141. /**
  35142. * Gets the right stick of the virtual joystick.
  35143. * @returns The virtual Joystick
  35144. */
  35145. getRightJoystick(): VirtualJoystick;
  35146. /**
  35147. * Update the current camera state depending on the inputs that have been used this frame.
  35148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35149. */
  35150. checkInputs(): void;
  35151. /**
  35152. * Attach the input controls to a specific dom element to get the input from.
  35153. * @param element Defines the element the controls should be listened from
  35154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35155. */
  35156. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35157. /**
  35158. * Detach the current controls from the specified dom element.
  35159. * @param element Defines the element to stop listening the inputs from
  35160. */
  35161. detachControl(element: Nullable<HTMLElement>): void;
  35162. /**
  35163. * Gets the class name of the current intput.
  35164. * @returns the class name
  35165. */
  35166. getClassName(): string;
  35167. /**
  35168. * Get the friendly name associated with the input class.
  35169. * @returns the input friendly name
  35170. */
  35171. getSimpleName(): string;
  35172. }
  35173. }
  35174. declare module BABYLON {
  35175. /**
  35176. * This represents a FPS type of camera controlled by touch.
  35177. * This is like a universal camera minus the Gamepad controls.
  35178. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35179. */
  35180. export class TouchCamera extends FreeCamera {
  35181. /**
  35182. * Defines the touch sensibility for rotation.
  35183. * The higher the faster.
  35184. */
  35185. touchAngularSensibility: number;
  35186. /**
  35187. * Defines the touch sensibility for move.
  35188. * The higher the faster.
  35189. */
  35190. touchMoveSensibility: number;
  35191. /**
  35192. * Instantiates a new touch camera.
  35193. * This represents a FPS type of camera controlled by touch.
  35194. * This is like a universal camera minus the Gamepad controls.
  35195. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35196. * @param name Define the name of the camera in the scene
  35197. * @param position Define the start position of the camera in the scene
  35198. * @param scene Define the scene the camera belongs to
  35199. */
  35200. constructor(name: string, position: Vector3, scene: Scene);
  35201. /**
  35202. * Gets the current object class name.
  35203. * @return the class name
  35204. */
  35205. getClassName(): string;
  35206. /** @hidden */ setupInputs(): void;
  35207. }
  35208. }
  35209. declare module BABYLON {
  35210. /**
  35211. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  35212. * being tilted forward or back and left or right.
  35213. */
  35214. export class DeviceOrientationCamera extends FreeCamera {
  35215. private _initialQuaternion;
  35216. private _quaternionCache;
  35217. /**
  35218. * Creates a new device orientation camera
  35219. * @param name The name of the camera
  35220. * @param position The start position camera
  35221. * @param scene The scene the camera belongs to
  35222. */
  35223. constructor(name: string, position: Vector3, scene: Scene);
  35224. /**
  35225. * Gets the current instance class name ("DeviceOrientationCamera").
  35226. * This helps avoiding instanceof at run time.
  35227. * @returns the class name
  35228. */
  35229. getClassName(): string;
  35230. /**
  35231. * @hidden
  35232. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  35233. */ checkInputs(): void;
  35234. /**
  35235. * Reset the camera to its default orientation on the specified axis only.
  35236. * @param axis The axis to reset
  35237. */
  35238. resetToCurrentRotation(axis?: Axis): void;
  35239. }
  35240. }
  35241. declare module BABYLON {
  35242. /**
  35243. * Manage the keyboard inputs to control the movement of a follow camera.
  35244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35245. */
  35246. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  35247. /**
  35248. * Defines the camera the input is attached to.
  35249. */
  35250. camera: FollowCamera;
  35251. /**
  35252. * Defines the list of key codes associated with the up action (increase heightOffset)
  35253. */
  35254. keysHeightOffsetIncr: number[];
  35255. /**
  35256. * Defines the list of key codes associated with the down action (decrease heightOffset)
  35257. */
  35258. keysHeightOffsetDecr: number[];
  35259. /**
  35260. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  35261. */
  35262. keysHeightOffsetModifierAlt: boolean;
  35263. /**
  35264. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  35265. */
  35266. keysHeightOffsetModifierCtrl: boolean;
  35267. /**
  35268. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  35269. */
  35270. keysHeightOffsetModifierShift: boolean;
  35271. /**
  35272. * Defines the list of key codes associated with the left action (increase rotationOffset)
  35273. */
  35274. keysRotationOffsetIncr: number[];
  35275. /**
  35276. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  35277. */
  35278. keysRotationOffsetDecr: number[];
  35279. /**
  35280. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  35281. */
  35282. keysRotationOffsetModifierAlt: boolean;
  35283. /**
  35284. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  35285. */
  35286. keysRotationOffsetModifierCtrl: boolean;
  35287. /**
  35288. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  35289. */
  35290. keysRotationOffsetModifierShift: boolean;
  35291. /**
  35292. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  35293. */
  35294. keysRadiusIncr: number[];
  35295. /**
  35296. * Defines the list of key codes associated with the zoom-out action (increase radius)
  35297. */
  35298. keysRadiusDecr: number[];
  35299. /**
  35300. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  35301. */
  35302. keysRadiusModifierAlt: boolean;
  35303. /**
  35304. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  35305. */
  35306. keysRadiusModifierCtrl: boolean;
  35307. /**
  35308. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  35309. */
  35310. keysRadiusModifierShift: boolean;
  35311. /**
  35312. * Defines the rate of change of heightOffset.
  35313. */
  35314. heightSensibility: number;
  35315. /**
  35316. * Defines the rate of change of rotationOffset.
  35317. */
  35318. rotationSensibility: number;
  35319. /**
  35320. * Defines the rate of change of radius.
  35321. */
  35322. radiusSensibility: number;
  35323. private _keys;
  35324. private _ctrlPressed;
  35325. private _altPressed;
  35326. private _shiftPressed;
  35327. private _onCanvasBlurObserver;
  35328. private _onKeyboardObserver;
  35329. private _engine;
  35330. private _scene;
  35331. /**
  35332. * Attach the input controls to a specific dom element to get the input from.
  35333. * @param element Defines the element the controls should be listened from
  35334. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35335. */
  35336. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35337. /**
  35338. * Detach the current controls from the specified dom element.
  35339. * @param element Defines the element to stop listening the inputs from
  35340. */
  35341. detachControl(element: Nullable<HTMLElement>): void;
  35342. /**
  35343. * Update the current camera state depending on the inputs that have been used this frame.
  35344. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35345. */
  35346. checkInputs(): void;
  35347. /**
  35348. * Gets the class name of the current input.
  35349. * @returns the class name
  35350. */
  35351. getClassName(): string;
  35352. /**
  35353. * Get the friendly name associated with the input class.
  35354. * @returns the input friendly name
  35355. */
  35356. getSimpleName(): string;
  35357. /**
  35358. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35359. * allow modification of the heightOffset value.
  35360. */
  35361. private _modifierHeightOffset;
  35362. /**
  35363. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35364. * allow modification of the rotationOffset value.
  35365. */
  35366. private _modifierRotationOffset;
  35367. /**
  35368. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35369. * allow modification of the radius value.
  35370. */
  35371. private _modifierRadius;
  35372. }
  35373. }
  35374. declare module BABYLON {
  35375. /**
  35376. * Manage the mouse wheel inputs to control a follow camera.
  35377. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35378. */
  35379. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35380. /**
  35381. * Defines the camera the input is attached to.
  35382. */
  35383. camera: FollowCamera;
  35384. /**
  35385. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  35386. */
  35387. axisControlRadius: boolean;
  35388. /**
  35389. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  35390. */
  35391. axisControlHeight: boolean;
  35392. /**
  35393. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  35394. */
  35395. axisControlRotation: boolean;
  35396. /**
  35397. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35398. * relation to mouseWheel events.
  35399. */
  35400. wheelPrecision: number;
  35401. /**
  35402. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35403. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35404. */
  35405. wheelDeltaPercentage: number;
  35406. private _wheel;
  35407. private _observer;
  35408. /**
  35409. * Attach the input controls to a specific dom element to get the input from.
  35410. * @param element Defines the element the controls should be listened from
  35411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35412. */
  35413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35414. /**
  35415. * Detach the current controls from the specified dom element.
  35416. * @param element Defines the element to stop listening the inputs from
  35417. */
  35418. detachControl(element: Nullable<HTMLElement>): void;
  35419. /**
  35420. * Gets the class name of the current intput.
  35421. * @returns the class name
  35422. */
  35423. getClassName(): string;
  35424. /**
  35425. * Get the friendly name associated with the input class.
  35426. * @returns the input friendly name
  35427. */
  35428. getSimpleName(): string;
  35429. }
  35430. }
  35431. declare module BABYLON {
  35432. /**
  35433. * Default Inputs manager for the FollowCamera.
  35434. * It groups all the default supported inputs for ease of use.
  35435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35436. */
  35437. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  35438. /**
  35439. * Instantiates a new FollowCameraInputsManager.
  35440. * @param camera Defines the camera the inputs belong to
  35441. */
  35442. constructor(camera: FollowCamera);
  35443. /**
  35444. * Add keyboard input support to the input manager.
  35445. * @returns the current input manager
  35446. */
  35447. addKeyboard(): FollowCameraInputsManager;
  35448. /**
  35449. * Add mouse wheel input support to the input manager.
  35450. * @returns the current input manager
  35451. */
  35452. addMouseWheel(): FollowCameraInputsManager;
  35453. /**
  35454. * Add pointers input support to the input manager.
  35455. * @returns the current input manager
  35456. */
  35457. addPointers(): FollowCameraInputsManager;
  35458. /**
  35459. * Add orientation input support to the input manager.
  35460. * @returns the current input manager
  35461. */
  35462. addVRDeviceOrientation(): FollowCameraInputsManager;
  35463. }
  35464. }
  35465. declare module BABYLON {
  35466. /**
  35467. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  35468. * an arc rotate version arcFollowCamera are available.
  35469. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35470. */
  35471. export class FollowCamera extends TargetCamera {
  35472. /**
  35473. * Distance the follow camera should follow an object at
  35474. */
  35475. radius: number;
  35476. /**
  35477. * Minimum allowed distance of the camera to the axis of rotation
  35478. * (The camera can not get closer).
  35479. * This can help limiting how the Camera is able to move in the scene.
  35480. */
  35481. lowerRadiusLimit: Nullable<number>;
  35482. /**
  35483. * Maximum allowed distance of the camera to the axis of rotation
  35484. * (The camera can not get further).
  35485. * This can help limiting how the Camera is able to move in the scene.
  35486. */
  35487. upperRadiusLimit: Nullable<number>;
  35488. /**
  35489. * Define a rotation offset between the camera and the object it follows
  35490. */
  35491. rotationOffset: number;
  35492. /**
  35493. * Minimum allowed angle to camera position relative to target object.
  35494. * This can help limiting how the Camera is able to move in the scene.
  35495. */
  35496. lowerRotationOffsetLimit: Nullable<number>;
  35497. /**
  35498. * Maximum allowed angle to camera position relative to target object.
  35499. * This can help limiting how the Camera is able to move in the scene.
  35500. */
  35501. upperRotationOffsetLimit: Nullable<number>;
  35502. /**
  35503. * Define a height offset between the camera and the object it follows.
  35504. * It can help following an object from the top (like a car chaing a plane)
  35505. */
  35506. heightOffset: number;
  35507. /**
  35508. * Minimum allowed height of camera position relative to target object.
  35509. * This can help limiting how the Camera is able to move in the scene.
  35510. */
  35511. lowerHeightOffsetLimit: Nullable<number>;
  35512. /**
  35513. * Maximum allowed height of camera position relative to target object.
  35514. * This can help limiting how the Camera is able to move in the scene.
  35515. */
  35516. upperHeightOffsetLimit: Nullable<number>;
  35517. /**
  35518. * Define how fast the camera can accelerate to follow it s target.
  35519. */
  35520. cameraAcceleration: number;
  35521. /**
  35522. * Define the speed limit of the camera following an object.
  35523. */
  35524. maxCameraSpeed: number;
  35525. /**
  35526. * Define the target of the camera.
  35527. */
  35528. lockedTarget: Nullable<AbstractMesh>;
  35529. /**
  35530. * Defines the input associated with the camera.
  35531. */
  35532. inputs: FollowCameraInputsManager;
  35533. /**
  35534. * Instantiates the follow camera.
  35535. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35536. * @param name Define the name of the camera in the scene
  35537. * @param position Define the position of the camera
  35538. * @param scene Define the scene the camera belong to
  35539. * @param lockedTarget Define the target of the camera
  35540. */
  35541. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  35542. private _follow;
  35543. /**
  35544. * Attached controls to the current camera.
  35545. * @param element Defines the element the controls should be listened from
  35546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35547. */
  35548. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35549. /**
  35550. * Detach the current controls from the camera.
  35551. * The camera will stop reacting to inputs.
  35552. * @param element Defines the element to stop listening the inputs from
  35553. */
  35554. detachControl(element: HTMLElement): void;
  35555. /** @hidden */ checkInputs(): void;
  35556. private _checkLimits;
  35557. /**
  35558. * Gets the camera class name.
  35559. * @returns the class name
  35560. */
  35561. getClassName(): string;
  35562. }
  35563. /**
  35564. * Arc Rotate version of the follow camera.
  35565. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  35566. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35567. */
  35568. export class ArcFollowCamera extends TargetCamera {
  35569. /** The longitudinal angle of the camera */
  35570. alpha: number;
  35571. /** The latitudinal angle of the camera */
  35572. beta: number;
  35573. /** The radius of the camera from its target */
  35574. radius: number;
  35575. /** Define the camera target (the messh it should follow) */
  35576. target: Nullable<AbstractMesh>;
  35577. private _cartesianCoordinates;
  35578. /**
  35579. * Instantiates a new ArcFollowCamera
  35580. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35581. * @param name Define the name of the camera
  35582. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  35583. * @param beta Define the rotation angle of the camera around the elevation axis
  35584. * @param radius Define the radius of the camera from its target point
  35585. * @param target Define the target of the camera
  35586. * @param scene Define the scene the camera belongs to
  35587. */
  35588. constructor(name: string,
  35589. /** The longitudinal angle of the camera */
  35590. alpha: number,
  35591. /** The latitudinal angle of the camera */
  35592. beta: number,
  35593. /** The radius of the camera from its target */
  35594. radius: number,
  35595. /** Define the camera target (the messh it should follow) */
  35596. target: Nullable<AbstractMesh>, scene: Scene);
  35597. private _follow;
  35598. /** @hidden */ checkInputs(): void;
  35599. /**
  35600. * Returns the class name of the object.
  35601. * It is mostly used internally for serialization purposes.
  35602. */
  35603. getClassName(): string;
  35604. }
  35605. }
  35606. declare module BABYLON {
  35607. /**
  35608. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  35609. * which still works and will still be found in many Playgrounds.
  35610. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35611. */
  35612. export class UniversalCamera extends TouchCamera {
  35613. /**
  35614. * Defines the gamepad rotation sensiblity.
  35615. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35616. */
  35617. gamepadAngularSensibility: number;
  35618. /**
  35619. * Defines the gamepad move sensiblity.
  35620. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35621. */
  35622. gamepadMoveSensibility: number;
  35623. /**
  35624. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  35625. * which still works and will still be found in many Playgrounds.
  35626. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35627. * @param name Define the name of the camera in the scene
  35628. * @param position Define the start position of the camera in the scene
  35629. * @param scene Define the scene the camera belongs to
  35630. */
  35631. constructor(name: string, position: Vector3, scene: Scene);
  35632. /**
  35633. * Gets the current object class name.
  35634. * @return the class name
  35635. */
  35636. getClassName(): string;
  35637. }
  35638. }
  35639. declare module BABYLON {
  35640. /**
  35641. * This represents a FPS type of camera. This is only here for back compat purpose.
  35642. * Please use the UniversalCamera instead as both are identical.
  35643. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35644. */
  35645. export class GamepadCamera extends UniversalCamera {
  35646. /**
  35647. * Instantiates a new Gamepad Camera
  35648. * This represents a FPS type of camera. This is only here for back compat purpose.
  35649. * Please use the UniversalCamera instead as both are identical.
  35650. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35651. * @param name Define the name of the camera in the scene
  35652. * @param position Define the start position of the camera in the scene
  35653. * @param scene Define the scene the camera belongs to
  35654. */
  35655. constructor(name: string, position: Vector3, scene: Scene);
  35656. /**
  35657. * Gets the current object class name.
  35658. * @return the class name
  35659. */
  35660. getClassName(): string;
  35661. }
  35662. }
  35663. declare module BABYLON {
  35664. /** @hidden */
  35665. export var passPixelShader: {
  35666. name: string;
  35667. shader: string;
  35668. };
  35669. }
  35670. declare module BABYLON {
  35671. /** @hidden */
  35672. export var passCubePixelShader: {
  35673. name: string;
  35674. shader: string;
  35675. };
  35676. }
  35677. declare module BABYLON {
  35678. /**
  35679. * PassPostProcess which produces an output the same as it's input
  35680. */
  35681. export class PassPostProcess extends PostProcess {
  35682. /**
  35683. * Creates the PassPostProcess
  35684. * @param name The name of the effect.
  35685. * @param options The required width/height ratio to downsize to before computing the render pass.
  35686. * @param camera The camera to apply the render pass to.
  35687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35688. * @param engine The engine which the post process will be applied. (default: current engine)
  35689. * @param reusable If the post process can be reused on the same frame. (default: false)
  35690. * @param textureType The type of texture to be used when performing the post processing.
  35691. * @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)
  35692. */
  35693. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35694. }
  35695. /**
  35696. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  35697. */
  35698. export class PassCubePostProcess extends PostProcess {
  35699. private _face;
  35700. /**
  35701. * Gets or sets the cube face to display.
  35702. * * 0 is +X
  35703. * * 1 is -X
  35704. * * 2 is +Y
  35705. * * 3 is -Y
  35706. * * 4 is +Z
  35707. * * 5 is -Z
  35708. */
  35709. face: number;
  35710. /**
  35711. * Creates the PassCubePostProcess
  35712. * @param name The name of the effect.
  35713. * @param options The required width/height ratio to downsize to before computing the render pass.
  35714. * @param camera The camera to apply the render pass to.
  35715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35716. * @param engine The engine which the post process will be applied. (default: current engine)
  35717. * @param reusable If the post process can be reused on the same frame. (default: false)
  35718. * @param textureType The type of texture to be used when performing the post processing.
  35719. * @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)
  35720. */
  35721. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35722. }
  35723. }
  35724. declare module BABYLON {
  35725. /** @hidden */
  35726. export var anaglyphPixelShader: {
  35727. name: string;
  35728. shader: string;
  35729. };
  35730. }
  35731. declare module BABYLON {
  35732. /**
  35733. * Postprocess used to generate anaglyphic rendering
  35734. */
  35735. export class AnaglyphPostProcess extends PostProcess {
  35736. private _passedProcess;
  35737. /**
  35738. * Creates a new AnaglyphPostProcess
  35739. * @param name defines postprocess name
  35740. * @param options defines creation options or target ratio scale
  35741. * @param rigCameras defines cameras using this postprocess
  35742. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  35743. * @param engine defines hosting engine
  35744. * @param reusable defines if the postprocess will be reused multiple times per frame
  35745. */
  35746. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  35747. }
  35748. }
  35749. declare module BABYLON {
  35750. /**
  35751. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  35752. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  35753. */
  35754. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  35755. /**
  35756. * Creates a new AnaglyphArcRotateCamera
  35757. * @param name defines camera name
  35758. * @param alpha defines alpha angle (in radians)
  35759. * @param beta defines beta angle (in radians)
  35760. * @param radius defines radius
  35761. * @param target defines camera target
  35762. * @param interaxialDistance defines distance between each color axis
  35763. * @param scene defines the hosting scene
  35764. */
  35765. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  35766. /**
  35767. * Gets camera class name
  35768. * @returns AnaglyphArcRotateCamera
  35769. */
  35770. getClassName(): string;
  35771. }
  35772. }
  35773. declare module BABYLON {
  35774. /**
  35775. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  35776. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  35777. */
  35778. export class AnaglyphFreeCamera extends FreeCamera {
  35779. /**
  35780. * Creates a new AnaglyphFreeCamera
  35781. * @param name defines camera name
  35782. * @param position defines initial position
  35783. * @param interaxialDistance defines distance between each color axis
  35784. * @param scene defines the hosting scene
  35785. */
  35786. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  35787. /**
  35788. * Gets camera class name
  35789. * @returns AnaglyphFreeCamera
  35790. */
  35791. getClassName(): string;
  35792. }
  35793. }
  35794. declare module BABYLON {
  35795. /**
  35796. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  35797. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  35798. */
  35799. export class AnaglyphGamepadCamera extends GamepadCamera {
  35800. /**
  35801. * Creates a new AnaglyphGamepadCamera
  35802. * @param name defines camera name
  35803. * @param position defines initial position
  35804. * @param interaxialDistance defines distance between each color axis
  35805. * @param scene defines the hosting scene
  35806. */
  35807. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  35808. /**
  35809. * Gets camera class name
  35810. * @returns AnaglyphGamepadCamera
  35811. */
  35812. getClassName(): string;
  35813. }
  35814. }
  35815. declare module BABYLON {
  35816. /**
  35817. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  35818. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  35819. */
  35820. export class AnaglyphUniversalCamera extends UniversalCamera {
  35821. /**
  35822. * Creates a new AnaglyphUniversalCamera
  35823. * @param name defines camera name
  35824. * @param position defines initial position
  35825. * @param interaxialDistance defines distance between each color axis
  35826. * @param scene defines the hosting scene
  35827. */
  35828. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  35829. /**
  35830. * Gets camera class name
  35831. * @returns AnaglyphUniversalCamera
  35832. */
  35833. getClassName(): string;
  35834. }
  35835. }
  35836. declare module BABYLON {
  35837. /** @hidden */
  35838. export var stereoscopicInterlacePixelShader: {
  35839. name: string;
  35840. shader: string;
  35841. };
  35842. }
  35843. declare module BABYLON {
  35844. /**
  35845. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35846. */
  35847. export class StereoscopicInterlacePostProcess extends PostProcess {
  35848. private _stepSize;
  35849. private _passedProcess;
  35850. /**
  35851. * Initializes a StereoscopicInterlacePostProcess
  35852. * @param name The name of the effect.
  35853. * @param rigCameras The rig cameras to be appled to the post process
  35854. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35856. * @param engine The engine which the post process will be applied. (default: current engine)
  35857. * @param reusable If the post process can be reused on the same frame. (default: false)
  35858. */
  35859. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35860. }
  35861. }
  35862. declare module BABYLON {
  35863. /**
  35864. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  35865. * @see http://doc.babylonjs.com/features/cameras
  35866. */
  35867. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  35868. /**
  35869. * Creates a new StereoscopicArcRotateCamera
  35870. * @param name defines camera name
  35871. * @param alpha defines alpha angle (in radians)
  35872. * @param beta defines beta angle (in radians)
  35873. * @param radius defines radius
  35874. * @param target defines camera target
  35875. * @param interaxialDistance defines distance between each color axis
  35876. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  35877. * @param scene defines the hosting scene
  35878. */
  35879. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  35880. /**
  35881. * Gets camera class name
  35882. * @returns StereoscopicArcRotateCamera
  35883. */
  35884. getClassName(): string;
  35885. }
  35886. }
  35887. declare module BABYLON {
  35888. /**
  35889. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  35890. * @see http://doc.babylonjs.com/features/cameras
  35891. */
  35892. export class StereoscopicFreeCamera extends FreeCamera {
  35893. /**
  35894. * Creates a new StereoscopicFreeCamera
  35895. * @param name defines camera name
  35896. * @param position defines initial position
  35897. * @param interaxialDistance defines distance between each color axis
  35898. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  35899. * @param scene defines the hosting scene
  35900. */
  35901. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  35902. /**
  35903. * Gets camera class name
  35904. * @returns StereoscopicFreeCamera
  35905. */
  35906. getClassName(): string;
  35907. }
  35908. }
  35909. declare module BABYLON {
  35910. /**
  35911. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  35912. * @see http://doc.babylonjs.com/features/cameras
  35913. */
  35914. export class StereoscopicGamepadCamera extends GamepadCamera {
  35915. /**
  35916. * Creates a new StereoscopicGamepadCamera
  35917. * @param name defines camera name
  35918. * @param position defines initial position
  35919. * @param interaxialDistance defines distance between each color axis
  35920. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  35921. * @param scene defines the hosting scene
  35922. */
  35923. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  35924. /**
  35925. * Gets camera class name
  35926. * @returns StereoscopicGamepadCamera
  35927. */
  35928. getClassName(): string;
  35929. }
  35930. }
  35931. declare module BABYLON {
  35932. /**
  35933. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  35934. * @see http://doc.babylonjs.com/features/cameras
  35935. */
  35936. export class StereoscopicUniversalCamera extends UniversalCamera {
  35937. /**
  35938. * Creates a new StereoscopicUniversalCamera
  35939. * @param name defines camera name
  35940. * @param position defines initial position
  35941. * @param interaxialDistance defines distance between each color axis
  35942. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  35943. * @param scene defines the hosting scene
  35944. */
  35945. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  35946. /**
  35947. * Gets camera class name
  35948. * @returns StereoscopicUniversalCamera
  35949. */
  35950. getClassName(): string;
  35951. }
  35952. }
  35953. declare module BABYLON {
  35954. /**
  35955. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  35956. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  35957. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  35958. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  35959. */
  35960. export class VirtualJoysticksCamera extends FreeCamera {
  35961. /**
  35962. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  35963. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  35964. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  35965. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  35966. * @param name Define the name of the camera in the scene
  35967. * @param position Define the start position of the camera in the scene
  35968. * @param scene Define the scene the camera belongs to
  35969. */
  35970. constructor(name: string, position: Vector3, scene: Scene);
  35971. /**
  35972. * Gets the current object class name.
  35973. * @return the class name
  35974. */
  35975. getClassName(): string;
  35976. }
  35977. }
  35978. declare module BABYLON {
  35979. /**
  35980. * This represents all the required metrics to create a VR camera.
  35981. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  35982. */
  35983. export class VRCameraMetrics {
  35984. /**
  35985. * Define the horizontal resolution off the screen.
  35986. */
  35987. hResolution: number;
  35988. /**
  35989. * Define the vertical resolution off the screen.
  35990. */
  35991. vResolution: number;
  35992. /**
  35993. * Define the horizontal screen size.
  35994. */
  35995. hScreenSize: number;
  35996. /**
  35997. * Define the vertical screen size.
  35998. */
  35999. vScreenSize: number;
  36000. /**
  36001. * Define the vertical screen center position.
  36002. */
  36003. vScreenCenter: number;
  36004. /**
  36005. * Define the distance of the eyes to the screen.
  36006. */
  36007. eyeToScreenDistance: number;
  36008. /**
  36009. * Define the distance between both lenses
  36010. */
  36011. lensSeparationDistance: number;
  36012. /**
  36013. * Define the distance between both viewer's eyes.
  36014. */
  36015. interpupillaryDistance: number;
  36016. /**
  36017. * Define the distortion factor of the VR postprocess.
  36018. * Please, touch with care.
  36019. */
  36020. distortionK: number[];
  36021. /**
  36022. * Define the chromatic aberration correction factors for the VR post process.
  36023. */
  36024. chromaAbCorrection: number[];
  36025. /**
  36026. * Define the scale factor of the post process.
  36027. * The smaller the better but the slower.
  36028. */
  36029. postProcessScaleFactor: number;
  36030. /**
  36031. * Define an offset for the lens center.
  36032. */
  36033. lensCenterOffset: number;
  36034. /**
  36035. * Define if the current vr camera should compensate the distortion of the lense or not.
  36036. */
  36037. compensateDistortion: boolean;
  36038. /**
  36039. * Gets the rendering aspect ratio based on the provided resolutions.
  36040. */
  36041. readonly aspectRatio: number;
  36042. /**
  36043. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  36044. */
  36045. readonly aspectRatioFov: number;
  36046. /**
  36047. * @hidden
  36048. */
  36049. readonly leftHMatrix: Matrix;
  36050. /**
  36051. * @hidden
  36052. */
  36053. readonly rightHMatrix: Matrix;
  36054. /**
  36055. * @hidden
  36056. */
  36057. readonly leftPreViewMatrix: Matrix;
  36058. /**
  36059. * @hidden
  36060. */
  36061. readonly rightPreViewMatrix: Matrix;
  36062. /**
  36063. * Get the default VRMetrics based on the most generic setup.
  36064. * @returns the default vr metrics
  36065. */
  36066. static GetDefault(): VRCameraMetrics;
  36067. }
  36068. }
  36069. declare module BABYLON {
  36070. /** @hidden */
  36071. export var vrDistortionCorrectionPixelShader: {
  36072. name: string;
  36073. shader: string;
  36074. };
  36075. }
  36076. declare module BABYLON {
  36077. /**
  36078. * VRDistortionCorrectionPostProcess used for mobile VR
  36079. */
  36080. export class VRDistortionCorrectionPostProcess extends PostProcess {
  36081. private _isRightEye;
  36082. private _distortionFactors;
  36083. private _postProcessScaleFactor;
  36084. private _lensCenterOffset;
  36085. private _scaleIn;
  36086. private _scaleFactor;
  36087. private _lensCenter;
  36088. /**
  36089. * Initializes the VRDistortionCorrectionPostProcess
  36090. * @param name The name of the effect.
  36091. * @param camera The camera to apply the render pass to.
  36092. * @param isRightEye If this is for the right eye distortion
  36093. * @param vrMetrics All the required metrics for the VR camera
  36094. */
  36095. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36096. }
  36097. }
  36098. declare module BABYLON {
  36099. /**
  36100. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  36101. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36102. */
  36103. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  36104. /**
  36105. * Creates a new VRDeviceOrientationArcRotateCamera
  36106. * @param name defines camera name
  36107. * @param alpha defines the camera rotation along the logitudinal axis
  36108. * @param beta defines the camera rotation along the latitudinal axis
  36109. * @param radius defines the camera distance from its target
  36110. * @param target defines the camera target
  36111. * @param scene defines the scene the camera belongs to
  36112. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36113. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36114. */
  36115. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36116. /**
  36117. * Gets camera class name
  36118. * @returns VRDeviceOrientationArcRotateCamera
  36119. */
  36120. getClassName(): string;
  36121. }
  36122. }
  36123. declare module BABYLON {
  36124. /**
  36125. * Camera used to simulate VR rendering (based on FreeCamera)
  36126. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36127. */
  36128. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  36129. /**
  36130. * Creates a new VRDeviceOrientationFreeCamera
  36131. * @param name defines camera name
  36132. * @param position defines the start position of the camera
  36133. * @param scene defines the scene the camera belongs to
  36134. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36135. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36136. */
  36137. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36138. /**
  36139. * Gets camera class name
  36140. * @returns VRDeviceOrientationFreeCamera
  36141. */
  36142. getClassName(): string;
  36143. }
  36144. }
  36145. declare module BABYLON {
  36146. /**
  36147. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  36148. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36149. */
  36150. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  36151. /**
  36152. * Creates a new VRDeviceOrientationGamepadCamera
  36153. * @param name defines camera name
  36154. * @param position defines the start position of the camera
  36155. * @param scene defines the scene the camera belongs to
  36156. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36157. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36158. */
  36159. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36160. /**
  36161. * Gets camera class name
  36162. * @returns VRDeviceOrientationGamepadCamera
  36163. */
  36164. getClassName(): string;
  36165. }
  36166. }
  36167. declare module BABYLON {
  36168. /**
  36169. * Defines supported buttons for XBox360 compatible gamepads
  36170. */
  36171. export enum Xbox360Button {
  36172. /** A */
  36173. A = 0,
  36174. /** B */
  36175. B = 1,
  36176. /** X */
  36177. X = 2,
  36178. /** Y */
  36179. Y = 3,
  36180. /** Start */
  36181. Start = 4,
  36182. /** Back */
  36183. Back = 5,
  36184. /** Left button */
  36185. LB = 6,
  36186. /** Right button */
  36187. RB = 7,
  36188. /** Left stick */
  36189. LeftStick = 8,
  36190. /** Right stick */
  36191. RightStick = 9
  36192. }
  36193. /** Defines values for XBox360 DPad */
  36194. export enum Xbox360Dpad {
  36195. /** Up */
  36196. Up = 0,
  36197. /** Down */
  36198. Down = 1,
  36199. /** Left */
  36200. Left = 2,
  36201. /** Right */
  36202. Right = 3
  36203. }
  36204. /**
  36205. * Defines a XBox360 gamepad
  36206. */
  36207. export class Xbox360Pad extends Gamepad {
  36208. private _leftTrigger;
  36209. private _rightTrigger;
  36210. private _onlefttriggerchanged;
  36211. private _onrighttriggerchanged;
  36212. private _onbuttondown;
  36213. private _onbuttonup;
  36214. private _ondpaddown;
  36215. private _ondpadup;
  36216. /** Observable raised when a button is pressed */
  36217. onButtonDownObservable: Observable<Xbox360Button>;
  36218. /** Observable raised when a button is released */
  36219. onButtonUpObservable: Observable<Xbox360Button>;
  36220. /** Observable raised when a pad is pressed */
  36221. onPadDownObservable: Observable<Xbox360Dpad>;
  36222. /** Observable raised when a pad is released */
  36223. onPadUpObservable: Observable<Xbox360Dpad>;
  36224. private _buttonA;
  36225. private _buttonB;
  36226. private _buttonX;
  36227. private _buttonY;
  36228. private _buttonBack;
  36229. private _buttonStart;
  36230. private _buttonLB;
  36231. private _buttonRB;
  36232. private _buttonLeftStick;
  36233. private _buttonRightStick;
  36234. private _dPadUp;
  36235. private _dPadDown;
  36236. private _dPadLeft;
  36237. private _dPadRight;
  36238. private _isXboxOnePad;
  36239. /**
  36240. * Creates a new XBox360 gamepad object
  36241. * @param id defines the id of this gamepad
  36242. * @param index defines its index
  36243. * @param gamepad defines the internal HTML gamepad object
  36244. * @param xboxOne defines if it is a XBox One gamepad
  36245. */
  36246. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  36247. /**
  36248. * Defines the callback to call when left trigger is pressed
  36249. * @param callback defines the callback to use
  36250. */
  36251. onlefttriggerchanged(callback: (value: number) => void): void;
  36252. /**
  36253. * Defines the callback to call when right trigger is pressed
  36254. * @param callback defines the callback to use
  36255. */
  36256. onrighttriggerchanged(callback: (value: number) => void): void;
  36257. /**
  36258. * Gets the left trigger value
  36259. */
  36260. /**
  36261. * Sets the left trigger value
  36262. */
  36263. leftTrigger: number;
  36264. /**
  36265. * Gets the right trigger value
  36266. */
  36267. /**
  36268. * Sets the right trigger value
  36269. */
  36270. rightTrigger: number;
  36271. /**
  36272. * Defines the callback to call when a button is pressed
  36273. * @param callback defines the callback to use
  36274. */
  36275. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  36276. /**
  36277. * Defines the callback to call when a button is released
  36278. * @param callback defines the callback to use
  36279. */
  36280. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  36281. /**
  36282. * Defines the callback to call when a pad is pressed
  36283. * @param callback defines the callback to use
  36284. */
  36285. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  36286. /**
  36287. * Defines the callback to call when a pad is released
  36288. * @param callback defines the callback to use
  36289. */
  36290. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  36291. private _setButtonValue;
  36292. private _setDPadValue;
  36293. /**
  36294. * Gets the value of the `A` button
  36295. */
  36296. /**
  36297. * Sets the value of the `A` button
  36298. */
  36299. buttonA: number;
  36300. /**
  36301. * Gets the value of the `B` button
  36302. */
  36303. /**
  36304. * Sets the value of the `B` button
  36305. */
  36306. buttonB: number;
  36307. /**
  36308. * Gets the value of the `X` button
  36309. */
  36310. /**
  36311. * Sets the value of the `X` button
  36312. */
  36313. buttonX: number;
  36314. /**
  36315. * Gets the value of the `Y` button
  36316. */
  36317. /**
  36318. * Sets the value of the `Y` button
  36319. */
  36320. buttonY: number;
  36321. /**
  36322. * Gets the value of the `Start` button
  36323. */
  36324. /**
  36325. * Sets the value of the `Start` button
  36326. */
  36327. buttonStart: number;
  36328. /**
  36329. * Gets the value of the `Back` button
  36330. */
  36331. /**
  36332. * Sets the value of the `Back` button
  36333. */
  36334. buttonBack: number;
  36335. /**
  36336. * Gets the value of the `Left` button
  36337. */
  36338. /**
  36339. * Sets the value of the `Left` button
  36340. */
  36341. buttonLB: number;
  36342. /**
  36343. * Gets the value of the `Right` button
  36344. */
  36345. /**
  36346. * Sets the value of the `Right` button
  36347. */
  36348. buttonRB: number;
  36349. /**
  36350. * Gets the value of the Left joystick
  36351. */
  36352. /**
  36353. * Sets the value of the Left joystick
  36354. */
  36355. buttonLeftStick: number;
  36356. /**
  36357. * Gets the value of the Right joystick
  36358. */
  36359. /**
  36360. * Sets the value of the Right joystick
  36361. */
  36362. buttonRightStick: number;
  36363. /**
  36364. * Gets the value of D-pad up
  36365. */
  36366. /**
  36367. * Sets the value of D-pad up
  36368. */
  36369. dPadUp: number;
  36370. /**
  36371. * Gets the value of D-pad down
  36372. */
  36373. /**
  36374. * Sets the value of D-pad down
  36375. */
  36376. dPadDown: number;
  36377. /**
  36378. * Gets the value of D-pad left
  36379. */
  36380. /**
  36381. * Sets the value of D-pad left
  36382. */
  36383. dPadLeft: number;
  36384. /**
  36385. * Gets the value of D-pad right
  36386. */
  36387. /**
  36388. * Sets the value of D-pad right
  36389. */
  36390. dPadRight: number;
  36391. /**
  36392. * Force the gamepad to synchronize with device values
  36393. */
  36394. update(): void;
  36395. /**
  36396. * Disposes the gamepad
  36397. */
  36398. dispose(): void;
  36399. }
  36400. }
  36401. declare module BABYLON {
  36402. /**
  36403. * Base class of materials working in push mode in babylon JS
  36404. * @hidden
  36405. */
  36406. export class PushMaterial extends Material {
  36407. protected _activeEffect: Effect;
  36408. protected _normalMatrix: Matrix;
  36409. /**
  36410. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  36411. * This means that the material can keep using a previous shader while a new one is being compiled.
  36412. * This is mostly used when shader parallel compilation is supported (true by default)
  36413. */
  36414. allowShaderHotSwapping: boolean;
  36415. constructor(name: string, scene: Scene);
  36416. getEffect(): Effect;
  36417. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  36418. /**
  36419. * Binds the given world matrix to the active effect
  36420. *
  36421. * @param world the matrix to bind
  36422. */
  36423. bindOnlyWorldMatrix(world: Matrix): void;
  36424. /**
  36425. * Binds the given normal matrix to the active effect
  36426. *
  36427. * @param normalMatrix the matrix to bind
  36428. */
  36429. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  36430. bind(world: Matrix, mesh?: Mesh): void;
  36431. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  36432. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  36433. }
  36434. }
  36435. declare module BABYLON {
  36436. /**
  36437. * This groups all the flags used to control the materials channel.
  36438. */
  36439. export class MaterialFlags {
  36440. private static _DiffuseTextureEnabled;
  36441. /**
  36442. * Are diffuse textures enabled in the application.
  36443. */
  36444. static DiffuseTextureEnabled: boolean;
  36445. private static _AmbientTextureEnabled;
  36446. /**
  36447. * Are ambient textures enabled in the application.
  36448. */
  36449. static AmbientTextureEnabled: boolean;
  36450. private static _OpacityTextureEnabled;
  36451. /**
  36452. * Are opacity textures enabled in the application.
  36453. */
  36454. static OpacityTextureEnabled: boolean;
  36455. private static _ReflectionTextureEnabled;
  36456. /**
  36457. * Are reflection textures enabled in the application.
  36458. */
  36459. static ReflectionTextureEnabled: boolean;
  36460. private static _EmissiveTextureEnabled;
  36461. /**
  36462. * Are emissive textures enabled in the application.
  36463. */
  36464. static EmissiveTextureEnabled: boolean;
  36465. private static _SpecularTextureEnabled;
  36466. /**
  36467. * Are specular textures enabled in the application.
  36468. */
  36469. static SpecularTextureEnabled: boolean;
  36470. private static _BumpTextureEnabled;
  36471. /**
  36472. * Are bump textures enabled in the application.
  36473. */
  36474. static BumpTextureEnabled: boolean;
  36475. private static _LightmapTextureEnabled;
  36476. /**
  36477. * Are lightmap textures enabled in the application.
  36478. */
  36479. static LightmapTextureEnabled: boolean;
  36480. private static _RefractionTextureEnabled;
  36481. /**
  36482. * Are refraction textures enabled in the application.
  36483. */
  36484. static RefractionTextureEnabled: boolean;
  36485. private static _ColorGradingTextureEnabled;
  36486. /**
  36487. * Are color grading textures enabled in the application.
  36488. */
  36489. static ColorGradingTextureEnabled: boolean;
  36490. private static _FresnelEnabled;
  36491. /**
  36492. * Are fresnels enabled in the application.
  36493. */
  36494. static FresnelEnabled: boolean;
  36495. }
  36496. }
  36497. declare module BABYLON {
  36498. /** @hidden */
  36499. export var defaultFragmentDeclaration: {
  36500. name: string;
  36501. shader: string;
  36502. };
  36503. }
  36504. declare module BABYLON {
  36505. /** @hidden */
  36506. export var defaultUboDeclaration: {
  36507. name: string;
  36508. shader: string;
  36509. };
  36510. }
  36511. declare module BABYLON {
  36512. /** @hidden */
  36513. export var lightFragmentDeclaration: {
  36514. name: string;
  36515. shader: string;
  36516. };
  36517. }
  36518. declare module BABYLON {
  36519. /** @hidden */
  36520. export var lightUboDeclaration: {
  36521. name: string;
  36522. shader: string;
  36523. };
  36524. }
  36525. declare module BABYLON {
  36526. /** @hidden */
  36527. export var lightsFragmentFunctions: {
  36528. name: string;
  36529. shader: string;
  36530. };
  36531. }
  36532. declare module BABYLON {
  36533. /** @hidden */
  36534. export var shadowsFragmentFunctions: {
  36535. name: string;
  36536. shader: string;
  36537. };
  36538. }
  36539. declare module BABYLON {
  36540. /** @hidden */
  36541. export var fresnelFunction: {
  36542. name: string;
  36543. shader: string;
  36544. };
  36545. }
  36546. declare module BABYLON {
  36547. /** @hidden */
  36548. export var reflectionFunction: {
  36549. name: string;
  36550. shader: string;
  36551. };
  36552. }
  36553. declare module BABYLON {
  36554. /** @hidden */
  36555. export var bumpFragmentFunctions: {
  36556. name: string;
  36557. shader: string;
  36558. };
  36559. }
  36560. declare module BABYLON {
  36561. /** @hidden */
  36562. export var logDepthDeclaration: {
  36563. name: string;
  36564. shader: string;
  36565. };
  36566. }
  36567. declare module BABYLON {
  36568. /** @hidden */
  36569. export var bumpFragment: {
  36570. name: string;
  36571. shader: string;
  36572. };
  36573. }
  36574. declare module BABYLON {
  36575. /** @hidden */
  36576. export var depthPrePass: {
  36577. name: string;
  36578. shader: string;
  36579. };
  36580. }
  36581. declare module BABYLON {
  36582. /** @hidden */
  36583. export var lightFragment: {
  36584. name: string;
  36585. shader: string;
  36586. };
  36587. }
  36588. declare module BABYLON {
  36589. /** @hidden */
  36590. export var logDepthFragment: {
  36591. name: string;
  36592. shader: string;
  36593. };
  36594. }
  36595. declare module BABYLON {
  36596. /** @hidden */
  36597. export var defaultPixelShader: {
  36598. name: string;
  36599. shader: string;
  36600. };
  36601. }
  36602. declare module BABYLON {
  36603. /** @hidden */
  36604. export var defaultVertexDeclaration: {
  36605. name: string;
  36606. shader: string;
  36607. };
  36608. }
  36609. declare module BABYLON {
  36610. /** @hidden */
  36611. export var bumpVertexDeclaration: {
  36612. name: string;
  36613. shader: string;
  36614. };
  36615. }
  36616. declare module BABYLON {
  36617. /** @hidden */
  36618. export var bumpVertex: {
  36619. name: string;
  36620. shader: string;
  36621. };
  36622. }
  36623. declare module BABYLON {
  36624. /** @hidden */
  36625. export var fogVertex: {
  36626. name: string;
  36627. shader: string;
  36628. };
  36629. }
  36630. declare module BABYLON {
  36631. /** @hidden */
  36632. export var shadowsVertex: {
  36633. name: string;
  36634. shader: string;
  36635. };
  36636. }
  36637. declare module BABYLON {
  36638. /** @hidden */
  36639. export var pointCloudVertex: {
  36640. name: string;
  36641. shader: string;
  36642. };
  36643. }
  36644. declare module BABYLON {
  36645. /** @hidden */
  36646. export var logDepthVertex: {
  36647. name: string;
  36648. shader: string;
  36649. };
  36650. }
  36651. declare module BABYLON {
  36652. /** @hidden */
  36653. export var defaultVertexShader: {
  36654. name: string;
  36655. shader: string;
  36656. };
  36657. }
  36658. declare module BABYLON {
  36659. /** @hidden */
  36660. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  36661. MAINUV1: boolean;
  36662. MAINUV2: boolean;
  36663. DIFFUSE: boolean;
  36664. DIFFUSEDIRECTUV: number;
  36665. AMBIENT: boolean;
  36666. AMBIENTDIRECTUV: number;
  36667. OPACITY: boolean;
  36668. OPACITYDIRECTUV: number;
  36669. OPACITYRGB: boolean;
  36670. REFLECTION: boolean;
  36671. EMISSIVE: boolean;
  36672. EMISSIVEDIRECTUV: number;
  36673. SPECULAR: boolean;
  36674. SPECULARDIRECTUV: number;
  36675. BUMP: boolean;
  36676. BUMPDIRECTUV: number;
  36677. PARALLAX: boolean;
  36678. PARALLAXOCCLUSION: boolean;
  36679. SPECULAROVERALPHA: boolean;
  36680. CLIPPLANE: boolean;
  36681. CLIPPLANE2: boolean;
  36682. CLIPPLANE3: boolean;
  36683. CLIPPLANE4: boolean;
  36684. ALPHATEST: boolean;
  36685. DEPTHPREPASS: boolean;
  36686. ALPHAFROMDIFFUSE: boolean;
  36687. POINTSIZE: boolean;
  36688. FOG: boolean;
  36689. SPECULARTERM: boolean;
  36690. DIFFUSEFRESNEL: boolean;
  36691. OPACITYFRESNEL: boolean;
  36692. REFLECTIONFRESNEL: boolean;
  36693. REFRACTIONFRESNEL: boolean;
  36694. EMISSIVEFRESNEL: boolean;
  36695. FRESNEL: boolean;
  36696. NORMAL: boolean;
  36697. UV1: boolean;
  36698. UV2: boolean;
  36699. VERTEXCOLOR: boolean;
  36700. VERTEXALPHA: boolean;
  36701. NUM_BONE_INFLUENCERS: number;
  36702. BonesPerMesh: number;
  36703. BONETEXTURE: boolean;
  36704. INSTANCES: boolean;
  36705. GLOSSINESS: boolean;
  36706. ROUGHNESS: boolean;
  36707. EMISSIVEASILLUMINATION: boolean;
  36708. LINKEMISSIVEWITHDIFFUSE: boolean;
  36709. REFLECTIONFRESNELFROMSPECULAR: boolean;
  36710. LIGHTMAP: boolean;
  36711. LIGHTMAPDIRECTUV: number;
  36712. OBJECTSPACE_NORMALMAP: boolean;
  36713. USELIGHTMAPASSHADOWMAP: boolean;
  36714. REFLECTIONMAP_3D: boolean;
  36715. REFLECTIONMAP_SPHERICAL: boolean;
  36716. REFLECTIONMAP_PLANAR: boolean;
  36717. REFLECTIONMAP_CUBIC: boolean;
  36718. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  36719. REFLECTIONMAP_PROJECTION: boolean;
  36720. REFLECTIONMAP_SKYBOX: boolean;
  36721. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  36722. REFLECTIONMAP_EXPLICIT: boolean;
  36723. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  36724. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  36725. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  36726. INVERTCUBICMAP: boolean;
  36727. LOGARITHMICDEPTH: boolean;
  36728. REFRACTION: boolean;
  36729. REFRACTIONMAP_3D: boolean;
  36730. REFLECTIONOVERALPHA: boolean;
  36731. TWOSIDEDLIGHTING: boolean;
  36732. SHADOWFLOAT: boolean;
  36733. MORPHTARGETS: boolean;
  36734. MORPHTARGETS_NORMAL: boolean;
  36735. MORPHTARGETS_TANGENT: boolean;
  36736. NUM_MORPH_INFLUENCERS: number;
  36737. NONUNIFORMSCALING: boolean;
  36738. PREMULTIPLYALPHA: boolean;
  36739. IMAGEPROCESSING: boolean;
  36740. VIGNETTE: boolean;
  36741. VIGNETTEBLENDMODEMULTIPLY: boolean;
  36742. VIGNETTEBLENDMODEOPAQUE: boolean;
  36743. TONEMAPPING: boolean;
  36744. TONEMAPPING_ACES: boolean;
  36745. CONTRAST: boolean;
  36746. COLORCURVES: boolean;
  36747. COLORGRADING: boolean;
  36748. COLORGRADING3D: boolean;
  36749. SAMPLER3DGREENDEPTH: boolean;
  36750. SAMPLER3DBGRMAP: boolean;
  36751. IMAGEPROCESSINGPOSTPROCESS: boolean;
  36752. /**
  36753. * If the reflection texture on this material is in linear color space
  36754. * @hidden
  36755. */
  36756. IS_REFLECTION_LINEAR: boolean;
  36757. /**
  36758. * If the refraction texture on this material is in linear color space
  36759. * @hidden
  36760. */
  36761. IS_REFRACTION_LINEAR: boolean;
  36762. EXPOSURE: boolean;
  36763. constructor();
  36764. setReflectionMode(modeToEnable: string): void;
  36765. }
  36766. /**
  36767. * This is the default material used in Babylon. It is the best trade off between quality
  36768. * and performances.
  36769. * @see http://doc.babylonjs.com/babylon101/materials
  36770. */
  36771. export class StandardMaterial extends PushMaterial {
  36772. private _diffuseTexture;
  36773. /**
  36774. * The basic texture of the material as viewed under a light.
  36775. */
  36776. diffuseTexture: Nullable<BaseTexture>;
  36777. private _ambientTexture;
  36778. /**
  36779. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  36780. */
  36781. ambientTexture: Nullable<BaseTexture>;
  36782. private _opacityTexture;
  36783. /**
  36784. * Define the transparency of the material from a texture.
  36785. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  36786. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  36787. */
  36788. opacityTexture: Nullable<BaseTexture>;
  36789. private _reflectionTexture;
  36790. /**
  36791. * Define the texture used to display the reflection.
  36792. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  36793. */
  36794. reflectionTexture: Nullable<BaseTexture>;
  36795. private _emissiveTexture;
  36796. /**
  36797. * Define texture of the material as if self lit.
  36798. * This will be mixed in the final result even in the absence of light.
  36799. */
  36800. emissiveTexture: Nullable<BaseTexture>;
  36801. private _specularTexture;
  36802. /**
  36803. * Define how the color and intensity of the highlight given by the light in the material.
  36804. */
  36805. specularTexture: Nullable<BaseTexture>;
  36806. private _bumpTexture;
  36807. /**
  36808. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  36809. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  36810. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  36811. */
  36812. bumpTexture: Nullable<BaseTexture>;
  36813. private _lightmapTexture;
  36814. /**
  36815. * Complex lighting can be computationally expensive to compute at runtime.
  36816. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  36817. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  36818. */
  36819. lightmapTexture: Nullable<BaseTexture>;
  36820. private _refractionTexture;
  36821. /**
  36822. * Define the texture used to display the refraction.
  36823. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  36824. */
  36825. refractionTexture: Nullable<BaseTexture>;
  36826. /**
  36827. * The color of the material lit by the environmental background lighting.
  36828. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  36829. */
  36830. ambientColor: Color3;
  36831. /**
  36832. * The basic color of the material as viewed under a light.
  36833. */
  36834. diffuseColor: Color3;
  36835. /**
  36836. * Define how the color and intensity of the highlight given by the light in the material.
  36837. */
  36838. specularColor: Color3;
  36839. /**
  36840. * Define the color of the material as if self lit.
  36841. * This will be mixed in the final result even in the absence of light.
  36842. */
  36843. emissiveColor: Color3;
  36844. /**
  36845. * Defines how sharp are the highlights in the material.
  36846. * The bigger the value the sharper giving a more glossy feeling to the result.
  36847. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  36848. */
  36849. specularPower: number;
  36850. private _useAlphaFromDiffuseTexture;
  36851. /**
  36852. * Does the transparency come from the diffuse texture alpha channel.
  36853. */
  36854. useAlphaFromDiffuseTexture: boolean;
  36855. private _useEmissiveAsIllumination;
  36856. /**
  36857. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  36858. */
  36859. useEmissiveAsIllumination: boolean;
  36860. private _linkEmissiveWithDiffuse;
  36861. /**
  36862. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  36863. * the emissive level when the final color is close to one.
  36864. */
  36865. linkEmissiveWithDiffuse: boolean;
  36866. private _useSpecularOverAlpha;
  36867. /**
  36868. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  36869. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  36870. */
  36871. useSpecularOverAlpha: boolean;
  36872. private _useReflectionOverAlpha;
  36873. /**
  36874. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  36875. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  36876. */
  36877. useReflectionOverAlpha: boolean;
  36878. private _disableLighting;
  36879. /**
  36880. * Does lights from the scene impacts this material.
  36881. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  36882. */
  36883. disableLighting: boolean;
  36884. private _useObjectSpaceNormalMap;
  36885. /**
  36886. * Allows using an object space normal map (instead of tangent space).
  36887. */
  36888. useObjectSpaceNormalMap: boolean;
  36889. private _useParallax;
  36890. /**
  36891. * Is parallax enabled or not.
  36892. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  36893. */
  36894. useParallax: boolean;
  36895. private _useParallaxOcclusion;
  36896. /**
  36897. * Is parallax occlusion enabled or not.
  36898. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  36899. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  36900. */
  36901. useParallaxOcclusion: boolean;
  36902. /**
  36903. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  36904. */
  36905. parallaxScaleBias: number;
  36906. private _roughness;
  36907. /**
  36908. * Helps to define how blurry the reflections should appears in the material.
  36909. */
  36910. roughness: number;
  36911. /**
  36912. * In case of refraction, define the value of the indice of refraction.
  36913. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  36914. */
  36915. indexOfRefraction: number;
  36916. /**
  36917. * Invert the refraction texture alongside the y axis.
  36918. * It can be useful with procedural textures or probe for instance.
  36919. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  36920. */
  36921. invertRefractionY: boolean;
  36922. /**
  36923. * Defines the alpha limits in alpha test mode.
  36924. */
  36925. alphaCutOff: number;
  36926. private _useLightmapAsShadowmap;
  36927. /**
  36928. * In case of light mapping, define whether the map contains light or shadow informations.
  36929. */
  36930. useLightmapAsShadowmap: boolean;
  36931. private _diffuseFresnelParameters;
  36932. /**
  36933. * Define the diffuse fresnel parameters of the material.
  36934. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36935. */
  36936. diffuseFresnelParameters: FresnelParameters;
  36937. private _opacityFresnelParameters;
  36938. /**
  36939. * Define the opacity fresnel parameters of the material.
  36940. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36941. */
  36942. opacityFresnelParameters: FresnelParameters;
  36943. private _reflectionFresnelParameters;
  36944. /**
  36945. * Define the reflection fresnel parameters of the material.
  36946. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36947. */
  36948. reflectionFresnelParameters: FresnelParameters;
  36949. private _refractionFresnelParameters;
  36950. /**
  36951. * Define the refraction fresnel parameters of the material.
  36952. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36953. */
  36954. refractionFresnelParameters: FresnelParameters;
  36955. private _emissiveFresnelParameters;
  36956. /**
  36957. * Define the emissive fresnel parameters of the material.
  36958. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36959. */
  36960. emissiveFresnelParameters: FresnelParameters;
  36961. private _useReflectionFresnelFromSpecular;
  36962. /**
  36963. * If true automatically deducts the fresnels values from the material specularity.
  36964. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36965. */
  36966. useReflectionFresnelFromSpecular: boolean;
  36967. private _useGlossinessFromSpecularMapAlpha;
  36968. /**
  36969. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  36970. */
  36971. useGlossinessFromSpecularMapAlpha: boolean;
  36972. private _maxSimultaneousLights;
  36973. /**
  36974. * Defines the maximum number of lights that can be used in the material
  36975. */
  36976. maxSimultaneousLights: number;
  36977. private _invertNormalMapX;
  36978. /**
  36979. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  36980. */
  36981. invertNormalMapX: boolean;
  36982. private _invertNormalMapY;
  36983. /**
  36984. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  36985. */
  36986. invertNormalMapY: boolean;
  36987. private _twoSidedLighting;
  36988. /**
  36989. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  36990. */
  36991. twoSidedLighting: boolean;
  36992. /**
  36993. * Default configuration related to image processing available in the standard Material.
  36994. */
  36995. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36996. /**
  36997. * Gets the image processing configuration used either in this material.
  36998. */
  36999. /**
  37000. * Sets the Default image processing configuration used either in the this material.
  37001. *
  37002. * If sets to null, the scene one is in use.
  37003. */
  37004. imageProcessingConfiguration: ImageProcessingConfiguration;
  37005. /**
  37006. * Keep track of the image processing observer to allow dispose and replace.
  37007. */
  37008. private _imageProcessingObserver;
  37009. /**
  37010. * Attaches a new image processing configuration to the Standard Material.
  37011. * @param configuration
  37012. */
  37013. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  37014. /**
  37015. * Gets wether the color curves effect is enabled.
  37016. */
  37017. /**
  37018. * Sets wether the color curves effect is enabled.
  37019. */
  37020. cameraColorCurvesEnabled: boolean;
  37021. /**
  37022. * Gets wether the color grading effect is enabled.
  37023. */
  37024. /**
  37025. * Gets wether the color grading effect is enabled.
  37026. */
  37027. cameraColorGradingEnabled: boolean;
  37028. /**
  37029. * Gets wether tonemapping is enabled or not.
  37030. */
  37031. /**
  37032. * Sets wether tonemapping is enabled or not
  37033. */
  37034. cameraToneMappingEnabled: boolean;
  37035. /**
  37036. * The camera exposure used on this material.
  37037. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37038. * This corresponds to a photographic exposure.
  37039. */
  37040. /**
  37041. * The camera exposure used on this material.
  37042. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37043. * This corresponds to a photographic exposure.
  37044. */
  37045. cameraExposure: number;
  37046. /**
  37047. * Gets The camera contrast used on this material.
  37048. */
  37049. /**
  37050. * Sets The camera contrast used on this material.
  37051. */
  37052. cameraContrast: number;
  37053. /**
  37054. * Gets the Color Grading 2D Lookup Texture.
  37055. */
  37056. /**
  37057. * Sets the Color Grading 2D Lookup Texture.
  37058. */
  37059. cameraColorGradingTexture: Nullable<BaseTexture>;
  37060. /**
  37061. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37062. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37063. * 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;
  37064. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37065. */
  37066. /**
  37067. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37068. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37069. * 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;
  37070. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37071. */
  37072. cameraColorCurves: Nullable<ColorCurves>;
  37073. /**
  37074. * Custom callback helping to override the default shader used in the material.
  37075. */
  37076. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  37077. protected _renderTargets: SmartArray<RenderTargetTexture>;
  37078. protected _worldViewProjectionMatrix: Matrix;
  37079. protected _globalAmbientColor: Color3;
  37080. protected _useLogarithmicDepth: boolean;
  37081. /**
  37082. * Instantiates a new standard material.
  37083. * This is the default material used in Babylon. It is the best trade off between quality
  37084. * and performances.
  37085. * @see http://doc.babylonjs.com/babylon101/materials
  37086. * @param name Define the name of the material in the scene
  37087. * @param scene Define the scene the material belong to
  37088. */
  37089. constructor(name: string, scene: Scene);
  37090. /**
  37091. * Gets a boolean indicating that current material needs to register RTT
  37092. */
  37093. readonly hasRenderTargetTextures: boolean;
  37094. /**
  37095. * Gets the current class name of the material e.g. "StandardMaterial"
  37096. * Mainly use in serialization.
  37097. * @returns the class name
  37098. */
  37099. getClassName(): string;
  37100. /**
  37101. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  37102. * You can try switching to logarithmic depth.
  37103. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  37104. */
  37105. useLogarithmicDepth: boolean;
  37106. /**
  37107. * Specifies if the material will require alpha blending
  37108. * @returns a boolean specifying if alpha blending is needed
  37109. */
  37110. needAlphaBlending(): boolean;
  37111. /**
  37112. * Specifies if this material should be rendered in alpha test mode
  37113. * @returns a boolean specifying if an alpha test is needed.
  37114. */
  37115. needAlphaTesting(): boolean;
  37116. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  37117. /**
  37118. * Get the texture used for alpha test purpose.
  37119. * @returns the diffuse texture in case of the standard material.
  37120. */
  37121. getAlphaTestTexture(): Nullable<BaseTexture>;
  37122. /**
  37123. * Get if the submesh is ready to be used and all its information available.
  37124. * Child classes can use it to update shaders
  37125. * @param mesh defines the mesh to check
  37126. * @param subMesh defines which submesh to check
  37127. * @param useInstances specifies that instances should be used
  37128. * @returns a boolean indicating that the submesh is ready or not
  37129. */
  37130. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  37131. /**
  37132. * Builds the material UBO layouts.
  37133. * Used internally during the effect preparation.
  37134. */
  37135. buildUniformLayout(): void;
  37136. /**
  37137. * Unbinds the material from the mesh
  37138. */
  37139. unbind(): void;
  37140. /**
  37141. * Binds the submesh to this material by preparing the effect and shader to draw
  37142. * @param world defines the world transformation matrix
  37143. * @param mesh defines the mesh containing the submesh
  37144. * @param subMesh defines the submesh to bind the material to
  37145. */
  37146. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  37147. /**
  37148. * Get the list of animatables in the material.
  37149. * @returns the list of animatables object used in the material
  37150. */
  37151. getAnimatables(): IAnimatable[];
  37152. /**
  37153. * Gets the active textures from the material
  37154. * @returns an array of textures
  37155. */
  37156. getActiveTextures(): BaseTexture[];
  37157. /**
  37158. * Specifies if the material uses a texture
  37159. * @param texture defines the texture to check against the material
  37160. * @returns a boolean specifying if the material uses the texture
  37161. */
  37162. hasTexture(texture: BaseTexture): boolean;
  37163. /**
  37164. * Disposes the material
  37165. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  37166. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  37167. */
  37168. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  37169. /**
  37170. * Makes a duplicate of the material, and gives it a new name
  37171. * @param name defines the new name for the duplicated material
  37172. * @returns the cloned material
  37173. */
  37174. clone(name: string): StandardMaterial;
  37175. /**
  37176. * Serializes this material in a JSON representation
  37177. * @returns the serialized material object
  37178. */
  37179. serialize(): any;
  37180. /**
  37181. * Creates a standard material from parsed material data
  37182. * @param source defines the JSON representation of the material
  37183. * @param scene defines the hosting scene
  37184. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  37185. * @returns a new standard material
  37186. */
  37187. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  37188. /**
  37189. * Are diffuse textures enabled in the application.
  37190. */
  37191. static DiffuseTextureEnabled: boolean;
  37192. /**
  37193. * Are ambient textures enabled in the application.
  37194. */
  37195. static AmbientTextureEnabled: boolean;
  37196. /**
  37197. * Are opacity textures enabled in the application.
  37198. */
  37199. static OpacityTextureEnabled: boolean;
  37200. /**
  37201. * Are reflection textures enabled in the application.
  37202. */
  37203. static ReflectionTextureEnabled: boolean;
  37204. /**
  37205. * Are emissive textures enabled in the application.
  37206. */
  37207. static EmissiveTextureEnabled: boolean;
  37208. /**
  37209. * Are specular textures enabled in the application.
  37210. */
  37211. static SpecularTextureEnabled: boolean;
  37212. /**
  37213. * Are bump textures enabled in the application.
  37214. */
  37215. static BumpTextureEnabled: boolean;
  37216. /**
  37217. * Are lightmap textures enabled in the application.
  37218. */
  37219. static LightmapTextureEnabled: boolean;
  37220. /**
  37221. * Are refraction textures enabled in the application.
  37222. */
  37223. static RefractionTextureEnabled: boolean;
  37224. /**
  37225. * Are color grading textures enabled in the application.
  37226. */
  37227. static ColorGradingTextureEnabled: boolean;
  37228. /**
  37229. * Are fresnels enabled in the application.
  37230. */
  37231. static FresnelEnabled: boolean;
  37232. }
  37233. }
  37234. declare module BABYLON {
  37235. /**
  37236. * A class extending Texture allowing drawing on a texture
  37237. * @see http://doc.babylonjs.com/how_to/dynamictexture
  37238. */
  37239. export class DynamicTexture extends Texture {
  37240. private _generateMipMaps;
  37241. private _canvas;
  37242. private _context;
  37243. private _engine;
  37244. /**
  37245. * Creates a DynamicTexture
  37246. * @param name defines the name of the texture
  37247. * @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
  37248. * @param scene defines the scene where you want the texture
  37249. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  37250. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  37251. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  37252. */
  37253. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  37254. /**
  37255. * Get the current class name of the texture useful for serialization or dynamic coding.
  37256. * @returns "DynamicTexture"
  37257. */
  37258. getClassName(): string;
  37259. /**
  37260. * Gets the current state of canRescale
  37261. */
  37262. readonly canRescale: boolean;
  37263. private _recreate;
  37264. /**
  37265. * Scales the texture
  37266. * @param ratio the scale factor to apply to both width and height
  37267. */
  37268. scale(ratio: number): void;
  37269. /**
  37270. * Resizes the texture
  37271. * @param width the new width
  37272. * @param height the new height
  37273. */
  37274. scaleTo(width: number, height: number): void;
  37275. /**
  37276. * Gets the context of the canvas used by the texture
  37277. * @returns the canvas context of the dynamic texture
  37278. */
  37279. getContext(): CanvasRenderingContext2D;
  37280. /**
  37281. * Clears the texture
  37282. */
  37283. clear(): void;
  37284. /**
  37285. * Updates the texture
  37286. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37287. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  37288. */
  37289. update(invertY?: boolean, premulAlpha?: boolean): void;
  37290. /**
  37291. * Draws text onto the texture
  37292. * @param text defines the text to be drawn
  37293. * @param x defines the placement of the text from the left
  37294. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  37295. * @param font defines the font to be used with font-style, font-size, font-name
  37296. * @param color defines the color used for the text
  37297. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  37298. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37299. * @param update defines whether texture is immediately update (default is true)
  37300. */
  37301. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  37302. /**
  37303. * Clones the texture
  37304. * @returns the clone of the texture.
  37305. */
  37306. clone(): DynamicTexture;
  37307. /**
  37308. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  37309. * @returns a serialized dynamic texture object
  37310. */
  37311. serialize(): any;
  37312. /** @hidden */ rebuild(): void;
  37313. }
  37314. }
  37315. declare module BABYLON {
  37316. /** @hidden */
  37317. export var imageProcessingPixelShader: {
  37318. name: string;
  37319. shader: string;
  37320. };
  37321. }
  37322. declare module BABYLON {
  37323. /**
  37324. * ImageProcessingPostProcess
  37325. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  37326. */
  37327. export class ImageProcessingPostProcess extends PostProcess {
  37328. /**
  37329. * Default configuration related to image processing available in the PBR Material.
  37330. */
  37331. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37332. /**
  37333. * Gets the image processing configuration used either in this material.
  37334. */
  37335. /**
  37336. * Sets the Default image processing configuration used either in the this material.
  37337. *
  37338. * If sets to null, the scene one is in use.
  37339. */
  37340. imageProcessingConfiguration: ImageProcessingConfiguration;
  37341. /**
  37342. * Keep track of the image processing observer to allow dispose and replace.
  37343. */
  37344. private _imageProcessingObserver;
  37345. /**
  37346. * Attaches a new image processing configuration to the PBR Material.
  37347. * @param configuration
  37348. */
  37349. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  37350. /**
  37351. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  37352. */
  37353. /**
  37354. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  37355. */
  37356. colorCurves: Nullable<ColorCurves>;
  37357. /**
  37358. * Gets wether the color curves effect is enabled.
  37359. */
  37360. /**
  37361. * Sets wether the color curves effect is enabled.
  37362. */
  37363. colorCurvesEnabled: boolean;
  37364. /**
  37365. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  37366. */
  37367. /**
  37368. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  37369. */
  37370. colorGradingTexture: Nullable<BaseTexture>;
  37371. /**
  37372. * Gets wether the color grading effect is enabled.
  37373. */
  37374. /**
  37375. * Gets wether the color grading effect is enabled.
  37376. */
  37377. colorGradingEnabled: boolean;
  37378. /**
  37379. * Gets exposure used in the effect.
  37380. */
  37381. /**
  37382. * Sets exposure used in the effect.
  37383. */
  37384. exposure: number;
  37385. /**
  37386. * Gets wether tonemapping is enabled or not.
  37387. */
  37388. /**
  37389. * Sets wether tonemapping is enabled or not
  37390. */
  37391. toneMappingEnabled: boolean;
  37392. /**
  37393. * Gets contrast used in the effect.
  37394. */
  37395. /**
  37396. * Sets contrast used in the effect.
  37397. */
  37398. contrast: number;
  37399. /**
  37400. * Gets Vignette stretch size.
  37401. */
  37402. /**
  37403. * Sets Vignette stretch size.
  37404. */
  37405. vignetteStretch: number;
  37406. /**
  37407. * Gets Vignette centre X Offset.
  37408. */
  37409. /**
  37410. * Sets Vignette centre X Offset.
  37411. */
  37412. vignetteCentreX: number;
  37413. /**
  37414. * Gets Vignette centre Y Offset.
  37415. */
  37416. /**
  37417. * Sets Vignette centre Y Offset.
  37418. */
  37419. vignetteCentreY: number;
  37420. /**
  37421. * Gets Vignette weight or intensity of the vignette effect.
  37422. */
  37423. /**
  37424. * Sets Vignette weight or intensity of the vignette effect.
  37425. */
  37426. vignetteWeight: number;
  37427. /**
  37428. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  37429. * if vignetteEnabled is set to true.
  37430. */
  37431. /**
  37432. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  37433. * if vignetteEnabled is set to true.
  37434. */
  37435. vignetteColor: Color4;
  37436. /**
  37437. * Gets Camera field of view used by the Vignette effect.
  37438. */
  37439. /**
  37440. * Sets Camera field of view used by the Vignette effect.
  37441. */
  37442. vignetteCameraFov: number;
  37443. /**
  37444. * Gets the vignette blend mode allowing different kind of effect.
  37445. */
  37446. /**
  37447. * Sets the vignette blend mode allowing different kind of effect.
  37448. */
  37449. vignetteBlendMode: number;
  37450. /**
  37451. * Gets wether the vignette effect is enabled.
  37452. */
  37453. /**
  37454. * Sets wether the vignette effect is enabled.
  37455. */
  37456. vignetteEnabled: boolean;
  37457. private _fromLinearSpace;
  37458. /**
  37459. * Gets wether the input of the processing is in Gamma or Linear Space.
  37460. */
  37461. /**
  37462. * Sets wether the input of the processing is in Gamma or Linear Space.
  37463. */
  37464. fromLinearSpace: boolean;
  37465. /**
  37466. * Defines cache preventing GC.
  37467. */
  37468. private _defines;
  37469. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  37470. /**
  37471. * "ImageProcessingPostProcess"
  37472. * @returns "ImageProcessingPostProcess"
  37473. */
  37474. getClassName(): string;
  37475. protected _updateParameters(): void;
  37476. dispose(camera?: Camera): void;
  37477. }
  37478. }
  37479. declare module BABYLON {
  37480. /**
  37481. * Class containing static functions to help procedurally build meshes
  37482. */
  37483. export class GroundBuilder {
  37484. /**
  37485. * Creates a ground mesh
  37486. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  37487. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  37488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37489. * @param name defines the name of the mesh
  37490. * @param options defines the options used to create the mesh
  37491. * @param scene defines the hosting scene
  37492. * @returns the ground mesh
  37493. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  37494. */
  37495. static CreateGround(name: string, options: {
  37496. width?: number;
  37497. height?: number;
  37498. subdivisions?: number;
  37499. subdivisionsX?: number;
  37500. subdivisionsY?: number;
  37501. updatable?: boolean;
  37502. }, scene: any): Mesh;
  37503. /**
  37504. * Creates a tiled ground mesh
  37505. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  37506. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  37507. * * 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
  37508. * * 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
  37509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  37510. * @param name defines the name of the mesh
  37511. * @param options defines the options used to create the mesh
  37512. * @param scene defines the hosting scene
  37513. * @returns the tiled ground mesh
  37514. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  37515. */
  37516. static CreateTiledGround(name: string, options: {
  37517. xmin: number;
  37518. zmin: number;
  37519. xmax: number;
  37520. zmax: number;
  37521. subdivisions?: {
  37522. w: number;
  37523. h: number;
  37524. };
  37525. precision?: {
  37526. w: number;
  37527. h: number;
  37528. };
  37529. updatable?: boolean;
  37530. }, scene: Scene): Mesh;
  37531. /**
  37532. * Creates a ground mesh from a height map
  37533. * * The parameter `url` sets the URL of the height map image resource.
  37534. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  37535. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  37536. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  37537. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  37538. * * 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.
  37539. * * 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).
  37540. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  37541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  37542. * @param name defines the name of the mesh
  37543. * @param url defines the url to the height map
  37544. * @param options defines the options used to create the mesh
  37545. * @param scene defines the hosting scene
  37546. * @returns the ground mesh
  37547. * @see https://doc.babylonjs.com/babylon101/height_map
  37548. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  37549. */
  37550. static CreateGroundFromHeightMap(name: string, url: string, options: {
  37551. width?: number;
  37552. height?: number;
  37553. subdivisions?: number;
  37554. minHeight?: number;
  37555. maxHeight?: number;
  37556. colorFilter?: Color3;
  37557. alphaFilter?: number;
  37558. updatable?: boolean;
  37559. onReady?: (mesh: GroundMesh) => void;
  37560. }, scene: Scene): GroundMesh;
  37561. }
  37562. }
  37563. declare module BABYLON {
  37564. /**
  37565. * Class containing static functions to help procedurally build meshes
  37566. */
  37567. export class TorusBuilder {
  37568. /**
  37569. * Creates a torus mesh
  37570. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  37571. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  37572. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  37573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37574. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  37576. * @param name defines the name of the mesh
  37577. * @param options defines the options used to create the mesh
  37578. * @param scene defines the hosting scene
  37579. * @returns the torus mesh
  37580. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  37581. */
  37582. static CreateTorus(name: string, options: {
  37583. diameter?: number;
  37584. thickness?: number;
  37585. tessellation?: number;
  37586. updatable?: boolean;
  37587. sideOrientation?: number;
  37588. frontUVs?: Vector4;
  37589. backUVs?: Vector4;
  37590. }, scene: any): Mesh;
  37591. }
  37592. }
  37593. declare module BABYLON {
  37594. /**
  37595. * Class containing static functions to help procedurally build meshes
  37596. */
  37597. export class CylinderBuilder {
  37598. /**
  37599. * Creates a cylinder or a cone mesh
  37600. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  37601. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  37602. * * 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.
  37603. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  37604. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  37605. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  37606. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  37607. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  37608. * * 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).
  37609. * * 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
  37610. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  37611. * * 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
  37612. * * 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.
  37613. * * If `enclose` is false, a ring surface is one element.
  37614. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  37615. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  37616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37617. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  37619. * @param name defines the name of the mesh
  37620. * @param options defines the options used to create the mesh
  37621. * @param scene defines the hosting scene
  37622. * @returns the cylinder mesh
  37623. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  37624. */
  37625. static CreateCylinder(name: string, options: {
  37626. height?: number;
  37627. diameterTop?: number;
  37628. diameterBottom?: number;
  37629. diameter?: number;
  37630. tessellation?: number;
  37631. subdivisions?: number;
  37632. arc?: number;
  37633. faceColors?: Color4[];
  37634. faceUV?: Vector4[];
  37635. updatable?: boolean;
  37636. hasRings?: boolean;
  37637. enclose?: boolean;
  37638. sideOrientation?: number;
  37639. frontUVs?: Vector4;
  37640. backUVs?: Vector4;
  37641. }, scene: any): Mesh;
  37642. }
  37643. }
  37644. declare module BABYLON {
  37645. /**
  37646. * Options to modify the vr teleportation behavior.
  37647. */
  37648. export interface VRTeleportationOptions {
  37649. /**
  37650. * The name of the mesh which should be used as the teleportation floor. (default: null)
  37651. */
  37652. floorMeshName?: string;
  37653. /**
  37654. * A list of meshes to be used as the teleportation floor. (default: empty)
  37655. */
  37656. floorMeshes?: Mesh[];
  37657. }
  37658. /**
  37659. * Options to modify the vr experience helper's behavior.
  37660. */
  37661. export interface VRExperienceHelperOptions extends WebVROptions {
  37662. /**
  37663. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  37664. */
  37665. createDeviceOrientationCamera?: boolean;
  37666. /**
  37667. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  37668. */
  37669. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  37670. /**
  37671. * Uses the main button on the controller to toggle the laser casted. (default: true)
  37672. */
  37673. laserToggle?: boolean;
  37674. /**
  37675. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  37676. */
  37677. floorMeshes?: Mesh[];
  37678. }
  37679. /**
  37680. * Helps to quickly add VR support to an existing scene.
  37681. * See http://doc.babylonjs.com/how_to/webvr_helper
  37682. */
  37683. export class VRExperienceHelper {
  37684. /** Options to modify the vr experience helper's behavior. */
  37685. webVROptions: VRExperienceHelperOptions;
  37686. private _scene;
  37687. private _position;
  37688. private _btnVR;
  37689. private _btnVRDisplayed;
  37690. private _webVRsupported;
  37691. private _webVRready;
  37692. private _webVRrequesting;
  37693. private _webVRpresenting;
  37694. private _hasEnteredVR;
  37695. private _fullscreenVRpresenting;
  37696. private _canvas;
  37697. private _webVRCamera;
  37698. private _vrDeviceOrientationCamera;
  37699. private _deviceOrientationCamera;
  37700. private _existingCamera;
  37701. private _onKeyDown;
  37702. private _onVrDisplayPresentChange;
  37703. private _onVRDisplayChanged;
  37704. private _onVRRequestPresentStart;
  37705. private _onVRRequestPresentComplete;
  37706. /**
  37707. * Observable raised when entering VR.
  37708. */
  37709. onEnteringVRObservable: Observable<VRExperienceHelper>;
  37710. /**
  37711. * Observable raised when exiting VR.
  37712. */
  37713. onExitingVRObservable: Observable<VRExperienceHelper>;
  37714. /**
  37715. * Observable raised when controller mesh is loaded.
  37716. */
  37717. onControllerMeshLoadedObservable: Observable<WebVRController>;
  37718. /** Return this.onEnteringVRObservable
  37719. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  37720. */
  37721. readonly onEnteringVR: Observable<VRExperienceHelper>;
  37722. /** Return this.onExitingVRObservable
  37723. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  37724. */
  37725. readonly onExitingVR: Observable<VRExperienceHelper>;
  37726. /** Return this.onControllerMeshLoadedObservable
  37727. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  37728. */
  37729. readonly onControllerMeshLoaded: Observable<WebVRController>;
  37730. private _rayLength;
  37731. private _useCustomVRButton;
  37732. private _teleportationRequested;
  37733. private _teleportActive;
  37734. private _floorMeshName;
  37735. private _floorMeshesCollection;
  37736. private _rotationAllowed;
  37737. private _teleportBackwardsVector;
  37738. private _teleportationTarget;
  37739. private _isDefaultTeleportationTarget;
  37740. private _postProcessMove;
  37741. private _teleportationFillColor;
  37742. private _teleportationBorderColor;
  37743. private _rotationAngle;
  37744. private _haloCenter;
  37745. private _cameraGazer;
  37746. private _padSensibilityUp;
  37747. private _padSensibilityDown;
  37748. private _leftController;
  37749. private _rightController;
  37750. /**
  37751. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  37752. */
  37753. onNewMeshSelected: Observable<AbstractMesh>;
  37754. /**
  37755. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  37756. */
  37757. onNewMeshPicked: Observable<PickingInfo>;
  37758. private _circleEase;
  37759. /**
  37760. * Observable raised before camera teleportation
  37761. */
  37762. onBeforeCameraTeleport: Observable<Vector3>;
  37763. /**
  37764. * Observable raised after camera teleportation
  37765. */
  37766. onAfterCameraTeleport: Observable<Vector3>;
  37767. /**
  37768. * Observable raised when current selected mesh gets unselected
  37769. */
  37770. onSelectedMeshUnselected: Observable<AbstractMesh>;
  37771. private _raySelectionPredicate;
  37772. /**
  37773. * To be optionaly changed by user to define custom ray selection
  37774. */
  37775. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  37776. /**
  37777. * To be optionaly changed by user to define custom selection logic (after ray selection)
  37778. */
  37779. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  37780. /**
  37781. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  37782. */
  37783. teleportationEnabled: boolean;
  37784. private _defaultHeight;
  37785. private _teleportationInitialized;
  37786. private _interactionsEnabled;
  37787. private _interactionsRequested;
  37788. private _displayGaze;
  37789. private _displayLaserPointer;
  37790. /**
  37791. * The mesh used to display where the user is going to teleport.
  37792. */
  37793. /**
  37794. * Sets the mesh to be used to display where the user is going to teleport.
  37795. */
  37796. teleportationTarget: Mesh;
  37797. /**
  37798. * 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
  37799. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  37800. * See http://doc.babylonjs.com/resources/baking_transformations
  37801. */
  37802. gazeTrackerMesh: Mesh;
  37803. /**
  37804. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  37805. */
  37806. updateGazeTrackerScale: boolean;
  37807. /**
  37808. * If the gaze trackers color should be updated when selecting meshes
  37809. */
  37810. updateGazeTrackerColor: boolean;
  37811. /**
  37812. * The gaze tracking mesh corresponding to the left controller
  37813. */
  37814. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  37815. /**
  37816. * The gaze tracking mesh corresponding to the right controller
  37817. */
  37818. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  37819. /**
  37820. * If the ray of the gaze should be displayed.
  37821. */
  37822. /**
  37823. * Sets if the ray of the gaze should be displayed.
  37824. */
  37825. displayGaze: boolean;
  37826. /**
  37827. * If the ray of the LaserPointer should be displayed.
  37828. */
  37829. /**
  37830. * Sets if the ray of the LaserPointer should be displayed.
  37831. */
  37832. displayLaserPointer: boolean;
  37833. /**
  37834. * The deviceOrientationCamera used as the camera when not in VR.
  37835. */
  37836. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  37837. /**
  37838. * Based on the current WebVR support, returns the current VR camera used.
  37839. */
  37840. readonly currentVRCamera: Nullable<Camera>;
  37841. /**
  37842. * The webVRCamera which is used when in VR.
  37843. */
  37844. readonly webVRCamera: WebVRFreeCamera;
  37845. /**
  37846. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  37847. */
  37848. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  37849. private readonly _teleportationRequestInitiated;
  37850. /**
  37851. * Instantiates a VRExperienceHelper.
  37852. * Helps to quickly add VR support to an existing scene.
  37853. * @param scene The scene the VRExperienceHelper belongs to.
  37854. * @param webVROptions Options to modify the vr experience helper's behavior.
  37855. */
  37856. constructor(scene: Scene,
  37857. /** Options to modify the vr experience helper's behavior. */
  37858. webVROptions?: VRExperienceHelperOptions);
  37859. private _onDefaultMeshLoaded;
  37860. private _onResize;
  37861. private _onFullscreenChange;
  37862. /**
  37863. * Gets a value indicating if we are currently in VR mode.
  37864. */
  37865. readonly isInVRMode: boolean;
  37866. private onVrDisplayPresentChange;
  37867. private onVRDisplayChanged;
  37868. private moveButtonToBottomRight;
  37869. private displayVRButton;
  37870. private updateButtonVisibility;
  37871. private _cachedAngularSensibility;
  37872. /**
  37873. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  37874. * Otherwise, will use the fullscreen API.
  37875. */
  37876. enterVR(): void;
  37877. /**
  37878. * Attempt to exit VR, or fullscreen.
  37879. */
  37880. exitVR(): void;
  37881. /**
  37882. * The position of the vr experience helper.
  37883. */
  37884. /**
  37885. * Sets the position of the vr experience helper.
  37886. */
  37887. position: Vector3;
  37888. /**
  37889. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  37890. */
  37891. enableInteractions(): void;
  37892. private readonly _noControllerIsActive;
  37893. private beforeRender;
  37894. private _isTeleportationFloor;
  37895. /**
  37896. * Adds a floor mesh to be used for teleportation.
  37897. * @param floorMesh the mesh to be used for teleportation.
  37898. */
  37899. addFloorMesh(floorMesh: Mesh): void;
  37900. /**
  37901. * Removes a floor mesh from being used for teleportation.
  37902. * @param floorMesh the mesh to be removed.
  37903. */
  37904. removeFloorMesh(floorMesh: Mesh): void;
  37905. /**
  37906. * Enables interactions and teleportation using the VR controllers and gaze.
  37907. * @param vrTeleportationOptions options to modify teleportation behavior.
  37908. */
  37909. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  37910. private _onNewGamepadConnected;
  37911. private _tryEnableInteractionOnController;
  37912. private _onNewGamepadDisconnected;
  37913. private _enableInteractionOnController;
  37914. private _checkTeleportWithRay;
  37915. private _checkRotate;
  37916. private _checkTeleportBackwards;
  37917. private _enableTeleportationOnController;
  37918. private _createTeleportationCircles;
  37919. private _displayTeleportationTarget;
  37920. private _hideTeleportationTarget;
  37921. private _rotateCamera;
  37922. private _moveTeleportationSelectorTo;
  37923. private _workingVector;
  37924. private _workingQuaternion;
  37925. private _workingMatrix;
  37926. /**
  37927. * Teleports the users feet to the desired location
  37928. * @param location The location where the user's feet should be placed
  37929. */
  37930. teleportCamera(location: Vector3): void;
  37931. private _convertNormalToDirectionOfRay;
  37932. private _castRayAndSelectObject;
  37933. private _notifySelectedMeshUnselected;
  37934. /**
  37935. * Sets the color of the laser ray from the vr controllers.
  37936. * @param color new color for the ray.
  37937. */
  37938. changeLaserColor(color: Color3): void;
  37939. /**
  37940. * Sets the color of the ray from the vr headsets gaze.
  37941. * @param color new color for the ray.
  37942. */
  37943. changeGazeColor(color: Color3): void;
  37944. /**
  37945. * Exits VR and disposes of the vr experience helper
  37946. */
  37947. dispose(): void;
  37948. /**
  37949. * Gets the name of the VRExperienceHelper class
  37950. * @returns "VRExperienceHelper"
  37951. */
  37952. getClassName(): string;
  37953. }
  37954. }
  37955. declare module BABYLON {
  37956. /**
  37957. * Manages an XRSession
  37958. * @see https://doc.babylonjs.com/how_to/webxr
  37959. */
  37960. export class WebXRSessionManager implements IDisposable {
  37961. private scene;
  37962. /**
  37963. * Fires every time a new xrFrame arrives which can be used to update the camera
  37964. */
  37965. onXRFrameObservable: Observable<any>;
  37966. /**
  37967. * Fires when the xr session is ended either by the device or manually done
  37968. */
  37969. onXRSessionEnded: Observable<any>;
  37970. /** @hidden */ xrSession: XRSession;
  37971. /** @hidden */ frameOfReference: XRFrameOfReference;
  37972. /** @hidden */ sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  37973. /** @hidden */ currentXRFrame: Nullable<XRFrame>;
  37974. private _xrNavigator;
  37975. private _xrDevice;
  37976. private _tmpMatrix;
  37977. /**
  37978. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  37979. * @param scene The scene which the session should be created for
  37980. */
  37981. constructor(scene: Scene);
  37982. /**
  37983. * Initializes the manager
  37984. * After initialization enterXR can be called to start an XR session
  37985. * @returns Promise which resolves after it is initialized
  37986. */
  37987. initializeAsync(): Promise<void>;
  37988. /**
  37989. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  37990. * @param sessionCreationOptions xr options to create the session with
  37991. * @param frameOfReferenceType option to configure how the xr pose is expressed
  37992. * @returns Promise which resolves after it enters XR
  37993. */
  37994. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  37995. /**
  37996. * Stops the xrSession and restores the renderloop
  37997. * @returns Promise which resolves after it exits XR
  37998. */
  37999. exitXRAsync(): Promise<void>;
  38000. /**
  38001. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38002. * @param ray ray to cast into the environment
  38003. * @returns Promise which resolves with a collision point in the environment if it exists
  38004. */
  38005. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38006. /**
  38007. * Checks if a session would be supported for the creation options specified
  38008. * @param options creation options to check if they are supported
  38009. * @returns true if supported
  38010. */
  38011. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38012. /**
  38013. * @hidden
  38014. * Converts the render layer of xrSession to a render target
  38015. * @param session session to create render target for
  38016. * @param scene scene the new render target should be created for
  38017. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  38018. /**
  38019. * Disposes of the session manager
  38020. */
  38021. dispose(): void;
  38022. }
  38023. }
  38024. declare module BABYLON {
  38025. /**
  38026. * WebXR Camera which holds the views for the xrSession
  38027. * @see https://doc.babylonjs.com/how_to/webxr
  38028. */
  38029. export class WebXRCamera extends FreeCamera {
  38030. private static _TmpMatrix;
  38031. /**
  38032. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  38033. * @param name the name of the camera
  38034. * @param scene the scene to add the camera to
  38035. */
  38036. constructor(name: string, scene: Scene);
  38037. private _updateNumberOfRigCameras;
  38038. /** @hidden */ updateForDualEyeDebugging(pupilDistance?: number): void;
  38039. /**
  38040. * Updates the cameras position from the current pose information of the XR session
  38041. * @param xrSessionManager the session containing pose information
  38042. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  38043. */
  38044. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  38045. }
  38046. }
  38047. declare module BABYLON {
  38048. /**
  38049. * States of the webXR experience
  38050. */
  38051. export enum WebXRState {
  38052. /**
  38053. * Transitioning to being in XR mode
  38054. */
  38055. ENTERING_XR = 0,
  38056. /**
  38057. * Transitioning to non XR mode
  38058. */
  38059. EXITING_XR = 1,
  38060. /**
  38061. * In XR mode and presenting
  38062. */
  38063. IN_XR = 2,
  38064. /**
  38065. * Not entered XR mode
  38066. */
  38067. NOT_IN_XR = 3
  38068. }
  38069. /**
  38070. * Helper class used to enable XR
  38071. * @see https://doc.babylonjs.com/how_to/webxr
  38072. */
  38073. export class WebXRExperienceHelper implements IDisposable {
  38074. private scene;
  38075. /**
  38076. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  38077. */
  38078. container: AbstractMesh;
  38079. /**
  38080. * Camera used to render xr content
  38081. */
  38082. camera: WebXRCamera;
  38083. /**
  38084. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  38085. */
  38086. state: WebXRState;
  38087. private _setState;
  38088. private static _TmpVector;
  38089. /**
  38090. * Fires when the state of the experience helper has changed
  38091. */
  38092. onStateChangedObservable: Observable<WebXRState>;
  38093. /** @hidden */ sessionManager: WebXRSessionManager;
  38094. private _nonVRCamera;
  38095. private _originalSceneAutoClear;
  38096. private _supported;
  38097. /**
  38098. * Creates the experience helper
  38099. * @param scene the scene to attach the experience helper to
  38100. * @returns a promise for the experience helper
  38101. */
  38102. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  38103. /**
  38104. * Creates a WebXRExperienceHelper
  38105. * @param scene The scene the helper should be created in
  38106. */
  38107. private constructor();
  38108. /**
  38109. * Exits XR mode and returns the scene to its original state
  38110. * @returns promise that resolves after xr mode has exited
  38111. */
  38112. exitXRAsync(): Promise<void>;
  38113. /**
  38114. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  38115. * @param sessionCreationOptions options for the XR session
  38116. * @param frameOfReference frame of reference of the XR session
  38117. * @returns promise that resolves after xr mode has entered
  38118. */
  38119. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  38120. /**
  38121. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38122. * @param ray ray to cast into the environment
  38123. * @returns Promise which resolves with a collision point in the environment if it exists
  38124. */
  38125. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38126. /**
  38127. * Updates the global position of the camera by moving the camera's container
  38128. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  38129. * @param position The desired global position of the camera
  38130. */
  38131. setPositionOfCameraUsingContainer(position: Vector3): void;
  38132. /**
  38133. * Rotates the xr camera by rotating the camera's container around the camera's position
  38134. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  38135. * @param rotation the desired quaternion rotation to apply to the camera
  38136. */
  38137. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  38138. /**
  38139. * Checks if the creation options are supported by the xr session
  38140. * @param options creation options
  38141. * @returns true if supported
  38142. */
  38143. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38144. /**
  38145. * Disposes of the experience helper
  38146. */
  38147. dispose(): void;
  38148. }
  38149. }
  38150. declare module BABYLON {
  38151. /**
  38152. * Button which can be used to enter a different mode of XR
  38153. */
  38154. export class WebXREnterExitUIButton {
  38155. /** button element */
  38156. element: HTMLElement;
  38157. /** XR initialization options for the button */
  38158. initializationOptions: XRSessionCreationOptions;
  38159. /**
  38160. * Creates a WebXREnterExitUIButton
  38161. * @param element button element
  38162. * @param initializationOptions XR initialization options for the button
  38163. */
  38164. constructor(
  38165. /** button element */
  38166. element: HTMLElement,
  38167. /** XR initialization options for the button */
  38168. initializationOptions: XRSessionCreationOptions);
  38169. /**
  38170. * Overwritable function which can be used to update the button's visuals when the state changes
  38171. * @param activeButton the current active button in the UI
  38172. */
  38173. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  38174. }
  38175. /**
  38176. * Options to create the webXR UI
  38177. */
  38178. export class WebXREnterExitUIOptions {
  38179. /**
  38180. * Context to enter xr with
  38181. */
  38182. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  38183. /**
  38184. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  38185. */
  38186. customButtons?: Array<WebXREnterExitUIButton>;
  38187. }
  38188. /**
  38189. * UI to allow the user to enter/exit XR mode
  38190. */
  38191. export class WebXREnterExitUI implements IDisposable {
  38192. private scene;
  38193. private _overlay;
  38194. private _buttons;
  38195. private _activeButton;
  38196. /**
  38197. * Fired every time the active button is changed.
  38198. *
  38199. * When xr is entered via a button that launches xr that button will be the callback parameter
  38200. *
  38201. * When exiting xr the callback parameter will be null)
  38202. */
  38203. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  38204. /**
  38205. * Creates UI to allow the user to enter/exit XR mode
  38206. * @param scene the scene to add the ui to
  38207. * @param helper the xr experience helper to enter/exit xr with
  38208. * @param options options to configure the UI
  38209. * @returns the created ui
  38210. */
  38211. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  38212. private constructor();
  38213. private _updateButtons;
  38214. /**
  38215. * Disposes of the object
  38216. */
  38217. dispose(): void;
  38218. }
  38219. }
  38220. declare module BABYLON {
  38221. /**
  38222. * Represents an XR input
  38223. */
  38224. export class WebXRController {
  38225. /**
  38226. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  38227. */
  38228. grip?: AbstractMesh;
  38229. /**
  38230. * Pointer which can be used to select objects or attach a visible laser to
  38231. */
  38232. pointer: AbstractMesh;
  38233. /**
  38234. * Creates the controller
  38235. * @see https://doc.babylonjs.com/how_to/webxr
  38236. * @param scene the scene which the controller should be associated to
  38237. */
  38238. constructor(scene: Scene);
  38239. /**
  38240. * Disposes of the object
  38241. */
  38242. dispose(): void;
  38243. }
  38244. /**
  38245. * XR input used to track XR inputs such as controllers/rays
  38246. */
  38247. export class WebXRInput implements IDisposable {
  38248. private helper;
  38249. /**
  38250. * XR controllers being tracked
  38251. */
  38252. controllers: Array<WebXRController>;
  38253. private _tmpMatrix;
  38254. private _frameObserver;
  38255. /**
  38256. * Initializes the WebXRInput
  38257. * @param helper experience helper which the input should be created for
  38258. */
  38259. constructor(helper: WebXRExperienceHelper);
  38260. /**
  38261. * Disposes of the object
  38262. */
  38263. dispose(): void;
  38264. }
  38265. }
  38266. declare module BABYLON {
  38267. /**
  38268. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  38269. */
  38270. export class WebXRManagedOutputCanvas implements IDisposable {
  38271. private _canvas;
  38272. /**
  38273. * xrpresent context of the canvas which can be used to display/mirror xr content
  38274. */
  38275. canvasContext: Nullable<WebGLRenderingContext>;
  38276. /**
  38277. * Initializes the canvas to be added/removed upon entering/exiting xr
  38278. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  38279. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  38280. */
  38281. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  38282. /**
  38283. * Disposes of the object
  38284. */
  38285. dispose(): void;
  38286. private _setManagedOutputCanvas;
  38287. private _addCanvas;
  38288. private _removeCanvas;
  38289. }
  38290. }
  38291. declare module BABYLON {
  38292. /**
  38293. * Contains an array of blocks representing the octree
  38294. */
  38295. export interface IOctreeContainer<T> {
  38296. /**
  38297. * Blocks within the octree
  38298. */
  38299. blocks: Array<OctreeBlock<T>>;
  38300. }
  38301. /**
  38302. * Class used to store a cell in an octree
  38303. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38304. */
  38305. export class OctreeBlock<T> {
  38306. /**
  38307. * Gets the content of the current block
  38308. */
  38309. entries: T[];
  38310. /**
  38311. * Gets the list of block children
  38312. */
  38313. blocks: Array<OctreeBlock<T>>;
  38314. private _depth;
  38315. private _maxDepth;
  38316. private _capacity;
  38317. private _minPoint;
  38318. private _maxPoint;
  38319. private _boundingVectors;
  38320. private _creationFunc;
  38321. /**
  38322. * Creates a new block
  38323. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  38324. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  38325. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  38326. * @param depth defines the current depth of this block in the octree
  38327. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  38328. * @param creationFunc defines a callback to call when an element is added to the block
  38329. */
  38330. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  38331. /**
  38332. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  38333. */
  38334. readonly capacity: number;
  38335. /**
  38336. * Gets the minimum vector (in world space) of the block's bounding box
  38337. */
  38338. readonly minPoint: Vector3;
  38339. /**
  38340. * Gets the maximum vector (in world space) of the block's bounding box
  38341. */
  38342. readonly maxPoint: Vector3;
  38343. /**
  38344. * Add a new element to this block
  38345. * @param entry defines the element to add
  38346. */
  38347. addEntry(entry: T): void;
  38348. /**
  38349. * Remove an element from this block
  38350. * @param entry defines the element to remove
  38351. */
  38352. removeEntry(entry: T): void;
  38353. /**
  38354. * Add an array of elements to this block
  38355. * @param entries defines the array of elements to add
  38356. */
  38357. addEntries(entries: T[]): void;
  38358. /**
  38359. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  38360. * @param frustumPlanes defines the frustum planes to test
  38361. * @param selection defines the array to store current content if selection is positive
  38362. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38363. */
  38364. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  38365. /**
  38366. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  38367. * @param sphereCenter defines the bounding sphere center
  38368. * @param sphereRadius defines the bounding sphere radius
  38369. * @param selection defines the array to store current content if selection is positive
  38370. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38371. */
  38372. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  38373. /**
  38374. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  38375. * @param ray defines the ray to test with
  38376. * @param selection defines the array to store current content if selection is positive
  38377. */
  38378. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  38379. /**
  38380. * Subdivide the content into child blocks (this block will then be empty)
  38381. */
  38382. createInnerBlocks(): void;
  38383. /**
  38384. * @hidden
  38385. */ 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;
  38386. }
  38387. }
  38388. declare module BABYLON {
  38389. /**
  38390. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  38391. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38392. */
  38393. export class Octree<T> {
  38394. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  38395. maxDepth: number;
  38396. /**
  38397. * Blocks within the octree containing objects
  38398. */
  38399. blocks: Array<OctreeBlock<T>>;
  38400. /**
  38401. * Content stored in the octree
  38402. */
  38403. dynamicContent: T[];
  38404. private _maxBlockCapacity;
  38405. private _selectionContent;
  38406. private _creationFunc;
  38407. /**
  38408. * Creates a octree
  38409. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38410. * @param creationFunc function to be used to instatiate the octree
  38411. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  38412. * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
  38413. */
  38414. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  38415. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  38416. maxDepth?: number);
  38417. /**
  38418. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  38419. * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  38420. * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  38421. * @param entries meshes to be added to the octree blocks
  38422. */
  38423. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  38424. /**
  38425. * Adds a mesh to the octree
  38426. * @param entry Mesh to add to the octree
  38427. */
  38428. addMesh(entry: T): void;
  38429. /**
  38430. * Remove an element from the octree
  38431. * @param entry defines the element to remove
  38432. */
  38433. removeMesh(entry: T): void;
  38434. /**
  38435. * Selects an array of meshes within the frustum
  38436. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  38437. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  38438. * @returns array of meshes within the frustum
  38439. */
  38440. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  38441. /**
  38442. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  38443. * @param sphereCenter defines the bounding sphere center
  38444. * @param sphereRadius defines the bounding sphere radius
  38445. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38446. * @returns an array of objects that intersect the sphere
  38447. */
  38448. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  38449. /**
  38450. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  38451. * @param ray defines the ray to test with
  38452. * @returns array of intersected objects
  38453. */
  38454. intersectsRay(ray: Ray): SmartArray<T>;
  38455. /**
  38456. * Adds a mesh into the octree block if it intersects the block
  38457. */
  38458. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  38459. /**
  38460. * Adds a submesh into the octree block if it intersects the block
  38461. */
  38462. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  38463. }
  38464. }
  38465. declare module BABYLON {
  38466. interface Scene {
  38467. /**
  38468. * @hidden
  38469. * Backing Filed
  38470. */ selectionOctree: Octree<AbstractMesh>;
  38471. /**
  38472. * Gets the octree used to boost mesh selection (picking)
  38473. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38474. */
  38475. selectionOctree: Octree<AbstractMesh>;
  38476. /**
  38477. * Creates or updates the octree used to boost selection (picking)
  38478. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38479. * @param maxCapacity defines the maximum capacity per leaf
  38480. * @param maxDepth defines the maximum depth of the octree
  38481. * @returns an octree of AbstractMesh
  38482. */
  38483. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  38484. }
  38485. interface AbstractMesh {
  38486. /**
  38487. * @hidden
  38488. * Backing Field
  38489. */ submeshesOctree: Octree<SubMesh>;
  38490. /**
  38491. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  38492. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  38493. * @param maxCapacity defines the maximum size of each block (64 by default)
  38494. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  38495. * @returns the new octree
  38496. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  38497. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38498. */
  38499. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  38500. }
  38501. /**
  38502. * Defines the octree scene component responsible to manage any octrees
  38503. * in a given scene.
  38504. */
  38505. export class OctreeSceneComponent {
  38506. /**
  38507. * The component name helpfull to identify the component in the list of scene components.
  38508. */
  38509. readonly name: string;
  38510. /**
  38511. * The scene the component belongs to.
  38512. */
  38513. scene: Scene;
  38514. /**
  38515. * Indicates if the meshes have been checked to make sure they are isEnabled()
  38516. */
  38517. readonly checksIsEnabled: boolean;
  38518. /**
  38519. * Creates a new instance of the component for the given scene
  38520. * @param scene Defines the scene to register the component in
  38521. */
  38522. constructor(scene: Scene);
  38523. /**
  38524. * Registers the component in a given scene
  38525. */
  38526. register(): void;
  38527. /**
  38528. * Return the list of active meshes
  38529. * @returns the list of active meshes
  38530. */
  38531. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  38532. /**
  38533. * Return the list of active sub meshes
  38534. * @param mesh The mesh to get the candidates sub meshes from
  38535. * @returns the list of active sub meshes
  38536. */
  38537. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  38538. private _tempRay;
  38539. /**
  38540. * Return the list of sub meshes intersecting with a given local ray
  38541. * @param mesh defines the mesh to find the submesh for
  38542. * @param localRay defines the ray in local space
  38543. * @returns the list of intersecting sub meshes
  38544. */
  38545. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  38546. /**
  38547. * Return the list of sub meshes colliding with a collider
  38548. * @param mesh defines the mesh to find the submesh for
  38549. * @param collider defines the collider to evaluate the collision against
  38550. * @returns the list of colliding sub meshes
  38551. */
  38552. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  38553. /**
  38554. * Rebuilds the elements related to this component in case of
  38555. * context lost for instance.
  38556. */
  38557. rebuild(): void;
  38558. /**
  38559. * Disposes the component and the associated ressources.
  38560. */
  38561. dispose(): void;
  38562. }
  38563. }
  38564. declare module BABYLON {
  38565. /**
  38566. * Class containing static functions to help procedurally build meshes
  38567. */
  38568. export class LinesBuilder {
  38569. /**
  38570. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  38571. * * 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
  38572. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  38573. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  38574. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  38575. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  38576. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  38577. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  38578. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  38579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38580. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  38581. * @param name defines the name of the new line system
  38582. * @param options defines the options used to create the line system
  38583. * @param scene defines the hosting scene
  38584. * @returns a new line system mesh
  38585. */
  38586. static CreateLineSystem(name: string, options: {
  38587. lines: Vector3[][];
  38588. updatable?: boolean;
  38589. instance?: Nullable<LinesMesh>;
  38590. colors?: Nullable<Color4[][]>;
  38591. useVertexAlpha?: boolean;
  38592. }, scene: Nullable<Scene>): LinesMesh;
  38593. /**
  38594. * Creates a line mesh
  38595. * 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
  38596. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  38597. * * The parameter `points` is an array successive Vector3
  38598. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  38599. * * The optional parameter `colors` is an array of successive Color4, one per line point
  38600. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  38601. * * When updating an instance, remember that only point positions can change, not the number of points
  38602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38603. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  38604. * @param name defines the name of the new line system
  38605. * @param options defines the options used to create the line system
  38606. * @param scene defines the hosting scene
  38607. * @returns a new line mesh
  38608. */
  38609. static CreateLines(name: string, options: {
  38610. points: Vector3[];
  38611. updatable?: boolean;
  38612. instance?: Nullable<LinesMesh>;
  38613. colors?: Color4[];
  38614. useVertexAlpha?: boolean;
  38615. }, scene?: Nullable<Scene>): LinesMesh;
  38616. /**
  38617. * Creates a dashed line mesh
  38618. * * 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
  38619. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  38620. * * The parameter `points` is an array successive Vector3
  38621. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  38622. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  38623. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  38624. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  38625. * * When updating an instance, remember that only point positions can change, not the number of points
  38626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38627. * @param name defines the name of the mesh
  38628. * @param options defines the options used to create the mesh
  38629. * @param scene defines the hosting scene
  38630. * @returns the dashed line mesh
  38631. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  38632. */
  38633. static CreateDashedLines(name: string, options: {
  38634. points: Vector3[];
  38635. dashSize?: number;
  38636. gapSize?: number;
  38637. dashNb?: number;
  38638. updatable?: boolean;
  38639. instance?: LinesMesh;
  38640. }, scene?: Nullable<Scene>): LinesMesh;
  38641. }
  38642. }
  38643. declare module BABYLON {
  38644. /**
  38645. * Renders a layer on top of an existing scene
  38646. */
  38647. export class UtilityLayerRenderer implements IDisposable {
  38648. /** the original scene that will be rendered on top of */
  38649. originalScene: Scene;
  38650. private _pointerCaptures;
  38651. private _lastPointerEvents;
  38652. private static _DefaultUtilityLayer;
  38653. private static _DefaultKeepDepthUtilityLayer;
  38654. /**
  38655. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  38656. */
  38657. pickUtilitySceneFirst: boolean;
  38658. /**
  38659. * 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)
  38660. */
  38661. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  38662. /**
  38663. * 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)
  38664. */
  38665. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  38666. /**
  38667. * The scene that is rendered on top of the original scene
  38668. */
  38669. utilityLayerScene: Scene;
  38670. /**
  38671. * If the utility layer should automatically be rendered on top of existing scene
  38672. */
  38673. shouldRender: boolean;
  38674. /**
  38675. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  38676. */
  38677. onlyCheckPointerDownEvents: boolean;
  38678. /**
  38679. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  38680. */
  38681. processAllEvents: boolean;
  38682. /**
  38683. * Observable raised when the pointer move from the utility layer scene to the main scene
  38684. */
  38685. onPointerOutObservable: Observable<number>;
  38686. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  38687. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  38688. private _afterRenderObserver;
  38689. private _sceneDisposeObserver;
  38690. private _originalPointerObserver;
  38691. /**
  38692. * Instantiates a UtilityLayerRenderer
  38693. * @param originalScene the original scene that will be rendered on top of
  38694. * @param handleEvents boolean indicating if the utility layer should handle events
  38695. */
  38696. constructor(
  38697. /** the original scene that will be rendered on top of */
  38698. originalScene: Scene, handleEvents?: boolean);
  38699. private _notifyObservers;
  38700. /**
  38701. * Renders the utility layers scene on top of the original scene
  38702. */
  38703. render(): void;
  38704. /**
  38705. * Disposes of the renderer
  38706. */
  38707. dispose(): void;
  38708. private _updateCamera;
  38709. }
  38710. }
  38711. declare module BABYLON {
  38712. /**
  38713. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  38714. */
  38715. export class Gizmo implements IDisposable {
  38716. /** The utility layer the gizmo will be added to */
  38717. gizmoLayer: UtilityLayerRenderer;
  38718. /**
  38719. * The root mesh of the gizmo
  38720. */
  38721. protected _rootMesh: Mesh;
  38722. private _attachedMesh;
  38723. /**
  38724. * Ratio for the scale of the gizmo (Default: 1)
  38725. */
  38726. scaleRatio: number;
  38727. private _tmpMatrix;
  38728. /**
  38729. * If a custom mesh has been set (Default: false)
  38730. */
  38731. protected _customMeshSet: boolean;
  38732. /**
  38733. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  38734. * * When set, interactions will be enabled
  38735. */
  38736. attachedMesh: Nullable<AbstractMesh>;
  38737. /**
  38738. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38739. * @param mesh The mesh to replace the default mesh of the gizmo
  38740. */
  38741. setCustomMesh(mesh: Mesh): void;
  38742. /**
  38743. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  38744. */
  38745. updateGizmoRotationToMatchAttachedMesh: boolean;
  38746. /**
  38747. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  38748. */
  38749. updateGizmoPositionToMatchAttachedMesh: boolean;
  38750. /**
  38751. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  38752. */
  38753. protected _updateScale: boolean;
  38754. protected _interactionsEnabled: boolean;
  38755. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  38756. private _beforeRenderObserver;
  38757. /**
  38758. * Creates a gizmo
  38759. * @param gizmoLayer The utility layer the gizmo will be added to
  38760. */
  38761. constructor(
  38762. /** The utility layer the gizmo will be added to */
  38763. gizmoLayer?: UtilityLayerRenderer);
  38764. private _tempVector;
  38765. /**
  38766. * @hidden
  38767. * Updates the gizmo to match the attached mesh's position/rotation
  38768. */
  38769. protected _update(): void;
  38770. /**
  38771. * Disposes of the gizmo
  38772. */
  38773. dispose(): void;
  38774. }
  38775. }
  38776. declare module BABYLON {
  38777. /**
  38778. * Single axis drag gizmo
  38779. */
  38780. export class AxisDragGizmo extends Gizmo {
  38781. /**
  38782. * Drag behavior responsible for the gizmos dragging interactions
  38783. */
  38784. dragBehavior: PointerDragBehavior;
  38785. private _pointerObserver;
  38786. /**
  38787. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38788. */
  38789. snapDistance: number;
  38790. /**
  38791. * Event that fires each time the gizmo snaps to a new location.
  38792. * * snapDistance is the the change in distance
  38793. */
  38794. onSnapObservable: Observable<{
  38795. snapDistance: number;
  38796. }>;
  38797. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  38798. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  38799. /**
  38800. * Creates an AxisDragGizmo
  38801. * @param gizmoLayer The utility layer the gizmo will be added to
  38802. * @param dragAxis The axis which the gizmo will be able to drag on
  38803. * @param color The color of the gizmo
  38804. */
  38805. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  38806. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  38807. /**
  38808. * Disposes of the gizmo
  38809. */
  38810. dispose(): void;
  38811. }
  38812. }
  38813. declare module BABYLON.Debug {
  38814. /**
  38815. * The Axes viewer will show 3 axes in a specific point in space
  38816. */
  38817. export class AxesViewer {
  38818. private _xAxis;
  38819. private _yAxis;
  38820. private _zAxis;
  38821. private _scaleLinesFactor;
  38822. private _instanced;
  38823. /**
  38824. * Gets the hosting scene
  38825. */
  38826. scene: Scene;
  38827. /**
  38828. * Gets or sets a number used to scale line length
  38829. */
  38830. scaleLines: number;
  38831. /** Gets the node hierarchy used to render x-axis */
  38832. readonly xAxis: TransformNode;
  38833. /** Gets the node hierarchy used to render y-axis */
  38834. readonly yAxis: TransformNode;
  38835. /** Gets the node hierarchy used to render z-axis */
  38836. readonly zAxis: TransformNode;
  38837. /**
  38838. * Creates a new AxesViewer
  38839. * @param scene defines the hosting scene
  38840. * @param scaleLines defines a number used to scale line length (1 by default)
  38841. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  38842. * @param xAxis defines the node hierarchy used to render the x-axis
  38843. * @param yAxis defines the node hierarchy used to render the y-axis
  38844. * @param zAxis defines the node hierarchy used to render the z-axis
  38845. */
  38846. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  38847. /**
  38848. * Force the viewer to update
  38849. * @param position defines the position of the viewer
  38850. * @param xaxis defines the x axis of the viewer
  38851. * @param yaxis defines the y axis of the viewer
  38852. * @param zaxis defines the z axis of the viewer
  38853. */
  38854. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  38855. /**
  38856. * Creates an instance of this axes viewer.
  38857. * @returns a new axes viewer with instanced meshes
  38858. */
  38859. createInstance(): AxesViewer;
  38860. /** Releases resources */
  38861. dispose(): void;
  38862. private static _SetRenderingGroupId;
  38863. }
  38864. }
  38865. declare module BABYLON.Debug {
  38866. /**
  38867. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  38868. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  38869. */
  38870. export class BoneAxesViewer extends AxesViewer {
  38871. /**
  38872. * Gets or sets the target mesh where to display the axes viewer
  38873. */
  38874. mesh: Nullable<Mesh>;
  38875. /**
  38876. * Gets or sets the target bone where to display the axes viewer
  38877. */
  38878. bone: Nullable<Bone>;
  38879. /** Gets current position */
  38880. pos: Vector3;
  38881. /** Gets direction of X axis */
  38882. xaxis: Vector3;
  38883. /** Gets direction of Y axis */
  38884. yaxis: Vector3;
  38885. /** Gets direction of Z axis */
  38886. zaxis: Vector3;
  38887. /**
  38888. * Creates a new BoneAxesViewer
  38889. * @param scene defines the hosting scene
  38890. * @param bone defines the target bone
  38891. * @param mesh defines the target mesh
  38892. * @param scaleLines defines a scaling factor for line length (1 by default)
  38893. */
  38894. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  38895. /**
  38896. * Force the viewer to update
  38897. */
  38898. update(): void;
  38899. /** Releases resources */
  38900. dispose(): void;
  38901. }
  38902. }
  38903. declare module BABYLON {
  38904. /**
  38905. * Interface used to define scene explorer extensibility option
  38906. */
  38907. export interface IExplorerExtensibilityOption {
  38908. /**
  38909. * Define the option label
  38910. */
  38911. label: string;
  38912. /**
  38913. * Defines the action to execute on click
  38914. */
  38915. action: (entity: any) => void;
  38916. }
  38917. /**
  38918. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  38919. */
  38920. export interface IExplorerExtensibilityGroup {
  38921. /**
  38922. * Defines a predicate to test if a given type mut be extended
  38923. */
  38924. predicate: (entity: any) => boolean;
  38925. /**
  38926. * Gets the list of options added to a type
  38927. */
  38928. entries: IExplorerExtensibilityOption[];
  38929. }
  38930. /**
  38931. * Interface used to define the options to use to create the Inspector
  38932. */
  38933. export interface IInspectorOptions {
  38934. /**
  38935. * Display in overlay mode (default: false)
  38936. */
  38937. overlay?: boolean;
  38938. /**
  38939. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  38940. */
  38941. globalRoot?: HTMLElement;
  38942. /**
  38943. * Display the Scene explorer
  38944. */
  38945. showExplorer?: boolean;
  38946. /**
  38947. * Display the property inspector
  38948. */
  38949. showInspector?: boolean;
  38950. /**
  38951. * Display in embed mode (both panes on the right)
  38952. */
  38953. embedMode?: boolean;
  38954. /**
  38955. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  38956. */
  38957. handleResize?: boolean;
  38958. /**
  38959. * Allow the panes to popup (default: true)
  38960. */
  38961. enablePopup?: boolean;
  38962. /**
  38963. * Allow the panes to be closed by users (default: true)
  38964. */
  38965. enableClose?: boolean;
  38966. /**
  38967. * Optional list of extensibility entries
  38968. */
  38969. explorerExtensibility?: IExplorerExtensibilityGroup[];
  38970. }
  38971. interface Scene {
  38972. /**
  38973. * @hidden
  38974. * Backing field
  38975. */ debugLayer: DebugLayer;
  38976. /**
  38977. * Gets the debug layer (aka Inspector) associated with the scene
  38978. * @see http://doc.babylonjs.com/features/playground_debuglayer
  38979. */
  38980. debugLayer: DebugLayer;
  38981. }
  38982. /**
  38983. * The debug layer (aka Inspector) is the go to tool in order to better understand
  38984. * what is happening in your scene
  38985. * @see http://doc.babylonjs.com/features/playground_debuglayer
  38986. */
  38987. export class DebugLayer {
  38988. /**
  38989. * Define the url to get the inspector script from.
  38990. * By default it uses the babylonjs CDN.
  38991. * @ignoreNaming
  38992. */
  38993. static InspectorURL: string;
  38994. private _scene;
  38995. private BJSINSPECTOR;
  38996. /**
  38997. * Observable triggered when a property is changed through the inspector.
  38998. */
  38999. onPropertyChangedObservable: Observable<{
  39000. object: any;
  39001. property: string;
  39002. value: any;
  39003. initialValue: any;
  39004. }>;
  39005. /**
  39006. * Instantiates a new debug layer.
  39007. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39008. * what is happening in your scene
  39009. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39010. * @param scene Defines the scene to inspect
  39011. */
  39012. constructor(scene: Scene);
  39013. /** Creates the inspector window. */
  39014. private _createInspector;
  39015. /** Get the inspector from bundle or global */
  39016. private _getGlobalInspector;
  39017. /**
  39018. * Get if the inspector is visible or not.
  39019. * @returns true if visible otherwise, false
  39020. */
  39021. isVisible(): boolean;
  39022. /**
  39023. * Hide the inspector and close its window.
  39024. */
  39025. hide(): void;
  39026. /**
  39027. * Launch the debugLayer.
  39028. * @param config Define the configuration of the inspector
  39029. */
  39030. show(config?: IInspectorOptions): void;
  39031. }
  39032. }
  39033. declare module BABYLON {
  39034. /**
  39035. * Class containing static functions to help procedurally build meshes
  39036. */
  39037. export class BoxBuilder {
  39038. /**
  39039. * Creates a box mesh
  39040. * * The parameter `size` sets the size (float) of each box side (default 1)
  39041. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  39042. * * 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)
  39043. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  39044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39045. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39047. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  39048. * @param name defines the name of the mesh
  39049. * @param options defines the options used to create the mesh
  39050. * @param scene defines the hosting scene
  39051. * @returns the box mesh
  39052. */
  39053. static CreateBox(name: string, options: {
  39054. size?: number;
  39055. width?: number;
  39056. height?: number;
  39057. depth?: number;
  39058. faceUV?: Vector4[];
  39059. faceColors?: Color4[];
  39060. sideOrientation?: number;
  39061. frontUVs?: Vector4;
  39062. backUVs?: Vector4;
  39063. updatable?: boolean;
  39064. }, scene?: Nullable<Scene>): Mesh;
  39065. }
  39066. }
  39067. declare module BABYLON {
  39068. /**
  39069. * Class containing static functions to help procedurally build meshes
  39070. */
  39071. export class SphereBuilder {
  39072. /**
  39073. * Creates a sphere mesh
  39074. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  39075. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  39076. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  39077. * * 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
  39078. * * 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)
  39079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39080. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39082. * @param name defines the name of the mesh
  39083. * @param options defines the options used to create the mesh
  39084. * @param scene defines the hosting scene
  39085. * @returns the sphere mesh
  39086. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  39087. */
  39088. static CreateSphere(name: string, options: {
  39089. segments?: number;
  39090. diameter?: number;
  39091. diameterX?: number;
  39092. diameterY?: number;
  39093. diameterZ?: number;
  39094. arc?: number;
  39095. slice?: number;
  39096. sideOrientation?: number;
  39097. frontUVs?: Vector4;
  39098. backUVs?: Vector4;
  39099. updatable?: boolean;
  39100. }, scene: any): Mesh;
  39101. }
  39102. }
  39103. declare module BABYLON.Debug {
  39104. /**
  39105. * Used to show the physics impostor around the specific mesh
  39106. */
  39107. export class PhysicsViewer {
  39108. /** @hidden */
  39109. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  39110. /** @hidden */
  39111. protected _meshes: Array<Nullable<AbstractMesh>>;
  39112. /** @hidden */
  39113. protected _scene: Nullable<Scene>;
  39114. /** @hidden */
  39115. protected _numMeshes: number;
  39116. /** @hidden */
  39117. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  39118. private _renderFunction;
  39119. private _utilityLayer;
  39120. private _debugBoxMesh;
  39121. private _debugSphereMesh;
  39122. private _debugMaterial;
  39123. /**
  39124. * Creates a new PhysicsViewer
  39125. * @param scene defines the hosting scene
  39126. */
  39127. constructor(scene: Scene);
  39128. /** @hidden */
  39129. protected _updateDebugMeshes(): void;
  39130. /**
  39131. * Renders a specified physic impostor
  39132. * @param impostor defines the impostor to render
  39133. * @returns the new debug mesh used to render the impostor
  39134. */
  39135. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  39136. /**
  39137. * Hides a specified physic impostor
  39138. * @param impostor defines the impostor to hide
  39139. */
  39140. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  39141. private _getDebugMaterial;
  39142. private _getDebugBoxMesh;
  39143. private _getDebugSphereMesh;
  39144. private _getDebugMesh;
  39145. /** Releases all resources */
  39146. dispose(): void;
  39147. }
  39148. }
  39149. declare module BABYLON {
  39150. /**
  39151. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  39152. * in order to better appreciate the issue one might have.
  39153. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  39154. */
  39155. export class RayHelper {
  39156. /**
  39157. * Defines the ray we are currently tryin to visualize.
  39158. */
  39159. ray: Nullable<Ray>;
  39160. private _renderPoints;
  39161. private _renderLine;
  39162. private _renderFunction;
  39163. private _scene;
  39164. private _updateToMeshFunction;
  39165. private _attachedToMesh;
  39166. private _meshSpaceDirection;
  39167. private _meshSpaceOrigin;
  39168. /**
  39169. * Helper function to create a colored helper in a scene in one line.
  39170. * @param ray Defines the ray we are currently tryin to visualize
  39171. * @param scene Defines the scene the ray is used in
  39172. * @param color Defines the color we want to see the ray in
  39173. * @returns The newly created ray helper.
  39174. */
  39175. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  39176. /**
  39177. * Instantiate a new ray helper.
  39178. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  39179. * in order to better appreciate the issue one might have.
  39180. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  39181. * @param ray Defines the ray we are currently tryin to visualize
  39182. */
  39183. constructor(ray: Ray);
  39184. /**
  39185. * Shows the ray we are willing to debug.
  39186. * @param scene Defines the scene the ray needs to be rendered in
  39187. * @param color Defines the color the ray needs to be rendered in
  39188. */
  39189. show(scene: Scene, color?: Color3): void;
  39190. /**
  39191. * Hides the ray we are debugging.
  39192. */
  39193. hide(): void;
  39194. private _render;
  39195. /**
  39196. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  39197. * @param mesh Defines the mesh we want the helper attached to
  39198. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  39199. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  39200. * @param length Defines the length of the ray
  39201. */
  39202. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  39203. /**
  39204. * Detach the ray helper from the mesh it has previously been attached to.
  39205. */
  39206. detachFromMesh(): void;
  39207. private _updateToMesh;
  39208. /**
  39209. * Dispose the helper and release its associated resources.
  39210. */
  39211. dispose(): void;
  39212. }
  39213. }
  39214. declare module BABYLON.Debug {
  39215. /**
  39216. * Class used to render a debug view of a given skeleton
  39217. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  39218. */
  39219. export class SkeletonViewer {
  39220. /** defines the skeleton to render */
  39221. skeleton: Skeleton;
  39222. /** defines the mesh attached to the skeleton */
  39223. mesh: AbstractMesh;
  39224. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  39225. autoUpdateBonesMatrices: boolean;
  39226. /** defines the rendering group id to use with the viewer */
  39227. renderingGroupId: number;
  39228. /** Gets or sets the color used to render the skeleton */
  39229. color: Color3;
  39230. private _scene;
  39231. private _debugLines;
  39232. private _debugMesh;
  39233. private _isEnabled;
  39234. private _renderFunction;
  39235. private _utilityLayer;
  39236. /**
  39237. * Returns the mesh used to render the bones
  39238. */
  39239. readonly debugMesh: Nullable<LinesMesh>;
  39240. /**
  39241. * Creates a new SkeletonViewer
  39242. * @param skeleton defines the skeleton to render
  39243. * @param mesh defines the mesh attached to the skeleton
  39244. * @param scene defines the hosting scene
  39245. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  39246. * @param renderingGroupId defines the rendering group id to use with the viewer
  39247. */
  39248. constructor(
  39249. /** defines the skeleton to render */
  39250. skeleton: Skeleton,
  39251. /** defines the mesh attached to the skeleton */
  39252. mesh: AbstractMesh, scene: Scene,
  39253. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  39254. autoUpdateBonesMatrices?: boolean,
  39255. /** defines the rendering group id to use with the viewer */
  39256. renderingGroupId?: number);
  39257. /** Gets or sets a boolean indicating if the viewer is enabled */
  39258. isEnabled: boolean;
  39259. private _getBonePosition;
  39260. private _getLinesForBonesWithLength;
  39261. private _getLinesForBonesNoLength;
  39262. /** Update the viewer to sync with current skeleton state */
  39263. update(): void;
  39264. /** Release associated resources */
  39265. dispose(): void;
  39266. }
  39267. }
  39268. declare module BABYLON {
  39269. /**
  39270. * Options to create the null engine
  39271. */
  39272. export class NullEngineOptions {
  39273. /**
  39274. * Render width (Default: 512)
  39275. */
  39276. renderWidth: number;
  39277. /**
  39278. * Render height (Default: 256)
  39279. */
  39280. renderHeight: number;
  39281. /**
  39282. * Texture size (Default: 512)
  39283. */
  39284. textureSize: number;
  39285. /**
  39286. * If delta time between frames should be constant
  39287. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39288. */
  39289. deterministicLockstep: boolean;
  39290. /**
  39291. * Maximum about of steps between frames (Default: 4)
  39292. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39293. */
  39294. lockstepMaxSteps: number;
  39295. }
  39296. /**
  39297. * The null engine class provides support for headless version of babylon.js.
  39298. * This can be used in server side scenario or for testing purposes
  39299. */
  39300. export class NullEngine extends Engine {
  39301. private _options;
  39302. /**
  39303. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39304. */
  39305. isDeterministicLockStep(): boolean;
  39306. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  39307. getLockstepMaxSteps(): number;
  39308. /**
  39309. * Sets hardware scaling, used to save performance if needed
  39310. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39311. */
  39312. getHardwareScalingLevel(): number;
  39313. constructor(options?: NullEngineOptions);
  39314. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  39315. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  39316. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39317. getRenderWidth(useScreen?: boolean): number;
  39318. getRenderHeight(useScreen?: boolean): number;
  39319. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  39320. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  39321. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  39322. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  39323. bindSamplers(effect: Effect): void;
  39324. enableEffect(effect: Effect): void;
  39325. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39326. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  39327. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  39328. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  39329. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  39330. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  39331. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  39332. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  39333. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  39334. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  39335. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  39336. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  39337. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  39338. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  39339. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  39340. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  39341. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  39342. setFloat(uniform: WebGLUniformLocation, value: number): void;
  39343. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  39344. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  39345. setBool(uniform: WebGLUniformLocation, bool: number): void;
  39346. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  39347. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  39348. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  39349. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  39350. bindBuffers(vertexBuffers: {
  39351. [key: string]: VertexBuffer;
  39352. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  39353. wipeCaches(bruteForce?: boolean): void;
  39354. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39355. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39356. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39357. /** @hidden */ createTexture(): WebGLTexture;
  39358. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  39359. 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;
  39360. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  39361. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  39362. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  39363. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39364. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  39365. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  39366. areAllEffectsReady(): boolean;
  39367. /**
  39368. * @hidden
  39369. * Get the current error code of the webGL context
  39370. * @returns the error code
  39371. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39372. */
  39373. getError(): number;
  39374. /** @hidden */ getUnpackAlignement(): number;
  39375. /** @hidden */ unpackFlipY(value: boolean): void;
  39376. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  39377. /**
  39378. * Updates a dynamic vertex buffer.
  39379. * @param vertexBuffer the vertex buffer to update
  39380. * @param data the data used to update the vertex buffer
  39381. * @param byteOffset the byte offset of the data (optional)
  39382. * @param byteLength the byte length of the data (optional)
  39383. */
  39384. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  39385. /** @hidden */ bindTexture(channel: number, texture: InternalTexture): void;
  39386. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  39387. releaseEffects(): void;
  39388. displayLoadingUI(): void;
  39389. hideLoadingUI(): void;
  39390. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39391. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39392. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39393. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  39394. }
  39395. }
  39396. declare module BABYLON {
  39397. /** @hidden */
  39398. export class _OcclusionDataStorage {
  39399. /** @hidden */
  39400. occlusionInternalRetryCounter: number;
  39401. /** @hidden */
  39402. isOcclusionQueryInProgress: boolean;
  39403. /** @hidden */
  39404. isOccluded: boolean;
  39405. /** @hidden */
  39406. occlusionRetryCount: number;
  39407. /** @hidden */
  39408. occlusionType: number;
  39409. /** @hidden */
  39410. occlusionQueryAlgorithmType: number;
  39411. }
  39412. interface Engine {
  39413. /**
  39414. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  39415. * @return the new query
  39416. */
  39417. createQuery(): WebGLQuery;
  39418. /**
  39419. * Delete and release a webGL query
  39420. * @param query defines the query to delete
  39421. * @return the current engine
  39422. */
  39423. deleteQuery(query: WebGLQuery): Engine;
  39424. /**
  39425. * Check if a given query has resolved and got its value
  39426. * @param query defines the query to check
  39427. * @returns true if the query got its value
  39428. */
  39429. isQueryResultAvailable(query: WebGLQuery): boolean;
  39430. /**
  39431. * Gets the value of a given query
  39432. * @param query defines the query to check
  39433. * @returns the value of the query
  39434. */
  39435. getQueryResult(query: WebGLQuery): number;
  39436. /**
  39437. * Initiates an occlusion query
  39438. * @param algorithmType defines the algorithm to use
  39439. * @param query defines the query to use
  39440. * @returns the current engine
  39441. * @see http://doc.babylonjs.com/features/occlusionquery
  39442. */
  39443. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  39444. /**
  39445. * Ends an occlusion query
  39446. * @see http://doc.babylonjs.com/features/occlusionquery
  39447. * @param algorithmType defines the algorithm to use
  39448. * @returns the current engine
  39449. */
  39450. endOcclusionQuery(algorithmType: number): Engine;
  39451. /**
  39452. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  39453. * Please note that only one query can be issued at a time
  39454. * @returns a time token used to track the time span
  39455. */
  39456. startTimeQuery(): Nullable<_TimeToken>;
  39457. /**
  39458. * Ends a time query
  39459. * @param token defines the token used to measure the time span
  39460. * @returns the time spent (in ns)
  39461. */
  39462. endTimeQuery(token: _TimeToken): int;
  39463. /** @hidden */ currentNonTimestampToken: Nullable<_TimeToken>;
  39464. /** @hidden */ createTimeQuery(): WebGLQuery;
  39465. /** @hidden */ deleteTimeQuery(query: WebGLQuery): void;
  39466. /** @hidden */ getGlAlgorithmType(algorithmType: number): number;
  39467. /** @hidden */ getTimeQueryResult(query: WebGLQuery): any;
  39468. /** @hidden */ getTimeQueryAvailability(query: WebGLQuery): any;
  39469. }
  39470. interface AbstractMesh {
  39471. /**
  39472. * Backing filed
  39473. * @hidden
  39474. */ private _occlusionDataStorage: _OcclusionDataStorage;
  39475. /**
  39476. * Access property
  39477. * @hidden
  39478. */ occlusionDataStorage: _OcclusionDataStorage;
  39479. /**
  39480. * 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.
  39481. * The default value is -1 which means don't break the query and wait till the result
  39482. * @see http://doc.babylonjs.com/features/occlusionquery
  39483. */
  39484. occlusionRetryCount: number;
  39485. /**
  39486. * 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:
  39487. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  39488. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  39489. * * 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.
  39490. * @see http://doc.babylonjs.com/features/occlusionquery
  39491. */
  39492. occlusionType: number;
  39493. /**
  39494. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  39495. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  39496. * * 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.
  39497. * @see http://doc.babylonjs.com/features/occlusionquery
  39498. */
  39499. occlusionQueryAlgorithmType: number;
  39500. /**
  39501. * 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
  39502. * @see http://doc.babylonjs.com/features/occlusionquery
  39503. */
  39504. isOccluded: boolean;
  39505. /**
  39506. * Flag to check the progress status of the query
  39507. * @see http://doc.babylonjs.com/features/occlusionquery
  39508. */
  39509. isOcclusionQueryInProgress: boolean;
  39510. }
  39511. }
  39512. declare module BABYLON {
  39513. /** @hidden */
  39514. export var _forceTransformFeedbackToBundle: boolean;
  39515. interface Engine {
  39516. /**
  39517. * Creates a webGL transform feedback object
  39518. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  39519. * @returns the webGL transform feedback object
  39520. */
  39521. createTransformFeedback(): WebGLTransformFeedback;
  39522. /**
  39523. * Delete a webGL transform feedback object
  39524. * @param value defines the webGL transform feedback object to delete
  39525. */
  39526. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  39527. /**
  39528. * Bind a webGL transform feedback object to the webgl context
  39529. * @param value defines the webGL transform feedback object to bind
  39530. */
  39531. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  39532. /**
  39533. * Begins a transform feedback operation
  39534. * @param usePoints defines if points or triangles must be used
  39535. */
  39536. beginTransformFeedback(usePoints: boolean): void;
  39537. /**
  39538. * Ends a transform feedback operation
  39539. */
  39540. endTransformFeedback(): void;
  39541. /**
  39542. * Specify the varyings to use with transform feedback
  39543. * @param program defines the associated webGL program
  39544. * @param value defines the list of strings representing the varying names
  39545. */
  39546. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  39547. /**
  39548. * Bind a webGL buffer for a transform feedback operation
  39549. * @param value defines the webGL buffer to bind
  39550. */
  39551. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  39552. }
  39553. }
  39554. declare module BABYLON {
  39555. /**
  39556. * Gather the list of clipboard event types as constants.
  39557. */
  39558. export class ClipboardEventTypes {
  39559. /**
  39560. * The clipboard event is fired when a copy command is active (pressed).
  39561. */
  39562. static readonly COPY: number;
  39563. /**
  39564. * The clipboard event is fired when a cut command is active (pressed).
  39565. */
  39566. static readonly CUT: number;
  39567. /**
  39568. * The clipboard event is fired when a paste command is active (pressed).
  39569. */
  39570. static readonly PASTE: number;
  39571. }
  39572. /**
  39573. * This class is used to store clipboard related info for the onClipboardObservable event.
  39574. */
  39575. export class ClipboardInfo {
  39576. /**
  39577. * Defines the type of event (BABYLON.ClipboardEventTypes)
  39578. */
  39579. type: number;
  39580. /**
  39581. * Defines the related dom event
  39582. */
  39583. event: ClipboardEvent;
  39584. /**
  39585. *Creates an instance of ClipboardInfo.
  39586. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  39587. * @param event Defines the related dom event
  39588. */
  39589. constructor(
  39590. /**
  39591. * Defines the type of event (BABYLON.ClipboardEventTypes)
  39592. */
  39593. type: number,
  39594. /**
  39595. * Defines the related dom event
  39596. */
  39597. event: ClipboardEvent);
  39598. /**
  39599. * Get the clipboard event's type from the keycode.
  39600. * @param keyCode Defines the keyCode for the current keyboard event.
  39601. * @return {number}
  39602. */
  39603. static GetTypeFromCharacter(keyCode: number): number;
  39604. }
  39605. }
  39606. declare module BABYLON {
  39607. /**
  39608. * Class used to represent data loading progression
  39609. */
  39610. export class SceneLoaderProgressEvent {
  39611. /** defines if data length to load can be evaluated */
  39612. readonly lengthComputable: boolean;
  39613. /** defines the loaded data length */
  39614. readonly loaded: number;
  39615. /** defines the data length to load */
  39616. readonly total: number;
  39617. /**
  39618. * Create a new progress event
  39619. * @param lengthComputable defines if data length to load can be evaluated
  39620. * @param loaded defines the loaded data length
  39621. * @param total defines the data length to load
  39622. */
  39623. constructor(
  39624. /** defines if data length to load can be evaluated */
  39625. lengthComputable: boolean,
  39626. /** defines the loaded data length */
  39627. loaded: number,
  39628. /** defines the data length to load */
  39629. total: number);
  39630. /**
  39631. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  39632. * @param event defines the source event
  39633. * @returns a new SceneLoaderProgressEvent
  39634. */
  39635. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  39636. }
  39637. /**
  39638. * Interface used by SceneLoader plugins to define supported file extensions
  39639. */
  39640. export interface ISceneLoaderPluginExtensions {
  39641. /**
  39642. * Defines the list of supported extensions
  39643. */
  39644. [extension: string]: {
  39645. isBinary: boolean;
  39646. };
  39647. }
  39648. /**
  39649. * Interface used by SceneLoader plugin factory
  39650. */
  39651. export interface ISceneLoaderPluginFactory {
  39652. /**
  39653. * Defines the name of the factory
  39654. */
  39655. name: string;
  39656. /**
  39657. * Function called to create a new plugin
  39658. * @return the new plugin
  39659. */
  39660. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  39661. /**
  39662. * Boolean indicating if the plugin can direct load specific data
  39663. */
  39664. canDirectLoad?: (data: string) => boolean;
  39665. }
  39666. /**
  39667. * Interface used to define a SceneLoader plugin
  39668. */
  39669. export interface ISceneLoaderPlugin {
  39670. /**
  39671. * The friendly name of this plugin.
  39672. */
  39673. name: string;
  39674. /**
  39675. * The file extensions supported by this plugin.
  39676. */
  39677. extensions: string | ISceneLoaderPluginExtensions;
  39678. /**
  39679. * Import meshes into a scene.
  39680. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  39681. * @param scene The scene to import into
  39682. * @param data The data to import
  39683. * @param rootUrl The root url for scene and resources
  39684. * @param meshes The meshes array to import into
  39685. * @param particleSystems The particle systems array to import into
  39686. * @param skeletons The skeletons array to import into
  39687. * @param onError The callback when import fails
  39688. * @returns True if successful or false otherwise
  39689. */
  39690. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  39691. /**
  39692. * Load into a scene.
  39693. * @param scene The scene to load into
  39694. * @param data The data to import
  39695. * @param rootUrl The root url for scene and resources
  39696. * @param onError The callback when import fails
  39697. * @returns true if successful or false otherwise
  39698. */
  39699. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  39700. /**
  39701. * The callback that returns true if the data can be directly loaded.
  39702. */
  39703. canDirectLoad?: (data: string) => boolean;
  39704. /**
  39705. * The callback that allows custom handling of the root url based on the response url.
  39706. */
  39707. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  39708. /**
  39709. * Load into an asset container.
  39710. * @param scene The scene to load into
  39711. * @param data The data to import
  39712. * @param rootUrl The root url for scene and resources
  39713. * @param onError The callback when import fails
  39714. * @returns The loaded asset container
  39715. */
  39716. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  39717. }
  39718. /**
  39719. * Interface used to define an async SceneLoader plugin
  39720. */
  39721. export interface ISceneLoaderPluginAsync {
  39722. /**
  39723. * The friendly name of this plugin.
  39724. */
  39725. name: string;
  39726. /**
  39727. * The file extensions supported by this plugin.
  39728. */
  39729. extensions: string | ISceneLoaderPluginExtensions;
  39730. /**
  39731. * Import meshes into a scene.
  39732. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  39733. * @param scene The scene to import into
  39734. * @param data The data to import
  39735. * @param rootUrl The root url for scene and resources
  39736. * @param onProgress The callback when the load progresses
  39737. * @param fileName Defines the name of the file to load
  39738. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  39739. */
  39740. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  39741. meshes: AbstractMesh[];
  39742. particleSystems: IParticleSystem[];
  39743. skeletons: Skeleton[];
  39744. animationGroups: AnimationGroup[];
  39745. }>;
  39746. /**
  39747. * Load into a scene.
  39748. * @param scene The scene to load into
  39749. * @param data The data to import
  39750. * @param rootUrl The root url for scene and resources
  39751. * @param onProgress The callback when the load progresses
  39752. * @param fileName Defines the name of the file to load
  39753. * @returns Nothing
  39754. */
  39755. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  39756. /**
  39757. * The callback that returns true if the data can be directly loaded.
  39758. */
  39759. canDirectLoad?: (data: string) => boolean;
  39760. /**
  39761. * The callback that allows custom handling of the root url based on the response url.
  39762. */
  39763. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  39764. /**
  39765. * Load into an asset container.
  39766. * @param scene The scene to load into
  39767. * @param data The data to import
  39768. * @param rootUrl The root url for scene and resources
  39769. * @param onProgress The callback when the load progresses
  39770. * @param fileName Defines the name of the file to load
  39771. * @returns The loaded asset container
  39772. */
  39773. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  39774. }
  39775. /**
  39776. * Class used to load scene from various file formats using registered plugins
  39777. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  39778. */
  39779. export class SceneLoader {
  39780. /**
  39781. * No logging while loading
  39782. */
  39783. static readonly NO_LOGGING: number;
  39784. /**
  39785. * Minimal logging while loading
  39786. */
  39787. static readonly MINIMAL_LOGGING: number;
  39788. /**
  39789. * Summary logging while loading
  39790. */
  39791. static readonly SUMMARY_LOGGING: number;
  39792. /**
  39793. * Detailled logging while loading
  39794. */
  39795. static readonly DETAILED_LOGGING: number;
  39796. /**
  39797. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  39798. */
  39799. static ForceFullSceneLoadingForIncremental: boolean;
  39800. /**
  39801. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  39802. */
  39803. static ShowLoadingScreen: boolean;
  39804. /**
  39805. * Defines the current logging level (while loading the scene)
  39806. * @ignorenaming
  39807. */
  39808. static loggingLevel: number;
  39809. /**
  39810. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  39811. */
  39812. static CleanBoneMatrixWeights: boolean;
  39813. /**
  39814. * Event raised when a plugin is used to load a scene
  39815. */
  39816. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  39817. private static _registeredPlugins;
  39818. private static _getDefaultPlugin;
  39819. private static _getPluginForExtension;
  39820. private static _getPluginForDirectLoad;
  39821. private static _getPluginForFilename;
  39822. private static _getDirectLoad;
  39823. private static _loadData;
  39824. private static _getFileInfo;
  39825. /**
  39826. * Gets a plugin that can load the given extension
  39827. * @param extension defines the extension to load
  39828. * @returns a plugin or null if none works
  39829. */
  39830. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  39831. /**
  39832. * Gets a boolean indicating that the given extension can be loaded
  39833. * @param extension defines the extension to load
  39834. * @returns true if the extension is supported
  39835. */
  39836. static IsPluginForExtensionAvailable(extension: string): boolean;
  39837. /**
  39838. * Adds a new plugin to the list of registered plugins
  39839. * @param plugin defines the plugin to add
  39840. */
  39841. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  39842. /**
  39843. * Import meshes into a scene
  39844. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  39845. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  39846. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  39847. * @param scene the instance of BABYLON.Scene to append to
  39848. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  39849. * @param onProgress a callback with a progress event for each file being loaded
  39850. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  39851. * @param pluginExtension the extension used to determine the plugin
  39852. * @returns The loaded plugin
  39853. */
  39854. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, 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>;
  39855. /**
  39856. * Import meshes into a scene
  39857. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  39858. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  39859. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  39860. * @param scene the instance of BABYLON.Scene to append to
  39861. * @param onProgress a callback with a progress event for each file being loaded
  39862. * @param pluginExtension the extension used to determine the plugin
  39863. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  39864. */
  39865. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  39866. meshes: AbstractMesh[];
  39867. particleSystems: IParticleSystem[];
  39868. skeletons: Skeleton[];
  39869. animationGroups: AnimationGroup[];
  39870. }>;
  39871. /**
  39872. * Load a scene
  39873. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  39874. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  39875. * @param engine is the instance of BABYLON.Engine to use to create the scene
  39876. * @param onSuccess a callback with the scene when import succeeds
  39877. * @param onProgress a callback with a progress event for each file being loaded
  39878. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  39879. * @param pluginExtension the extension used to determine the plugin
  39880. * @returns The loaded plugin
  39881. */
  39882. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<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>;
  39883. /**
  39884. * Load a scene
  39885. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  39886. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  39887. * @param engine is the instance of BABYLON.Engine to use to create the scene
  39888. * @param onProgress a callback with a progress event for each file being loaded
  39889. * @param pluginExtension the extension used to determine the plugin
  39890. * @returns The loaded scene
  39891. */
  39892. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  39893. /**
  39894. * Append a scene
  39895. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  39896. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  39897. * @param scene is the instance of BABYLON.Scene to append to
  39898. * @param onSuccess a callback with the scene when import succeeds
  39899. * @param onProgress a callback with a progress event for each file being loaded
  39900. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  39901. * @param pluginExtension the extension used to determine the plugin
  39902. * @returns The loaded plugin
  39903. */
  39904. static Append(rootUrl: string, sceneFilename?: string | File, 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>;
  39905. /**
  39906. * Append a scene
  39907. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  39908. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  39909. * @param scene is the instance of BABYLON.Scene to append to
  39910. * @param onProgress a callback with a progress event for each file being loaded
  39911. * @param pluginExtension the extension used to determine the plugin
  39912. * @returns The given scene
  39913. */
  39914. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  39915. /**
  39916. * Load a scene into an asset container
  39917. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  39918. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  39919. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  39920. * @param onSuccess a callback with the scene when import succeeds
  39921. * @param onProgress a callback with a progress event for each file being loaded
  39922. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  39923. * @param pluginExtension the extension used to determine the plugin
  39924. * @returns The loaded plugin
  39925. */
  39926. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, 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>;
  39927. /**
  39928. * Load a scene into an asset container
  39929. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  39930. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  39931. * @param scene is the instance of Scene to append to
  39932. * @param onProgress a callback with a progress event for each file being loaded
  39933. * @param pluginExtension the extension used to determine the plugin
  39934. * @returns The loaded asset container
  39935. */
  39936. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  39937. }
  39938. }
  39939. declare module BABYLON {
  39940. /**
  39941. * Google Daydream controller
  39942. */
  39943. export class DaydreamController extends WebVRController {
  39944. /**
  39945. * Base Url for the controller model.
  39946. */
  39947. static MODEL_BASE_URL: string;
  39948. /**
  39949. * File name for the controller model.
  39950. */
  39951. static MODEL_FILENAME: string;
  39952. /**
  39953. * Gamepad Id prefix used to identify Daydream Controller.
  39954. */
  39955. static readonly GAMEPAD_ID_PREFIX: string;
  39956. /**
  39957. * Creates a new DaydreamController from a gamepad
  39958. * @param vrGamepad the gamepad that the controller should be created from
  39959. */
  39960. constructor(vrGamepad: any);
  39961. /**
  39962. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  39963. * @param scene scene in which to add meshes
  39964. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  39965. */
  39966. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  39967. /**
  39968. * Called once for each button that changed state since the last frame
  39969. * @param buttonIdx Which button index changed
  39970. * @param state New state of the button
  39971. * @param changes Which properties on the state changed since last frame
  39972. */
  39973. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  39974. }
  39975. }
  39976. declare module BABYLON {
  39977. /**
  39978. * Gear VR Controller
  39979. */
  39980. export class GearVRController extends WebVRController {
  39981. /**
  39982. * Base Url for the controller model.
  39983. */
  39984. static MODEL_BASE_URL: string;
  39985. /**
  39986. * File name for the controller model.
  39987. */
  39988. static MODEL_FILENAME: string;
  39989. /**
  39990. * Gamepad Id prefix used to identify this controller.
  39991. */
  39992. static readonly GAMEPAD_ID_PREFIX: string;
  39993. private readonly _buttonIndexToObservableNameMap;
  39994. /**
  39995. * Creates a new GearVRController from a gamepad
  39996. * @param vrGamepad the gamepad that the controller should be created from
  39997. */
  39998. constructor(vrGamepad: any);
  39999. /**
  40000. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40001. * @param scene scene in which to add meshes
  40002. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40003. */
  40004. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40005. /**
  40006. * Called once for each button that changed state since the last frame
  40007. * @param buttonIdx Which button index changed
  40008. * @param state New state of the button
  40009. * @param changes Which properties on the state changed since last frame
  40010. */
  40011. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40012. }
  40013. }
  40014. declare module BABYLON {
  40015. /**
  40016. * Generic Controller
  40017. */
  40018. export class GenericController extends WebVRController {
  40019. /**
  40020. * Base Url for the controller model.
  40021. */
  40022. static readonly MODEL_BASE_URL: string;
  40023. /**
  40024. * File name for the controller model.
  40025. */
  40026. static readonly MODEL_FILENAME: string;
  40027. /**
  40028. * Creates a new GenericController from a gamepad
  40029. * @param vrGamepad the gamepad that the controller should be created from
  40030. */
  40031. constructor(vrGamepad: any);
  40032. /**
  40033. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40034. * @param scene scene in which to add meshes
  40035. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40036. */
  40037. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40038. /**
  40039. * Called once for each button that changed state since the last frame
  40040. * @param buttonIdx Which button index changed
  40041. * @param state New state of the button
  40042. * @param changes Which properties on the state changed since last frame
  40043. */
  40044. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40045. }
  40046. }
  40047. declare module BABYLON {
  40048. /**
  40049. * Oculus Touch Controller
  40050. */
  40051. export class OculusTouchController extends WebVRController {
  40052. /**
  40053. * Base Url for the controller model.
  40054. */
  40055. static MODEL_BASE_URL: string;
  40056. /**
  40057. * File name for the left controller model.
  40058. */
  40059. static MODEL_LEFT_FILENAME: string;
  40060. /**
  40061. * File name for the right controller model.
  40062. */
  40063. static MODEL_RIGHT_FILENAME: string;
  40064. /**
  40065. * Fired when the secondary trigger on this controller is modified
  40066. */
  40067. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  40068. /**
  40069. * Fired when the thumb rest on this controller is modified
  40070. */
  40071. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  40072. /**
  40073. * Creates a new OculusTouchController from a gamepad
  40074. * @param vrGamepad the gamepad that the controller should be created from
  40075. */
  40076. constructor(vrGamepad: any);
  40077. /**
  40078. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40079. * @param scene scene in which to add meshes
  40080. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40081. */
  40082. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40083. /**
  40084. * Fired when the A button on this controller is modified
  40085. */
  40086. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40087. /**
  40088. * Fired when the B button on this controller is modified
  40089. */
  40090. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40091. /**
  40092. * Fired when the X button on this controller is modified
  40093. */
  40094. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40095. /**
  40096. * Fired when the Y button on this controller is modified
  40097. */
  40098. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40099. /**
  40100. * Called once for each button that changed state since the last frame
  40101. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  40102. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  40103. * 2) secondary trigger (same)
  40104. * 3) A (right) X (left), touch, pressed = value
  40105. * 4) B / Y
  40106. * 5) thumb rest
  40107. * @param buttonIdx Which button index changed
  40108. * @param state New state of the button
  40109. * @param changes Which properties on the state changed since last frame
  40110. */
  40111. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40112. }
  40113. }
  40114. declare module BABYLON {
  40115. /**
  40116. * Vive Controller
  40117. */
  40118. export class ViveController extends WebVRController {
  40119. /**
  40120. * Base Url for the controller model.
  40121. */
  40122. static MODEL_BASE_URL: string;
  40123. /**
  40124. * File name for the controller model.
  40125. */
  40126. static MODEL_FILENAME: string;
  40127. /**
  40128. * Creates a new ViveController from a gamepad
  40129. * @param vrGamepad the gamepad that the controller should be created from
  40130. */
  40131. constructor(vrGamepad: any);
  40132. /**
  40133. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40134. * @param scene scene in which to add meshes
  40135. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40136. */
  40137. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40138. /**
  40139. * Fired when the left button on this controller is modified
  40140. */
  40141. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40142. /**
  40143. * Fired when the right button on this controller is modified
  40144. */
  40145. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40146. /**
  40147. * Fired when the menu button on this controller is modified
  40148. */
  40149. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40150. /**
  40151. * Called once for each button that changed state since the last frame
  40152. * Vive mapping:
  40153. * 0: touchpad
  40154. * 1: trigger
  40155. * 2: left AND right buttons
  40156. * 3: menu button
  40157. * @param buttonIdx Which button index changed
  40158. * @param state New state of the button
  40159. * @param changes Which properties on the state changed since last frame
  40160. */
  40161. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40162. }
  40163. }
  40164. declare module BABYLON {
  40165. /**
  40166. * Defines the WindowsMotionController object that the state of the windows motion controller
  40167. */
  40168. export class WindowsMotionController extends WebVRController {
  40169. /**
  40170. * The base url used to load the left and right controller models
  40171. */
  40172. static MODEL_BASE_URL: string;
  40173. /**
  40174. * The name of the left controller model file
  40175. */
  40176. static MODEL_LEFT_FILENAME: string;
  40177. /**
  40178. * The name of the right controller model file
  40179. */
  40180. static MODEL_RIGHT_FILENAME: string;
  40181. /**
  40182. * The controller name prefix for this controller type
  40183. */
  40184. static readonly GAMEPAD_ID_PREFIX: string;
  40185. /**
  40186. * The controller id pattern for this controller type
  40187. */
  40188. private static readonly GAMEPAD_ID_PATTERN;
  40189. private _loadedMeshInfo;
  40190. private readonly _mapping;
  40191. /**
  40192. * Fired when the trackpad on this controller is clicked
  40193. */
  40194. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  40195. /**
  40196. * Fired when the trackpad on this controller is modified
  40197. */
  40198. onTrackpadValuesChangedObservable: Observable<StickValues>;
  40199. /**
  40200. * The current x and y values of this controller's trackpad
  40201. */
  40202. trackpad: StickValues;
  40203. /**
  40204. * Creates a new WindowsMotionController from a gamepad
  40205. * @param vrGamepad the gamepad that the controller should be created from
  40206. */
  40207. constructor(vrGamepad: any);
  40208. /**
  40209. * Fired when the trigger on this controller is modified
  40210. */
  40211. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40212. /**
  40213. * Fired when the menu button on this controller is modified
  40214. */
  40215. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40216. /**
  40217. * Fired when the grip button on this controller is modified
  40218. */
  40219. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40220. /**
  40221. * Fired when the thumbstick button on this controller is modified
  40222. */
  40223. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40224. /**
  40225. * Fired when the touchpad button on this controller is modified
  40226. */
  40227. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40228. /**
  40229. * Fired when the touchpad values on this controller are modified
  40230. */
  40231. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  40232. private _updateTrackpad;
  40233. /**
  40234. * Called once per frame by the engine.
  40235. */
  40236. update(): void;
  40237. /**
  40238. * Called once for each button that changed state since the last frame
  40239. * @param buttonIdx Which button index changed
  40240. * @param state New state of the button
  40241. * @param changes Which properties on the state changed since last frame
  40242. */
  40243. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40244. /**
  40245. * Moves the buttons on the controller mesh based on their current state
  40246. * @param buttonName the name of the button to move
  40247. * @param buttonValue the value of the button which determines the buttons new position
  40248. */
  40249. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  40250. /**
  40251. * Moves the axis on the controller mesh based on its current state
  40252. * @param axis the index of the axis
  40253. * @param axisValue the value of the axis which determines the meshes new position
  40254. * @hidden
  40255. */
  40256. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  40257. /**
  40258. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40259. * @param scene scene in which to add meshes
  40260. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40261. */
  40262. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  40263. /**
  40264. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  40265. * can be transformed by button presses and axes values, based on this._mapping.
  40266. *
  40267. * @param scene scene in which the meshes exist
  40268. * @param meshes list of meshes that make up the controller model to process
  40269. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  40270. */
  40271. private processModel;
  40272. private createMeshInfo;
  40273. /**
  40274. * Gets the ray of the controller in the direction the controller is pointing
  40275. * @param length the length the resulting ray should be
  40276. * @returns a ray in the direction the controller is pointing
  40277. */
  40278. getForwardRay(length?: number): Ray;
  40279. /**
  40280. * Disposes of the controller
  40281. */
  40282. dispose(): void;
  40283. }
  40284. }
  40285. declare module BABYLON {
  40286. /**
  40287. * Manager for handling gamepads
  40288. */
  40289. export class GamepadManager {
  40290. private _scene?;
  40291. private _babylonGamepads;
  40292. private _oneGamepadConnected;
  40293. /** @hidden */ isMonitoring: boolean;
  40294. private _gamepadEventSupported;
  40295. private _gamepadSupport;
  40296. /**
  40297. * observable to be triggered when the gamepad controller has been connected
  40298. */
  40299. onGamepadConnectedObservable: Observable<Gamepad>;
  40300. /**
  40301. * observable to be triggered when the gamepad controller has been disconnected
  40302. */
  40303. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40304. private _onGamepadConnectedEvent;
  40305. private _onGamepadDisconnectedEvent;
  40306. /**
  40307. * Initializes the gamepad manager
  40308. * @param _scene BabylonJS scene
  40309. */
  40310. constructor(_scene?: Scene | undefined);
  40311. /**
  40312. * The gamepads in the game pad manager
  40313. */
  40314. readonly gamepads: Gamepad[];
  40315. /**
  40316. * Get the gamepad controllers based on type
  40317. * @param type The type of gamepad controller
  40318. * @returns Nullable gamepad
  40319. */
  40320. getGamepadByType(type?: number): Nullable<Gamepad>;
  40321. /**
  40322. * Disposes the gamepad manager
  40323. */
  40324. dispose(): void;
  40325. private _addNewGamepad;
  40326. private _startMonitoringGamepads;
  40327. private _stopMonitoringGamepads;
  40328. /** @hidden */ checkGamepadsStatus(): void;
  40329. private _updateGamepadObjects;
  40330. }
  40331. }
  40332. declare module BABYLON {
  40333. interface Scene {
  40334. /** @hidden */ gamepadManager: Nullable<GamepadManager>;
  40335. /**
  40336. * Gets the gamepad manager associated with the scene
  40337. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40338. */
  40339. gamepadManager: GamepadManager;
  40340. }
  40341. /**
  40342. * Interface representing a free camera inputs manager
  40343. */
  40344. interface FreeCameraInputsManager {
  40345. /**
  40346. * Adds gamepad input support to the FreeCameraInputsManager.
  40347. * @returns the FreeCameraInputsManager
  40348. */
  40349. addGamepad(): FreeCameraInputsManager;
  40350. }
  40351. /**
  40352. * Interface representing an arc rotate camera inputs manager
  40353. */
  40354. interface ArcRotateCameraInputsManager {
  40355. /**
  40356. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40357. * @returns the camera inputs manager
  40358. */
  40359. addGamepad(): ArcRotateCameraInputsManager;
  40360. }
  40361. /**
  40362. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40363. */
  40364. export class GamepadSystemSceneComponent implements ISceneComponent {
  40365. /**
  40366. * The component name helpfull to identify the component in the list of scene components.
  40367. */
  40368. readonly name: string;
  40369. /**
  40370. * The scene the component belongs to.
  40371. */
  40372. scene: Scene;
  40373. /**
  40374. * Creates a new instance of the component for the given scene
  40375. * @param scene Defines the scene to register the component in
  40376. */
  40377. constructor(scene: Scene);
  40378. /**
  40379. * Registers the component in a given scene
  40380. */
  40381. register(): void;
  40382. /**
  40383. * Rebuilds the elements related to this component in case of
  40384. * context lost for instance.
  40385. */
  40386. rebuild(): void;
  40387. /**
  40388. * Disposes the component and the associated ressources
  40389. */
  40390. dispose(): void;
  40391. private _beforeCameraUpdate;
  40392. }
  40393. }
  40394. declare module BABYLON {
  40395. /**
  40396. * Single axis scale gizmo
  40397. */
  40398. export class AxisScaleGizmo extends Gizmo {
  40399. private _coloredMaterial;
  40400. /**
  40401. * Drag behavior responsible for the gizmos dragging interactions
  40402. */
  40403. dragBehavior: PointerDragBehavior;
  40404. private _pointerObserver;
  40405. /**
  40406. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40407. */
  40408. snapDistance: number;
  40409. /**
  40410. * Event that fires each time the gizmo snaps to a new location.
  40411. * * snapDistance is the the change in distance
  40412. */
  40413. onSnapObservable: Observable<{
  40414. snapDistance: number;
  40415. }>;
  40416. /**
  40417. * If the scaling operation should be done on all axis (default: false)
  40418. */
  40419. uniformScaling: boolean;
  40420. /**
  40421. * Creates an AxisScaleGizmo
  40422. * @param gizmoLayer The utility layer the gizmo will be added to
  40423. * @param dragAxis The axis which the gizmo will be able to scale on
  40424. * @param color The color of the gizmo
  40425. */
  40426. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40427. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40428. /**
  40429. * Disposes of the gizmo
  40430. */
  40431. dispose(): void;
  40432. /**
  40433. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40434. * @param mesh The mesh to replace the default mesh of the gizmo
  40435. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  40436. */
  40437. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  40438. }
  40439. }
  40440. declare module BABYLON {
  40441. /**
  40442. * Bounding box gizmo
  40443. */
  40444. export class BoundingBoxGizmo extends Gizmo {
  40445. private _lineBoundingBox;
  40446. private _rotateSpheresParent;
  40447. private _scaleBoxesParent;
  40448. private _boundingDimensions;
  40449. private _renderObserver;
  40450. private _pointerObserver;
  40451. private _scaleDragSpeed;
  40452. private _tmpQuaternion;
  40453. private _tmpVector;
  40454. private _tmpRotationMatrix;
  40455. /**
  40456. * 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)
  40457. */
  40458. ignoreChildren: boolean;
  40459. /**
  40460. * 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)
  40461. */
  40462. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  40463. /**
  40464. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  40465. */
  40466. rotationSphereSize: number;
  40467. /**
  40468. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  40469. */
  40470. scaleBoxSize: number;
  40471. /**
  40472. * 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)
  40473. */
  40474. fixedDragMeshScreenSize: boolean;
  40475. /**
  40476. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  40477. */
  40478. fixedDragMeshScreenSizeDistanceFactor: number;
  40479. /**
  40480. * Fired when a rotation sphere or scale box is dragged
  40481. */
  40482. onDragStartObservable: Observable<{}>;
  40483. /**
  40484. * Fired when a scale box is dragged
  40485. */
  40486. onScaleBoxDragObservable: Observable<{}>;
  40487. /**
  40488. * Fired when a scale box drag is ended
  40489. */
  40490. onScaleBoxDragEndObservable: Observable<{}>;
  40491. /**
  40492. * Fired when a rotation sphere is dragged
  40493. */
  40494. onRotationSphereDragObservable: Observable<{}>;
  40495. /**
  40496. * Fired when a rotation sphere drag is ended
  40497. */
  40498. onRotationSphereDragEndObservable: Observable<{}>;
  40499. /**
  40500. * 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)
  40501. */
  40502. scalePivot: Nullable<Vector3>;
  40503. private _anchorMesh;
  40504. private _existingMeshScale;
  40505. private _dragMesh;
  40506. private pointerDragBehavior;
  40507. /**
  40508. * Creates an BoundingBoxGizmo
  40509. * @param gizmoLayer The utility layer the gizmo will be added to
  40510. * @param color The color of the gizmo
  40511. */
  40512. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40513. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40514. private _selectNode;
  40515. /**
  40516. * Updates the bounding box information for the Gizmo
  40517. */
  40518. updateBoundingBox(): void;
  40519. private _updateRotationSpheres;
  40520. private _updateScaleBoxes;
  40521. /**
  40522. * Enables rotation on the specified axis and disables rotation on the others
  40523. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  40524. */
  40525. setEnabledRotationAxis(axis: string): void;
  40526. /**
  40527. * Enables/disables scaling
  40528. * @param enable if scaling should be enabled
  40529. */
  40530. setEnabledScaling(enable: boolean): void;
  40531. private _updateDummy;
  40532. /**
  40533. * Enables a pointer drag behavior on the bounding box of the gizmo
  40534. */
  40535. enableDragBehavior(): void;
  40536. /**
  40537. * Disposes of the gizmo
  40538. */
  40539. dispose(): void;
  40540. /**
  40541. * 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)
  40542. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  40543. * @returns the bounding box mesh with the passed in mesh as a child
  40544. */
  40545. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  40546. /**
  40547. * CustomMeshes are not supported by this gizmo
  40548. * @param mesh The mesh to replace the default mesh of the gizmo
  40549. */
  40550. setCustomMesh(mesh: Mesh): void;
  40551. }
  40552. }
  40553. declare module BABYLON {
  40554. /**
  40555. * Single plane rotation gizmo
  40556. */
  40557. export class PlaneRotationGizmo extends Gizmo {
  40558. /**
  40559. * Drag behavior responsible for the gizmos dragging interactions
  40560. */
  40561. dragBehavior: PointerDragBehavior;
  40562. private _pointerObserver;
  40563. /**
  40564. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  40565. */
  40566. snapDistance: number;
  40567. /**
  40568. * Event that fires each time the gizmo snaps to a new location.
  40569. * * snapDistance is the the change in distance
  40570. */
  40571. onSnapObservable: Observable<{
  40572. snapDistance: number;
  40573. }>;
  40574. /**
  40575. * Creates a PlaneRotationGizmo
  40576. * @param gizmoLayer The utility layer the gizmo will be added to
  40577. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  40578. * @param color The color of the gizmo
  40579. * @param tessellation Amount of tessellation to be used when creating rotation circles
  40580. */
  40581. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  40582. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40583. /**
  40584. * Disposes of the gizmo
  40585. */
  40586. dispose(): void;
  40587. }
  40588. }
  40589. declare module BABYLON {
  40590. /**
  40591. * Gizmo that enables rotating a mesh along 3 axis
  40592. */
  40593. export class RotationGizmo extends Gizmo {
  40594. /**
  40595. * Internal gizmo used for interactions on the x axis
  40596. */
  40597. xGizmo: PlaneRotationGizmo;
  40598. /**
  40599. * Internal gizmo used for interactions on the y axis
  40600. */
  40601. yGizmo: PlaneRotationGizmo;
  40602. /**
  40603. * Internal gizmo used for interactions on the z axis
  40604. */
  40605. zGizmo: PlaneRotationGizmo;
  40606. /** Fires an event when any of it's sub gizmos are dragged */
  40607. onDragStartObservable: Observable<{}>;
  40608. /** Fires an event when any of it's sub gizmos are released from dragging */
  40609. onDragEndObservable: Observable<{}>;
  40610. attachedMesh: Nullable<AbstractMesh>;
  40611. /**
  40612. * Creates a RotationGizmo
  40613. * @param gizmoLayer The utility layer the gizmo will be added to
  40614. * @param tessellation Amount of tessellation to be used when creating rotation circles
  40615. */
  40616. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  40617. updateGizmoRotationToMatchAttachedMesh: boolean;
  40618. /**
  40619. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40620. */
  40621. snapDistance: number;
  40622. /**
  40623. * Ratio for the scale of the gizmo (Default: 1)
  40624. */
  40625. scaleRatio: number;
  40626. /**
  40627. * Disposes of the gizmo
  40628. */
  40629. dispose(): void;
  40630. /**
  40631. * CustomMeshes are not supported by this gizmo
  40632. * @param mesh The mesh to replace the default mesh of the gizmo
  40633. */
  40634. setCustomMesh(mesh: Mesh): void;
  40635. }
  40636. }
  40637. declare module BABYLON {
  40638. /**
  40639. * Gizmo that enables dragging a mesh along 3 axis
  40640. */
  40641. export class PositionGizmo extends Gizmo {
  40642. /**
  40643. * Internal gizmo used for interactions on the x axis
  40644. */
  40645. xGizmo: AxisDragGizmo;
  40646. /**
  40647. * Internal gizmo used for interactions on the y axis
  40648. */
  40649. yGizmo: AxisDragGizmo;
  40650. /**
  40651. * Internal gizmo used for interactions on the z axis
  40652. */
  40653. zGizmo: AxisDragGizmo;
  40654. /** Fires an event when any of it's sub gizmos are dragged */
  40655. onDragStartObservable: Observable<{}>;
  40656. /** Fires an event when any of it's sub gizmos are released from dragging */
  40657. onDragEndObservable: Observable<{}>;
  40658. attachedMesh: Nullable<AbstractMesh>;
  40659. /**
  40660. * Creates a PositionGizmo
  40661. * @param gizmoLayer The utility layer the gizmo will be added to
  40662. */
  40663. constructor(gizmoLayer?: UtilityLayerRenderer);
  40664. updateGizmoRotationToMatchAttachedMesh: boolean;
  40665. /**
  40666. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40667. */
  40668. snapDistance: number;
  40669. /**
  40670. * Ratio for the scale of the gizmo (Default: 1)
  40671. */
  40672. scaleRatio: number;
  40673. /**
  40674. * Disposes of the gizmo
  40675. */
  40676. dispose(): void;
  40677. /**
  40678. * CustomMeshes are not supported by this gizmo
  40679. * @param mesh The mesh to replace the default mesh of the gizmo
  40680. */
  40681. setCustomMesh(mesh: Mesh): void;
  40682. }
  40683. }
  40684. declare module BABYLON {
  40685. /**
  40686. * Class containing static functions to help procedurally build meshes
  40687. */
  40688. export class PolyhedronBuilder {
  40689. /**
  40690. * Creates a polyhedron mesh
  40691. * * 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
  40692. * * The parameter `size` (positive float, default 1) sets the polygon size
  40693. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  40694. * * 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`
  40695. * * 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
  40696. * * 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)`)
  40697. * * 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 : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40698. * * 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
  40699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40700. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40702. * @param name defines the name of the mesh
  40703. * @param options defines the options used to create the mesh
  40704. * @param scene defines the hosting scene
  40705. * @returns the polyhedron mesh
  40706. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  40707. */
  40708. static CreatePolyhedron(name: string, options: {
  40709. type?: number;
  40710. size?: number;
  40711. sizeX?: number;
  40712. sizeY?: number;
  40713. sizeZ?: number;
  40714. custom?: any;
  40715. faceUV?: Vector4[];
  40716. faceColors?: Color4[];
  40717. flat?: boolean;
  40718. updatable?: boolean;
  40719. sideOrientation?: number;
  40720. frontUVs?: Vector4;
  40721. backUVs?: Vector4;
  40722. }, scene: Scene): Mesh;
  40723. }
  40724. }
  40725. declare module BABYLON {
  40726. /**
  40727. * Gizmo that enables scaling a mesh along 3 axis
  40728. */
  40729. export class ScaleGizmo extends Gizmo {
  40730. /**
  40731. * Internal gizmo used for interactions on the x axis
  40732. */
  40733. xGizmo: AxisScaleGizmo;
  40734. /**
  40735. * Internal gizmo used for interactions on the y axis
  40736. */
  40737. yGizmo: AxisScaleGizmo;
  40738. /**
  40739. * Internal gizmo used for interactions on the z axis
  40740. */
  40741. zGizmo: AxisScaleGizmo;
  40742. /**
  40743. * Internal gizmo used to scale all axis equally
  40744. */
  40745. uniformScaleGizmo: AxisScaleGizmo;
  40746. /** Fires an event when any of it's sub gizmos are dragged */
  40747. onDragStartObservable: Observable<{}>;
  40748. /** Fires an event when any of it's sub gizmos are released from dragging */
  40749. onDragEndObservable: Observable<{}>;
  40750. attachedMesh: Nullable<AbstractMesh>;
  40751. /**
  40752. * Creates a ScaleGizmo
  40753. * @param gizmoLayer The utility layer the gizmo will be added to
  40754. */
  40755. constructor(gizmoLayer?: UtilityLayerRenderer);
  40756. updateGizmoRotationToMatchAttachedMesh: boolean;
  40757. /**
  40758. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40759. */
  40760. snapDistance: number;
  40761. /**
  40762. * Ratio for the scale of the gizmo (Default: 1)
  40763. */
  40764. scaleRatio: number;
  40765. /**
  40766. * Disposes of the gizmo
  40767. */
  40768. dispose(): void;
  40769. }
  40770. }
  40771. declare module BABYLON {
  40772. /**
  40773. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  40774. */
  40775. export class GizmoManager implements IDisposable {
  40776. private scene;
  40777. /**
  40778. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  40779. */
  40780. gizmos: {
  40781. positionGizmo: Nullable<PositionGizmo>;
  40782. rotationGizmo: Nullable<RotationGizmo>;
  40783. scaleGizmo: Nullable<ScaleGizmo>;
  40784. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  40785. };
  40786. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  40787. clearGizmoOnEmptyPointerEvent: boolean;
  40788. /** Fires an event when the manager is attached to a mesh */
  40789. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  40790. private _gizmosEnabled;
  40791. private _pointerObserver;
  40792. private _attachedMesh;
  40793. private _boundingBoxColor;
  40794. private _defaultUtilityLayer;
  40795. private _defaultKeepDepthUtilityLayer;
  40796. /**
  40797. * When bounding box gizmo is enabled, this can be used to track drag/end events
  40798. */
  40799. boundingBoxDragBehavior: SixDofDragBehavior;
  40800. /**
  40801. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  40802. */
  40803. attachableMeshes: Nullable<Array<AbstractMesh>>;
  40804. /**
  40805. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  40806. */
  40807. usePointerToAttachGizmos: boolean;
  40808. /**
  40809. * Instatiates a gizmo manager
  40810. * @param scene the scene to overlay the gizmos on top of
  40811. */
  40812. constructor(scene: Scene);
  40813. /**
  40814. * Attaches a set of gizmos to the specified mesh
  40815. * @param mesh The mesh the gizmo's should be attached to
  40816. */
  40817. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  40818. /**
  40819. * If the position gizmo is enabled
  40820. */
  40821. positionGizmoEnabled: boolean;
  40822. /**
  40823. * If the rotation gizmo is enabled
  40824. */
  40825. rotationGizmoEnabled: boolean;
  40826. /**
  40827. * If the scale gizmo is enabled
  40828. */
  40829. scaleGizmoEnabled: boolean;
  40830. /**
  40831. * If the boundingBox gizmo is enabled
  40832. */
  40833. boundingBoxGizmoEnabled: boolean;
  40834. /**
  40835. * Disposes of the gizmo manager
  40836. */
  40837. dispose(): void;
  40838. }
  40839. }
  40840. declare module BABYLON {
  40841. /** @hidden */
  40842. export var backgroundFragmentDeclaration: {
  40843. name: string;
  40844. shader: string;
  40845. };
  40846. }
  40847. declare module BABYLON {
  40848. /** @hidden */
  40849. export var backgroundUboDeclaration: {
  40850. name: string;
  40851. shader: string;
  40852. };
  40853. }
  40854. declare module BABYLON {
  40855. /** @hidden */
  40856. export var backgroundPixelShader: {
  40857. name: string;
  40858. shader: string;
  40859. };
  40860. }
  40861. declare module BABYLON {
  40862. /** @hidden */
  40863. export var backgroundVertexDeclaration: {
  40864. name: string;
  40865. shader: string;
  40866. };
  40867. }
  40868. declare module BABYLON {
  40869. /** @hidden */
  40870. export var backgroundVertexShader: {
  40871. name: string;
  40872. shader: string;
  40873. };
  40874. }
  40875. declare module BABYLON {
  40876. /**
  40877. * Background material used to create an efficient environement around your scene.
  40878. */
  40879. export class BackgroundMaterial extends PushMaterial {
  40880. /**
  40881. * Standard reflectance value at parallel view angle.
  40882. */
  40883. static StandardReflectance0: number;
  40884. /**
  40885. * Standard reflectance value at grazing angle.
  40886. */
  40887. static StandardReflectance90: number;
  40888. protected _primaryColor: Color3;
  40889. /**
  40890. * Key light Color (multiply against the environement texture)
  40891. */
  40892. primaryColor: Color3;
  40893. protected __perceptualColor: Nullable<Color3>;
  40894. /**
  40895. * Experimental Internal Use Only.
  40896. *
  40897. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  40898. * This acts as a helper to set the primary color to a more "human friendly" value.
  40899. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  40900. * output color as close as possible from the chosen value.
  40901. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  40902. * part of lighting setup.)
  40903. */ perceptualColor: Nullable<Color3>;
  40904. protected _primaryColorShadowLevel: float;
  40905. /**
  40906. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  40907. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  40908. */
  40909. primaryColorShadowLevel: float;
  40910. protected _primaryColorHighlightLevel: float;
  40911. /**
  40912. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  40913. * The primary color is used at the level chosen to define what the white area would look.
  40914. */
  40915. primaryColorHighlightLevel: float;
  40916. protected _reflectionTexture: Nullable<BaseTexture>;
  40917. /**
  40918. * Reflection Texture used in the material.
  40919. * Should be author in a specific way for the best result (refer to the documentation).
  40920. */
  40921. reflectionTexture: Nullable<BaseTexture>;
  40922. protected _reflectionBlur: float;
  40923. /**
  40924. * Reflection Texture level of blur.
  40925. *
  40926. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  40927. * texture twice.
  40928. */
  40929. reflectionBlur: float;
  40930. protected _diffuseTexture: Nullable<BaseTexture>;
  40931. /**
  40932. * Diffuse Texture used in the material.
  40933. * Should be author in a specific way for the best result (refer to the documentation).
  40934. */
  40935. diffuseTexture: Nullable<BaseTexture>;
  40936. protected _shadowLights: Nullable<IShadowLight[]>;
  40937. /**
  40938. * Specify the list of lights casting shadow on the material.
  40939. * All scene shadow lights will be included if null.
  40940. */
  40941. shadowLights: Nullable<IShadowLight[]>;
  40942. protected _shadowLevel: float;
  40943. /**
  40944. * Helps adjusting the shadow to a softer level if required.
  40945. * 0 means black shadows and 1 means no shadows.
  40946. */
  40947. shadowLevel: float;
  40948. protected _sceneCenter: Vector3;
  40949. /**
  40950. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  40951. * It is usually zero but might be interesting to modify according to your setup.
  40952. */
  40953. sceneCenter: Vector3;
  40954. protected _opacityFresnel: boolean;
  40955. /**
  40956. * This helps specifying that the material is falling off to the sky box at grazing angle.
  40957. * This helps ensuring a nice transition when the camera goes under the ground.
  40958. */
  40959. opacityFresnel: boolean;
  40960. protected _reflectionFresnel: boolean;
  40961. /**
  40962. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  40963. * This helps adding a mirror texture on the ground.
  40964. */
  40965. reflectionFresnel: boolean;
  40966. protected _reflectionFalloffDistance: number;
  40967. /**
  40968. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  40969. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  40970. */
  40971. reflectionFalloffDistance: number;
  40972. protected _reflectionAmount: number;
  40973. /**
  40974. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  40975. */
  40976. reflectionAmount: number;
  40977. protected _reflectionReflectance0: number;
  40978. /**
  40979. * This specifies the weight of the reflection at grazing angle.
  40980. */
  40981. reflectionReflectance0: number;
  40982. protected _reflectionReflectance90: number;
  40983. /**
  40984. * This specifies the weight of the reflection at a perpendicular point of view.
  40985. */
  40986. reflectionReflectance90: number;
  40987. /**
  40988. * Sets the reflection reflectance fresnel values according to the default standard
  40989. * empirically know to work well :-)
  40990. */
  40991. reflectionStandardFresnelWeight: number;
  40992. protected _useRGBColor: boolean;
  40993. /**
  40994. * Helps to directly use the maps channels instead of their level.
  40995. */
  40996. useRGBColor: boolean;
  40997. protected _enableNoise: boolean;
  40998. /**
  40999. * This helps reducing the banding effect that could occur on the background.
  41000. */
  41001. enableNoise: boolean;
  41002. /**
  41003. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41004. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  41005. * Recommended to be keep at 1.0 except for special cases.
  41006. */
  41007. fovMultiplier: number;
  41008. private _fovMultiplier;
  41009. /**
  41010. * Enable the FOV adjustment feature controlled by fovMultiplier.
  41011. */
  41012. useEquirectangularFOV: boolean;
  41013. private _maxSimultaneousLights;
  41014. /**
  41015. * Number of Simultaneous lights allowed on the material.
  41016. */
  41017. maxSimultaneousLights: int;
  41018. /**
  41019. * Default configuration related to image processing available in the Background Material.
  41020. */
  41021. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41022. /**
  41023. * Keep track of the image processing observer to allow dispose and replace.
  41024. */
  41025. private _imageProcessingObserver;
  41026. /**
  41027. * Attaches a new image processing configuration to the PBR Material.
  41028. * @param configuration (if null the scene configuration will be use)
  41029. */
  41030. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41031. /**
  41032. * Gets the image processing configuration used either in this material.
  41033. */
  41034. /**
  41035. * Sets the Default image processing configuration used either in the this material.
  41036. *
  41037. * If sets to null, the scene one is in use.
  41038. */
  41039. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  41040. /**
  41041. * Gets wether the color curves effect is enabled.
  41042. */
  41043. /**
  41044. * Sets wether the color curves effect is enabled.
  41045. */
  41046. cameraColorCurvesEnabled: boolean;
  41047. /**
  41048. * Gets wether the color grading effect is enabled.
  41049. */
  41050. /**
  41051. * Gets wether the color grading effect is enabled.
  41052. */
  41053. cameraColorGradingEnabled: boolean;
  41054. /**
  41055. * Gets wether tonemapping is enabled or not.
  41056. */
  41057. /**
  41058. * Sets wether tonemapping is enabled or not
  41059. */
  41060. cameraToneMappingEnabled: boolean;
  41061. /**
  41062. * The camera exposure used on this material.
  41063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41064. * This corresponds to a photographic exposure.
  41065. */
  41066. /**
  41067. * The camera exposure used on this material.
  41068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41069. * This corresponds to a photographic exposure.
  41070. */
  41071. cameraExposure: float;
  41072. /**
  41073. * Gets The camera contrast used on this material.
  41074. */
  41075. /**
  41076. * Sets The camera contrast used on this material.
  41077. */
  41078. cameraContrast: float;
  41079. /**
  41080. * Gets the Color Grading 2D Lookup Texture.
  41081. */
  41082. /**
  41083. * Sets the Color Grading 2D Lookup Texture.
  41084. */
  41085. cameraColorGradingTexture: Nullable<BaseTexture>;
  41086. /**
  41087. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41088. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41089. * 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;
  41090. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41091. */
  41092. /**
  41093. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41094. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41095. * 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;
  41096. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41097. */
  41098. cameraColorCurves: Nullable<ColorCurves>;
  41099. /**
  41100. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  41101. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  41102. */
  41103. switchToBGR: boolean;
  41104. private _renderTargets;
  41105. private _reflectionControls;
  41106. private _white;
  41107. private _primaryShadowColor;
  41108. private _primaryHighlightColor;
  41109. /**
  41110. * Instantiates a Background Material in the given scene
  41111. * @param name The friendly name of the material
  41112. * @param scene The scene to add the material to
  41113. */
  41114. constructor(name: string, scene: Scene);
  41115. /**
  41116. * Gets a boolean indicating that current material needs to register RTT
  41117. */
  41118. readonly hasRenderTargetTextures: boolean;
  41119. /**
  41120. * The entire material has been created in order to prevent overdraw.
  41121. * @returns false
  41122. */
  41123. needAlphaTesting(): boolean;
  41124. /**
  41125. * The entire material has been created in order to prevent overdraw.
  41126. * @returns true if blending is enable
  41127. */
  41128. needAlphaBlending(): boolean;
  41129. /**
  41130. * Checks wether the material is ready to be rendered for a given mesh.
  41131. * @param mesh The mesh to render
  41132. * @param subMesh The submesh to check against
  41133. * @param useInstances Specify wether or not the material is used with instances
  41134. * @returns true if all the dependencies are ready (Textures, Effects...)
  41135. */
  41136. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41137. /**
  41138. * Compute the primary color according to the chosen perceptual color.
  41139. */
  41140. private _computePrimaryColorFromPerceptualColor;
  41141. /**
  41142. * Compute the highlights and shadow colors according to their chosen levels.
  41143. */
  41144. private _computePrimaryColors;
  41145. /**
  41146. * Build the uniform buffer used in the material.
  41147. */
  41148. buildUniformLayout(): void;
  41149. /**
  41150. * Unbind the material.
  41151. */
  41152. unbind(): void;
  41153. /**
  41154. * Bind only the world matrix to the material.
  41155. * @param world The world matrix to bind.
  41156. */
  41157. bindOnlyWorldMatrix(world: Matrix): void;
  41158. /**
  41159. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  41160. * @param world The world matrix to bind.
  41161. * @param subMesh The submesh to bind for.
  41162. */
  41163. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41164. /**
  41165. * Dispose the material.
  41166. * @param forceDisposeEffect Force disposal of the associated effect.
  41167. * @param forceDisposeTextures Force disposal of the associated textures.
  41168. */
  41169. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41170. /**
  41171. * Clones the material.
  41172. * @param name The cloned name.
  41173. * @returns The cloned material.
  41174. */
  41175. clone(name: string): BackgroundMaterial;
  41176. /**
  41177. * Serializes the current material to its JSON representation.
  41178. * @returns The JSON representation.
  41179. */
  41180. serialize(): any;
  41181. /**
  41182. * Gets the class name of the material
  41183. * @returns "BackgroundMaterial"
  41184. */
  41185. getClassName(): string;
  41186. /**
  41187. * Parse a JSON input to create back a background material.
  41188. * @param source The JSON data to parse
  41189. * @param scene The scene to create the parsed material in
  41190. * @param rootUrl The root url of the assets the material depends upon
  41191. * @returns the instantiated BackgroundMaterial.
  41192. */
  41193. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  41194. }
  41195. }
  41196. declare module BABYLON {
  41197. /**
  41198. * Represents the different options available during the creation of
  41199. * a Environment helper.
  41200. *
  41201. * This can control the default ground, skybox and image processing setup of your scene.
  41202. */
  41203. export interface IEnvironmentHelperOptions {
  41204. /**
  41205. * Specifies wether or not to create a ground.
  41206. * True by default.
  41207. */
  41208. createGround: boolean;
  41209. /**
  41210. * Specifies the ground size.
  41211. * 15 by default.
  41212. */
  41213. groundSize: number;
  41214. /**
  41215. * The texture used on the ground for the main color.
  41216. * Comes from the BabylonJS CDN by default.
  41217. *
  41218. * Remarks: Can be either a texture or a url.
  41219. */
  41220. groundTexture: string | BaseTexture;
  41221. /**
  41222. * The color mixed in the ground texture by default.
  41223. * BabylonJS clearColor by default.
  41224. */
  41225. groundColor: Color3;
  41226. /**
  41227. * Specifies the ground opacity.
  41228. * 1 by default.
  41229. */
  41230. groundOpacity: number;
  41231. /**
  41232. * Enables the ground to receive shadows.
  41233. * True by default.
  41234. */
  41235. enableGroundShadow: boolean;
  41236. /**
  41237. * Helps preventing the shadow to be fully black on the ground.
  41238. * 0.5 by default.
  41239. */
  41240. groundShadowLevel: number;
  41241. /**
  41242. * Creates a mirror texture attach to the ground.
  41243. * false by default.
  41244. */
  41245. enableGroundMirror: boolean;
  41246. /**
  41247. * Specifies the ground mirror size ratio.
  41248. * 0.3 by default as the default kernel is 64.
  41249. */
  41250. groundMirrorSizeRatio: number;
  41251. /**
  41252. * Specifies the ground mirror blur kernel size.
  41253. * 64 by default.
  41254. */
  41255. groundMirrorBlurKernel: number;
  41256. /**
  41257. * Specifies the ground mirror visibility amount.
  41258. * 1 by default
  41259. */
  41260. groundMirrorAmount: number;
  41261. /**
  41262. * Specifies the ground mirror reflectance weight.
  41263. * This uses the standard weight of the background material to setup the fresnel effect
  41264. * of the mirror.
  41265. * 1 by default.
  41266. */
  41267. groundMirrorFresnelWeight: number;
  41268. /**
  41269. * Specifies the ground mirror Falloff distance.
  41270. * This can helps reducing the size of the reflection.
  41271. * 0 by Default.
  41272. */
  41273. groundMirrorFallOffDistance: number;
  41274. /**
  41275. * Specifies the ground mirror texture type.
  41276. * Unsigned Int by Default.
  41277. */
  41278. groundMirrorTextureType: number;
  41279. /**
  41280. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  41281. * the shown objects.
  41282. */
  41283. groundYBias: number;
  41284. /**
  41285. * Specifies wether or not to create a skybox.
  41286. * True by default.
  41287. */
  41288. createSkybox: boolean;
  41289. /**
  41290. * Specifies the skybox size.
  41291. * 20 by default.
  41292. */
  41293. skyboxSize: number;
  41294. /**
  41295. * The texture used on the skybox for the main color.
  41296. * Comes from the BabylonJS CDN by default.
  41297. *
  41298. * Remarks: Can be either a texture or a url.
  41299. */
  41300. skyboxTexture: string | BaseTexture;
  41301. /**
  41302. * The color mixed in the skybox texture by default.
  41303. * BabylonJS clearColor by default.
  41304. */
  41305. skyboxColor: Color3;
  41306. /**
  41307. * The background rotation around the Y axis of the scene.
  41308. * This helps aligning the key lights of your scene with the background.
  41309. * 0 by default.
  41310. */
  41311. backgroundYRotation: number;
  41312. /**
  41313. * Compute automatically the size of the elements to best fit with the scene.
  41314. */
  41315. sizeAuto: boolean;
  41316. /**
  41317. * Default position of the rootMesh if autoSize is not true.
  41318. */
  41319. rootPosition: Vector3;
  41320. /**
  41321. * Sets up the image processing in the scene.
  41322. * true by default.
  41323. */
  41324. setupImageProcessing: boolean;
  41325. /**
  41326. * The texture used as your environment texture in the scene.
  41327. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  41328. *
  41329. * Remarks: Can be either a texture or a url.
  41330. */
  41331. environmentTexture: string | BaseTexture;
  41332. /**
  41333. * The value of the exposure to apply to the scene.
  41334. * 0.6 by default if setupImageProcessing is true.
  41335. */
  41336. cameraExposure: number;
  41337. /**
  41338. * The value of the contrast to apply to the scene.
  41339. * 1.6 by default if setupImageProcessing is true.
  41340. */
  41341. cameraContrast: number;
  41342. /**
  41343. * Specifies wether or not tonemapping should be enabled in the scene.
  41344. * true by default if setupImageProcessing is true.
  41345. */
  41346. toneMappingEnabled: boolean;
  41347. }
  41348. /**
  41349. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  41350. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  41351. * It also helps with the default setup of your imageProcessing configuration.
  41352. */
  41353. export class EnvironmentHelper {
  41354. /**
  41355. * Default ground texture URL.
  41356. */
  41357. private static _groundTextureCDNUrl;
  41358. /**
  41359. * Default skybox texture URL.
  41360. */
  41361. private static _skyboxTextureCDNUrl;
  41362. /**
  41363. * Default environment texture URL.
  41364. */
  41365. private static _environmentTextureCDNUrl;
  41366. /**
  41367. * Creates the default options for the helper.
  41368. */
  41369. private static _getDefaultOptions;
  41370. private _rootMesh;
  41371. /**
  41372. * Gets the root mesh created by the helper.
  41373. */
  41374. readonly rootMesh: Mesh;
  41375. private _skybox;
  41376. /**
  41377. * Gets the skybox created by the helper.
  41378. */
  41379. readonly skybox: Nullable<Mesh>;
  41380. private _skyboxTexture;
  41381. /**
  41382. * Gets the skybox texture created by the helper.
  41383. */
  41384. readonly skyboxTexture: Nullable<BaseTexture>;
  41385. private _skyboxMaterial;
  41386. /**
  41387. * Gets the skybox material created by the helper.
  41388. */
  41389. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  41390. private _ground;
  41391. /**
  41392. * Gets the ground mesh created by the helper.
  41393. */
  41394. readonly ground: Nullable<Mesh>;
  41395. private _groundTexture;
  41396. /**
  41397. * Gets the ground texture created by the helper.
  41398. */
  41399. readonly groundTexture: Nullable<BaseTexture>;
  41400. private _groundMirror;
  41401. /**
  41402. * Gets the ground mirror created by the helper.
  41403. */
  41404. readonly groundMirror: Nullable<MirrorTexture>;
  41405. /**
  41406. * Gets the ground mirror render list to helps pushing the meshes
  41407. * you wish in the ground reflection.
  41408. */
  41409. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  41410. private _groundMaterial;
  41411. /**
  41412. * Gets the ground material created by the helper.
  41413. */
  41414. readonly groundMaterial: Nullable<BackgroundMaterial>;
  41415. /**
  41416. * Stores the creation options.
  41417. */
  41418. private readonly _scene;
  41419. private _options;
  41420. /**
  41421. * This observable will be notified with any error during the creation of the environment,
  41422. * mainly texture creation errors.
  41423. */
  41424. onErrorObservable: Observable<{
  41425. message?: string;
  41426. exception?: any;
  41427. }>;
  41428. /**
  41429. * constructor
  41430. * @param options Defines the options we want to customize the helper
  41431. * @param scene The scene to add the material to
  41432. */
  41433. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  41434. /**
  41435. * Updates the background according to the new options
  41436. * @param options
  41437. */
  41438. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  41439. /**
  41440. * Sets the primary color of all the available elements.
  41441. * @param color the main color to affect to the ground and the background
  41442. */
  41443. setMainColor(color: Color3): void;
  41444. /**
  41445. * Setup the image processing according to the specified options.
  41446. */
  41447. private _setupImageProcessing;
  41448. /**
  41449. * Setup the environment texture according to the specified options.
  41450. */
  41451. private _setupEnvironmentTexture;
  41452. /**
  41453. * Setup the background according to the specified options.
  41454. */
  41455. private _setupBackground;
  41456. /**
  41457. * Get the scene sizes according to the setup.
  41458. */
  41459. private _getSceneSize;
  41460. /**
  41461. * Setup the ground according to the specified options.
  41462. */
  41463. private _setupGround;
  41464. /**
  41465. * Setup the ground material according to the specified options.
  41466. */
  41467. private _setupGroundMaterial;
  41468. /**
  41469. * Setup the ground diffuse texture according to the specified options.
  41470. */
  41471. private _setupGroundDiffuseTexture;
  41472. /**
  41473. * Setup the ground mirror texture according to the specified options.
  41474. */
  41475. private _setupGroundMirrorTexture;
  41476. /**
  41477. * Setup the ground to receive the mirror texture.
  41478. */
  41479. private _setupMirrorInGroundMaterial;
  41480. /**
  41481. * Setup the skybox according to the specified options.
  41482. */
  41483. private _setupSkybox;
  41484. /**
  41485. * Setup the skybox material according to the specified options.
  41486. */
  41487. private _setupSkyboxMaterial;
  41488. /**
  41489. * Setup the skybox reflection texture according to the specified options.
  41490. */
  41491. private _setupSkyboxReflectionTexture;
  41492. private _errorHandler;
  41493. /**
  41494. * Dispose all the elements created by the Helper.
  41495. */
  41496. dispose(): void;
  41497. }
  41498. }
  41499. declare module BABYLON {
  41500. /**
  41501. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  41502. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  41503. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  41504. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  41505. */
  41506. export class PhotoDome extends TransformNode {
  41507. private _useDirectMapping;
  41508. /**
  41509. * The texture being displayed on the sphere
  41510. */
  41511. protected _photoTexture: Texture;
  41512. /**
  41513. * Gets or sets the texture being displayed on the sphere
  41514. */
  41515. photoTexture: Texture;
  41516. /**
  41517. * Observable raised when an error occured while loading the 360 image
  41518. */
  41519. onLoadErrorObservable: Observable<string>;
  41520. /**
  41521. * The skybox material
  41522. */
  41523. protected _material: BackgroundMaterial;
  41524. /**
  41525. * The surface used for the skybox
  41526. */
  41527. protected _mesh: Mesh;
  41528. /**
  41529. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41530. * Also see the options.resolution property.
  41531. */
  41532. fovMultiplier: number;
  41533. /**
  41534. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  41535. * @param name Element's name, child elements will append suffixes for their own names.
  41536. * @param urlsOfPhoto defines the url of the photo to display
  41537. * @param options defines an object containing optional or exposed sub element properties
  41538. * @param onError defines a callback called when an error occured while loading the texture
  41539. */
  41540. constructor(name: string, urlOfPhoto: string, options: {
  41541. resolution?: number;
  41542. size?: number;
  41543. useDirectMapping?: boolean;
  41544. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  41545. /**
  41546. * Releases resources associated with this node.
  41547. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  41548. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  41549. */
  41550. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  41551. }
  41552. }
  41553. declare module BABYLON {
  41554. /**
  41555. * Class used to host texture specific utilities
  41556. */
  41557. export class TextureTools {
  41558. /**
  41559. * Uses the GPU to create a copy texture rescaled at a given size
  41560. * @param texture Texture to copy from
  41561. * @param width defines the desired width
  41562. * @param height defines the desired height
  41563. * @param useBilinearMode defines if bilinear mode has to be used
  41564. * @return the generated texture
  41565. */
  41566. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  41567. /**
  41568. * Gets an environment BRDF texture for a given scene
  41569. * @param scene defines the hosting scene
  41570. * @returns the environment BRDF texture
  41571. */
  41572. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  41573. private static _environmentBRDFBase64Texture;
  41574. }
  41575. }
  41576. declare module BABYLON {
  41577. /** @hidden */
  41578. export var pbrFragmentDeclaration: {
  41579. name: string;
  41580. shader: string;
  41581. };
  41582. }
  41583. declare module BABYLON {
  41584. /** @hidden */
  41585. export var pbrUboDeclaration: {
  41586. name: string;
  41587. shader: string;
  41588. };
  41589. }
  41590. declare module BABYLON {
  41591. /** @hidden */
  41592. export var pbrFunctions: {
  41593. name: string;
  41594. shader: string;
  41595. };
  41596. }
  41597. declare module BABYLON {
  41598. /** @hidden */
  41599. export var harmonicsFunctions: {
  41600. name: string;
  41601. shader: string;
  41602. };
  41603. }
  41604. declare module BABYLON {
  41605. /** @hidden */
  41606. export var pbrLightFunctions: {
  41607. name: string;
  41608. shader: string;
  41609. };
  41610. }
  41611. declare module BABYLON {
  41612. /** @hidden */
  41613. export var pbrPixelShader: {
  41614. name: string;
  41615. shader: string;
  41616. };
  41617. }
  41618. declare module BABYLON {
  41619. /** @hidden */
  41620. export var pbrVertexDeclaration: {
  41621. name: string;
  41622. shader: string;
  41623. };
  41624. }
  41625. declare module BABYLON {
  41626. /** @hidden */
  41627. export var pbrVertexShader: {
  41628. name: string;
  41629. shader: string;
  41630. };
  41631. }
  41632. declare module BABYLON {
  41633. /**
  41634. * The Physically based material base class of BJS.
  41635. *
  41636. * This offers the main features of a standard PBR material.
  41637. * For more information, please refer to the documentation :
  41638. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  41639. */
  41640. export abstract class PBRBaseMaterial extends PushMaterial {
  41641. /**
  41642. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  41643. */
  41644. static readonly PBRMATERIAL_OPAQUE: number;
  41645. /**
  41646. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  41647. */
  41648. static readonly PBRMATERIAL_ALPHATEST: number;
  41649. /**
  41650. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  41651. */
  41652. static readonly PBRMATERIAL_ALPHABLEND: number;
  41653. /**
  41654. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  41655. * They are also discarded below the alpha cutoff threshold to improve performances.
  41656. */
  41657. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  41658. /**
  41659. * Defines the default value of how much AO map is occluding the analytical lights
  41660. * (point spot...).
  41661. */
  41662. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  41663. /**
  41664. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  41665. */
  41666. static readonly LIGHTFALLOFF_PHYSICAL: number;
  41667. /**
  41668. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  41669. * to enhance interoperability with other engines.
  41670. */
  41671. static readonly LIGHTFALLOFF_GLTF: number;
  41672. /**
  41673. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  41674. * to enhance interoperability with other materials.
  41675. */
  41676. static readonly LIGHTFALLOFF_STANDARD: number;
  41677. /**
  41678. * Intensity of the direct lights e.g. the four lights available in your scene.
  41679. * This impacts both the direct diffuse and specular highlights.
  41680. */
  41681. protected _directIntensity: number;
  41682. /**
  41683. * Intensity of the emissive part of the material.
  41684. * This helps controlling the emissive effect without modifying the emissive color.
  41685. */
  41686. protected _emissiveIntensity: number;
  41687. /**
  41688. * Intensity of the environment e.g. how much the environment will light the object
  41689. * either through harmonics for rough material or through the refelction for shiny ones.
  41690. */
  41691. protected _environmentIntensity: number;
  41692. /**
  41693. * This is a special control allowing the reduction of the specular highlights coming from the
  41694. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  41695. */
  41696. protected _specularIntensity: number;
  41697. /**
  41698. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  41699. */
  41700. private _lightingInfos;
  41701. /**
  41702. * Debug Control allowing disabling the bump map on this material.
  41703. */
  41704. protected _disableBumpMap: boolean;
  41705. /**
  41706. * AKA Diffuse Texture in standard nomenclature.
  41707. */
  41708. protected _albedoTexture: BaseTexture;
  41709. /**
  41710. * AKA Occlusion Texture in other nomenclature.
  41711. */
  41712. protected _ambientTexture: BaseTexture;
  41713. /**
  41714. * AKA Occlusion Texture Intensity in other nomenclature.
  41715. */
  41716. protected _ambientTextureStrength: number;
  41717. /**
  41718. * Defines how much the AO map is occluding the analytical lights (point spot...).
  41719. * 1 means it completely occludes it
  41720. * 0 mean it has no impact
  41721. */
  41722. protected _ambientTextureImpactOnAnalyticalLights: number;
  41723. /**
  41724. * Stores the alpha values in a texture.
  41725. */
  41726. protected _opacityTexture: BaseTexture;
  41727. /**
  41728. * Stores the reflection values in a texture.
  41729. */
  41730. protected _reflectionTexture: BaseTexture;
  41731. /**
  41732. * Stores the refraction values in a texture.
  41733. */
  41734. protected _refractionTexture: BaseTexture;
  41735. /**
  41736. * Stores the emissive values in a texture.
  41737. */
  41738. protected _emissiveTexture: BaseTexture;
  41739. /**
  41740. * AKA Specular texture in other nomenclature.
  41741. */
  41742. protected _reflectivityTexture: BaseTexture;
  41743. /**
  41744. * Used to switch from specular/glossiness to metallic/roughness workflow.
  41745. */
  41746. protected _metallicTexture: BaseTexture;
  41747. /**
  41748. * Specifies the metallic scalar of the metallic/roughness workflow.
  41749. * Can also be used to scale the metalness values of the metallic texture.
  41750. */
  41751. protected _metallic: Nullable<number>;
  41752. /**
  41753. * Specifies the roughness scalar of the metallic/roughness workflow.
  41754. * Can also be used to scale the roughness values of the metallic texture.
  41755. */
  41756. protected _roughness: Nullable<number>;
  41757. /**
  41758. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  41759. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  41760. */
  41761. protected _microSurfaceTexture: BaseTexture;
  41762. /**
  41763. * Stores surface normal data used to displace a mesh in a texture.
  41764. */
  41765. protected _bumpTexture: BaseTexture;
  41766. /**
  41767. * Stores the pre-calculated light information of a mesh in a texture.
  41768. */
  41769. protected _lightmapTexture: BaseTexture;
  41770. /**
  41771. * The color of a material in ambient lighting.
  41772. */
  41773. protected _ambientColor: Color3;
  41774. /**
  41775. * AKA Diffuse Color in other nomenclature.
  41776. */
  41777. protected _albedoColor: Color3;
  41778. /**
  41779. * AKA Specular Color in other nomenclature.
  41780. */
  41781. protected _reflectivityColor: Color3;
  41782. /**
  41783. * The color applied when light is reflected from a material.
  41784. */
  41785. protected _reflectionColor: Color3;
  41786. /**
  41787. * The color applied when light is emitted from a material.
  41788. */
  41789. protected _emissiveColor: Color3;
  41790. /**
  41791. * AKA Glossiness in other nomenclature.
  41792. */
  41793. protected _microSurface: number;
  41794. /**
  41795. * source material index of refraction (IOR)' / 'destination material IOR.
  41796. */
  41797. protected _indexOfRefraction: number;
  41798. /**
  41799. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  41800. */
  41801. protected _invertRefractionY: boolean;
  41802. /**
  41803. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  41804. * Materials half opaque for instance using refraction could benefit from this control.
  41805. */
  41806. protected _linkRefractionWithTransparency: boolean;
  41807. /**
  41808. * Specifies that the material will use the light map as a show map.
  41809. */
  41810. protected _useLightmapAsShadowmap: boolean;
  41811. /**
  41812. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  41813. * makes the reflect vector face the model (under horizon).
  41814. */
  41815. protected _useHorizonOcclusion: boolean;
  41816. /**
  41817. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  41818. * too much the area relying on ambient texture to define their ambient occlusion.
  41819. */
  41820. protected _useRadianceOcclusion: boolean;
  41821. /**
  41822. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  41823. */
  41824. protected _useAlphaFromAlbedoTexture: boolean;
  41825. /**
  41826. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  41827. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41828. */
  41829. protected _useSpecularOverAlpha: boolean;
  41830. /**
  41831. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  41832. */
  41833. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  41834. /**
  41835. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  41836. */
  41837. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  41838. /**
  41839. * Specifies if the metallic texture contains the roughness information in its green channel.
  41840. */
  41841. protected _useRoughnessFromMetallicTextureGreen: boolean;
  41842. /**
  41843. * Specifies if the metallic texture contains the metallness information in its blue channel.
  41844. */
  41845. protected _useMetallnessFromMetallicTextureBlue: boolean;
  41846. /**
  41847. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  41848. */
  41849. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  41850. /**
  41851. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  41852. */
  41853. protected _useAmbientInGrayScale: boolean;
  41854. /**
  41855. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  41856. * The material will try to infer what glossiness each pixel should be.
  41857. */
  41858. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  41859. /**
  41860. * Defines the falloff type used in this material.
  41861. * It by default is Physical.
  41862. */
  41863. protected _lightFalloff: number;
  41864. /**
  41865. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41866. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41867. */
  41868. protected _useRadianceOverAlpha: boolean;
  41869. /**
  41870. * Allows using an object space normal map (instead of tangent space).
  41871. */
  41872. protected _useObjectSpaceNormalMap: boolean;
  41873. /**
  41874. * Allows using the bump map in parallax mode.
  41875. */
  41876. protected _useParallax: boolean;
  41877. /**
  41878. * Allows using the bump map in parallax occlusion mode.
  41879. */
  41880. protected _useParallaxOcclusion: boolean;
  41881. /**
  41882. * Controls the scale bias of the parallax mode.
  41883. */
  41884. protected _parallaxScaleBias: number;
  41885. /**
  41886. * If sets to true, disables all the lights affecting the material.
  41887. */
  41888. protected _disableLighting: boolean;
  41889. /**
  41890. * Number of Simultaneous lights allowed on the material.
  41891. */
  41892. protected _maxSimultaneousLights: number;
  41893. /**
  41894. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  41895. */
  41896. protected _invertNormalMapX: boolean;
  41897. /**
  41898. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  41899. */
  41900. protected _invertNormalMapY: boolean;
  41901. /**
  41902. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41903. */
  41904. protected _twoSidedLighting: boolean;
  41905. /**
  41906. * Defines the alpha limits in alpha test mode.
  41907. */
  41908. protected _alphaCutOff: number;
  41909. /**
  41910. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  41911. */
  41912. protected _forceAlphaTest: boolean;
  41913. /**
  41914. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  41915. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  41916. */
  41917. protected _useAlphaFresnel: boolean;
  41918. /**
  41919. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  41920. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  41921. */
  41922. protected _useLinearAlphaFresnel: boolean;
  41923. /**
  41924. * The transparency mode of the material.
  41925. */
  41926. protected _transparencyMode: Nullable<number>;
  41927. /**
  41928. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  41929. * from cos thetav and roughness:
  41930. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  41931. */
  41932. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  41933. /**
  41934. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  41935. */
  41936. protected _forceIrradianceInFragment: boolean;
  41937. /**
  41938. * Force normal to face away from face.
  41939. */
  41940. protected _forceNormalForward: boolean;
  41941. /**
  41942. * Enables specular anti aliasing in the PBR shader.
  41943. * It will both interacts on the Geometry for analytical and IBL lighting.
  41944. * It also prefilter the roughness map based on the bump values.
  41945. */
  41946. protected _enableSpecularAntiAliasing: boolean;
  41947. /**
  41948. * Default configuration related to image processing available in the PBR Material.
  41949. */
  41950. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41951. /**
  41952. * Keep track of the image processing observer to allow dispose and replace.
  41953. */
  41954. private _imageProcessingObserver;
  41955. /**
  41956. * Attaches a new image processing configuration to the PBR Material.
  41957. * @param configuration
  41958. */
  41959. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41960. /**
  41961. * Stores the available render targets.
  41962. */
  41963. private _renderTargets;
  41964. /**
  41965. * Sets the global ambient color for the material used in lighting calculations.
  41966. */
  41967. private _globalAmbientColor;
  41968. /**
  41969. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  41970. */
  41971. private _useLogarithmicDepth;
  41972. /**
  41973. * If set to true, no lighting calculations will be applied.
  41974. */
  41975. private _unlit;
  41976. /**
  41977. * Instantiates a new PBRMaterial instance.
  41978. *
  41979. * @param name The material name
  41980. * @param scene The scene the material will be use in.
  41981. */
  41982. constructor(name: string, scene: Scene);
  41983. /**
  41984. * Gets a boolean indicating that current material needs to register RTT
  41985. */
  41986. readonly hasRenderTargetTextures: boolean;
  41987. /**
  41988. * Gets the name of the material class.
  41989. */
  41990. getClassName(): string;
  41991. /**
  41992. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  41993. */
  41994. /**
  41995. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  41996. */
  41997. useLogarithmicDepth: boolean;
  41998. /**
  41999. * Gets the current transparency mode.
  42000. */
  42001. /**
  42002. * Sets the transparency mode of the material.
  42003. *
  42004. * | Value | Type | Description |
  42005. * | ----- | ----------------------------------- | ----------- |
  42006. * | 0 | OPAQUE | |
  42007. * | 1 | ALPHATEST | |
  42008. * | 2 | ALPHABLEND | |
  42009. * | 3 | ALPHATESTANDBLEND | |
  42010. *
  42011. */
  42012. transparencyMode: Nullable<number>;
  42013. /**
  42014. * Returns true if alpha blending should be disabled.
  42015. */
  42016. private readonly _disableAlphaBlending;
  42017. /**
  42018. * Specifies whether or not this material should be rendered in alpha blend mode.
  42019. */
  42020. needAlphaBlending(): boolean;
  42021. /**
  42022. * Specifies if the mesh will require alpha blending.
  42023. * @param mesh - BJS mesh.
  42024. */
  42025. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  42026. /**
  42027. * Specifies whether or not this material should be rendered in alpha test mode.
  42028. */
  42029. needAlphaTesting(): boolean;
  42030. /**
  42031. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  42032. */
  42033. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  42034. /**
  42035. * Gets the texture used for the alpha test.
  42036. */
  42037. getAlphaTestTexture(): BaseTexture;
  42038. /**
  42039. * Specifies that the submesh is ready to be used.
  42040. * @param mesh - BJS mesh.
  42041. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  42042. * @param useInstances - Specifies that instances should be used.
  42043. * @returns - boolean indicating that the submesh is ready or not.
  42044. */
  42045. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42046. /**
  42047. * Specifies if the material uses metallic roughness workflow.
  42048. * @returns boolean specifiying if the material uses metallic roughness workflow.
  42049. */
  42050. isMetallicWorkflow(): boolean;
  42051. private _prepareEffect;
  42052. private _prepareDefines;
  42053. /**
  42054. * Force shader compilation
  42055. */
  42056. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  42057. clipPlane: boolean;
  42058. }>): void;
  42059. /**
  42060. * Initializes the uniform buffer layout for the shader.
  42061. */
  42062. buildUniformLayout(): void;
  42063. /**
  42064. * Unbinds the textures.
  42065. */
  42066. unbind(): void;
  42067. /**
  42068. * Binds the submesh data.
  42069. * @param world - The world matrix.
  42070. * @param mesh - The BJS mesh.
  42071. * @param subMesh - A submesh of the BJS mesh.
  42072. */
  42073. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42074. /**
  42075. * Returns the animatable textures.
  42076. * @returns - Array of animatable textures.
  42077. */
  42078. getAnimatables(): IAnimatable[];
  42079. /**
  42080. * Returns the texture used for reflections.
  42081. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  42082. */
  42083. private _getReflectionTexture;
  42084. /**
  42085. * Returns the texture used for refraction or null if none is used.
  42086. * @returns - Refection texture if present. If no refraction texture and refraction
  42087. * is linked with transparency, returns environment texture. Otherwise, returns null.
  42088. */
  42089. private _getRefractionTexture;
  42090. /**
  42091. * Disposes the resources of the material.
  42092. * @param forceDisposeEffect - Forces the disposal of effects.
  42093. * @param forceDisposeTextures - Forces the disposal of all textures.
  42094. */
  42095. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42096. }
  42097. }
  42098. declare module BABYLON {
  42099. /**
  42100. * The Physically based material of BJS.
  42101. *
  42102. * This offers the main features of a standard PBR material.
  42103. * For more information, please refer to the documentation :
  42104. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  42105. */
  42106. export class PBRMaterial extends PBRBaseMaterial {
  42107. /**
  42108. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  42109. */
  42110. static readonly PBRMATERIAL_OPAQUE: number;
  42111. /**
  42112. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  42113. */
  42114. static readonly PBRMATERIAL_ALPHATEST: number;
  42115. /**
  42116. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42117. */
  42118. static readonly PBRMATERIAL_ALPHABLEND: number;
  42119. /**
  42120. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42121. * They are also discarded below the alpha cutoff threshold to improve performances.
  42122. */
  42123. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  42124. /**
  42125. * Defines the default value of how much AO map is occluding the analytical lights
  42126. * (point spot...).
  42127. */
  42128. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  42129. /**
  42130. * Intensity of the direct lights e.g. the four lights available in your scene.
  42131. * This impacts both the direct diffuse and specular highlights.
  42132. */
  42133. directIntensity: number;
  42134. /**
  42135. * Intensity of the emissive part of the material.
  42136. * This helps controlling the emissive effect without modifying the emissive color.
  42137. */
  42138. emissiveIntensity: number;
  42139. /**
  42140. * Intensity of the environment e.g. how much the environment will light the object
  42141. * either through harmonics for rough material or through the refelction for shiny ones.
  42142. */
  42143. environmentIntensity: number;
  42144. /**
  42145. * This is a special control allowing the reduction of the specular highlights coming from the
  42146. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  42147. */
  42148. specularIntensity: number;
  42149. /**
  42150. * Debug Control allowing disabling the bump map on this material.
  42151. */
  42152. disableBumpMap: boolean;
  42153. /**
  42154. * AKA Diffuse Texture in standard nomenclature.
  42155. */
  42156. albedoTexture: BaseTexture;
  42157. /**
  42158. * AKA Occlusion Texture in other nomenclature.
  42159. */
  42160. ambientTexture: BaseTexture;
  42161. /**
  42162. * AKA Occlusion Texture Intensity in other nomenclature.
  42163. */
  42164. ambientTextureStrength: number;
  42165. /**
  42166. * Defines how much the AO map is occluding the analytical lights (point spot...).
  42167. * 1 means it completely occludes it
  42168. * 0 mean it has no impact
  42169. */
  42170. ambientTextureImpactOnAnalyticalLights: number;
  42171. /**
  42172. * Stores the alpha values in a texture.
  42173. */
  42174. opacityTexture: BaseTexture;
  42175. /**
  42176. * Stores the reflection values in a texture.
  42177. */
  42178. reflectionTexture: Nullable<BaseTexture>;
  42179. /**
  42180. * Stores the emissive values in a texture.
  42181. */
  42182. emissiveTexture: BaseTexture;
  42183. /**
  42184. * AKA Specular texture in other nomenclature.
  42185. */
  42186. reflectivityTexture: BaseTexture;
  42187. /**
  42188. * Used to switch from specular/glossiness to metallic/roughness workflow.
  42189. */
  42190. metallicTexture: BaseTexture;
  42191. /**
  42192. * Specifies the metallic scalar of the metallic/roughness workflow.
  42193. * Can also be used to scale the metalness values of the metallic texture.
  42194. */
  42195. metallic: Nullable<number>;
  42196. /**
  42197. * Specifies the roughness scalar of the metallic/roughness workflow.
  42198. * Can also be used to scale the roughness values of the metallic texture.
  42199. */
  42200. roughness: Nullable<number>;
  42201. /**
  42202. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  42203. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  42204. */
  42205. microSurfaceTexture: BaseTexture;
  42206. /**
  42207. * Stores surface normal data used to displace a mesh in a texture.
  42208. */
  42209. bumpTexture: BaseTexture;
  42210. /**
  42211. * Stores the pre-calculated light information of a mesh in a texture.
  42212. */
  42213. lightmapTexture: BaseTexture;
  42214. /**
  42215. * Stores the refracted light information in a texture.
  42216. */
  42217. refractionTexture: BaseTexture;
  42218. /**
  42219. * The color of a material in ambient lighting.
  42220. */
  42221. ambientColor: Color3;
  42222. /**
  42223. * AKA Diffuse Color in other nomenclature.
  42224. */
  42225. albedoColor: Color3;
  42226. /**
  42227. * AKA Specular Color in other nomenclature.
  42228. */
  42229. reflectivityColor: Color3;
  42230. /**
  42231. * The color reflected from the material.
  42232. */
  42233. reflectionColor: Color3;
  42234. /**
  42235. * The color emitted from the material.
  42236. */
  42237. emissiveColor: Color3;
  42238. /**
  42239. * AKA Glossiness in other nomenclature.
  42240. */
  42241. microSurface: number;
  42242. /**
  42243. * source material index of refraction (IOR)' / 'destination material IOR.
  42244. */
  42245. indexOfRefraction: number;
  42246. /**
  42247. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  42248. */
  42249. invertRefractionY: boolean;
  42250. /**
  42251. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  42252. * Materials half opaque for instance using refraction could benefit from this control.
  42253. */
  42254. linkRefractionWithTransparency: boolean;
  42255. /**
  42256. * If true, the light map contains occlusion information instead of lighting info.
  42257. */
  42258. useLightmapAsShadowmap: boolean;
  42259. /**
  42260. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  42261. */
  42262. useAlphaFromAlbedoTexture: boolean;
  42263. /**
  42264. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  42265. */
  42266. forceAlphaTest: boolean;
  42267. /**
  42268. * Defines the alpha limits in alpha test mode.
  42269. */
  42270. alphaCutOff: number;
  42271. /**
  42272. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42273. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42274. */
  42275. useSpecularOverAlpha: boolean;
  42276. /**
  42277. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  42278. */
  42279. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  42280. /**
  42281. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  42282. */
  42283. useRoughnessFromMetallicTextureAlpha: boolean;
  42284. /**
  42285. * Specifies if the metallic texture contains the roughness information in its green channel.
  42286. */
  42287. useRoughnessFromMetallicTextureGreen: boolean;
  42288. /**
  42289. * Specifies if the metallic texture contains the metallness information in its blue channel.
  42290. */
  42291. useMetallnessFromMetallicTextureBlue: boolean;
  42292. /**
  42293. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  42294. */
  42295. useAmbientOcclusionFromMetallicTextureRed: boolean;
  42296. /**
  42297. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  42298. */
  42299. useAmbientInGrayScale: boolean;
  42300. /**
  42301. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  42302. * The material will try to infer what glossiness each pixel should be.
  42303. */
  42304. useAutoMicroSurfaceFromReflectivityMap: boolean;
  42305. /**
  42306. * BJS is using an harcoded light falloff based on a manually sets up range.
  42307. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  42308. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  42309. */
  42310. /**
  42311. * BJS is using an harcoded light falloff based on a manually sets up range.
  42312. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  42313. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  42314. */
  42315. usePhysicalLightFalloff: boolean;
  42316. /**
  42317. * In order to support the falloff compatibility with gltf, a special mode has been added
  42318. * to reproduce the gltf light falloff.
  42319. */
  42320. /**
  42321. * In order to support the falloff compatibility with gltf, a special mode has been added
  42322. * to reproduce the gltf light falloff.
  42323. */
  42324. useGLTFLightFalloff: boolean;
  42325. /**
  42326. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42327. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42328. */
  42329. useRadianceOverAlpha: boolean;
  42330. /**
  42331. * Allows using an object space normal map (instead of tangent space).
  42332. */
  42333. useObjectSpaceNormalMap: boolean;
  42334. /**
  42335. * Allows using the bump map in parallax mode.
  42336. */
  42337. useParallax: boolean;
  42338. /**
  42339. * Allows using the bump map in parallax occlusion mode.
  42340. */
  42341. useParallaxOcclusion: boolean;
  42342. /**
  42343. * Controls the scale bias of the parallax mode.
  42344. */
  42345. parallaxScaleBias: number;
  42346. /**
  42347. * If sets to true, disables all the lights affecting the material.
  42348. */
  42349. disableLighting: boolean;
  42350. /**
  42351. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  42352. */
  42353. forceIrradianceInFragment: boolean;
  42354. /**
  42355. * Number of Simultaneous lights allowed on the material.
  42356. */
  42357. maxSimultaneousLights: number;
  42358. /**
  42359. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42360. */
  42361. invertNormalMapX: boolean;
  42362. /**
  42363. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42364. */
  42365. invertNormalMapY: boolean;
  42366. /**
  42367. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42368. */
  42369. twoSidedLighting: boolean;
  42370. /**
  42371. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42372. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  42373. */
  42374. useAlphaFresnel: boolean;
  42375. /**
  42376. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42377. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  42378. */
  42379. useLinearAlphaFresnel: boolean;
  42380. /**
  42381. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42382. * And/Or occlude the blended part.
  42383. */
  42384. environmentBRDFTexture: Nullable<BaseTexture>;
  42385. /**
  42386. * Force normal to face away from face.
  42387. */
  42388. forceNormalForward: boolean;
  42389. /**
  42390. * Enables specular anti aliasing in the PBR shader.
  42391. * It will both interacts on the Geometry for analytical and IBL lighting.
  42392. * It also prefilter the roughness map based on the bump values.
  42393. */
  42394. enableSpecularAntiAliasing: boolean;
  42395. /**
  42396. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  42397. * makes the reflect vector face the model (under horizon).
  42398. */
  42399. useHorizonOcclusion: boolean;
  42400. /**
  42401. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  42402. * too much the area relying on ambient texture to define their ambient occlusion.
  42403. */
  42404. useRadianceOcclusion: boolean;
  42405. /**
  42406. * If set to true, no lighting calculations will be applied.
  42407. */
  42408. unlit: boolean;
  42409. /**
  42410. * Gets the image processing configuration used either in this material.
  42411. */
  42412. /**
  42413. * Sets the Default image processing configuration used either in the this material.
  42414. *
  42415. * If sets to null, the scene one is in use.
  42416. */
  42417. imageProcessingConfiguration: ImageProcessingConfiguration;
  42418. /**
  42419. * Gets wether the color curves effect is enabled.
  42420. */
  42421. /**
  42422. * Sets wether the color curves effect is enabled.
  42423. */
  42424. cameraColorCurvesEnabled: boolean;
  42425. /**
  42426. * Gets wether the color grading effect is enabled.
  42427. */
  42428. /**
  42429. * Gets wether the color grading effect is enabled.
  42430. */
  42431. cameraColorGradingEnabled: boolean;
  42432. /**
  42433. * Gets wether tonemapping is enabled or not.
  42434. */
  42435. /**
  42436. * Sets wether tonemapping is enabled or not
  42437. */
  42438. cameraToneMappingEnabled: boolean;
  42439. /**
  42440. * The camera exposure used on this material.
  42441. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42442. * This corresponds to a photographic exposure.
  42443. */
  42444. /**
  42445. * The camera exposure used on this material.
  42446. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42447. * This corresponds to a photographic exposure.
  42448. */
  42449. cameraExposure: number;
  42450. /**
  42451. * Gets The camera contrast used on this material.
  42452. */
  42453. /**
  42454. * Sets The camera contrast used on this material.
  42455. */
  42456. cameraContrast: number;
  42457. /**
  42458. * Gets the Color Grading 2D Lookup Texture.
  42459. */
  42460. /**
  42461. * Sets the Color Grading 2D Lookup Texture.
  42462. */
  42463. cameraColorGradingTexture: Nullable<BaseTexture>;
  42464. /**
  42465. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42466. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42467. * 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;
  42468. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42469. */
  42470. /**
  42471. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42472. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42473. * 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;
  42474. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42475. */
  42476. cameraColorCurves: Nullable<ColorCurves>;
  42477. /**
  42478. * Instantiates a new PBRMaterial instance.
  42479. *
  42480. * @param name The material name
  42481. * @param scene The scene the material will be use in.
  42482. */
  42483. constructor(name: string, scene: Scene);
  42484. /**
  42485. * Returns the name of this material class.
  42486. */
  42487. getClassName(): string;
  42488. /**
  42489. * Returns an array of the actively used textures.
  42490. * @returns - Array of BaseTextures
  42491. */
  42492. getActiveTextures(): BaseTexture[];
  42493. /**
  42494. * Checks to see if a texture is used in the material.
  42495. * @param texture - Base texture to use.
  42496. * @returns - Boolean specifying if a texture is used in the material.
  42497. */
  42498. hasTexture(texture: BaseTexture): boolean;
  42499. /**
  42500. * Makes a duplicate of the current material.
  42501. * @param name - name to use for the new material.
  42502. */
  42503. clone(name: string): PBRMaterial;
  42504. /**
  42505. * Serializes this PBR Material.
  42506. * @returns - An object with the serialized material.
  42507. */
  42508. serialize(): any;
  42509. /**
  42510. * Parses a PBR Material from a serialized object.
  42511. * @param source - Serialized object.
  42512. * @param scene - BJS scene instance.
  42513. * @param rootUrl - url for the scene object
  42514. * @returns - PBRMaterial
  42515. */
  42516. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  42517. }
  42518. }
  42519. declare module BABYLON {
  42520. /** @hidden */
  42521. export var _forceSceneHelpersToBundle: boolean;
  42522. interface Scene {
  42523. /**
  42524. * Creates a default light for the scene.
  42525. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  42526. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  42527. */
  42528. createDefaultLight(replace?: boolean): void;
  42529. /**
  42530. * Creates a default camera for the scene.
  42531. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  42532. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  42533. * @param replace has default false, when true replaces the active camera in the scene
  42534. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  42535. */
  42536. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  42537. /**
  42538. * Creates a default camera and a default light.
  42539. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  42540. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  42541. * @param replace has the default false, when true replaces the active camera/light in the scene
  42542. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  42543. */
  42544. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  42545. /**
  42546. * Creates a new sky box
  42547. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  42548. * @param environmentTexture defines the texture to use as environment texture
  42549. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  42550. * @param scale defines the overall scale of the skybox
  42551. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  42552. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  42553. * @returns a new mesh holding the sky box
  42554. */
  42555. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  42556. /**
  42557. * Creates a new environment
  42558. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  42559. * @param options defines the options you can use to configure the environment
  42560. * @returns the new EnvironmentHelper
  42561. */
  42562. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  42563. /**
  42564. * Creates a new VREXperienceHelper
  42565. * @see http://doc.babylonjs.com/how_to/webvr_helper
  42566. * @param webVROptions defines the options used to create the new VREXperienceHelper
  42567. * @returns a new VREXperienceHelper
  42568. */
  42569. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  42570. /**
  42571. * Creates a new XREXperienceHelper
  42572. * @see http://doc.babylonjs.com/how_to/webxr
  42573. * @returns a promise for a new XREXperienceHelper
  42574. */
  42575. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  42576. }
  42577. }
  42578. declare module BABYLON {
  42579. /**
  42580. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  42581. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  42582. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  42583. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  42584. */
  42585. export class VideoDome extends TransformNode {
  42586. private _useDirectMapping;
  42587. /**
  42588. * The video texture being displayed on the sphere
  42589. */
  42590. protected _videoTexture: VideoTexture;
  42591. /**
  42592. * Gets the video texture being displayed on the sphere
  42593. */
  42594. readonly videoTexture: VideoTexture;
  42595. /**
  42596. * The skybox material
  42597. */
  42598. protected _material: BackgroundMaterial;
  42599. /**
  42600. * The surface used for the skybox
  42601. */
  42602. protected _mesh: Mesh;
  42603. /**
  42604. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42605. * Also see the options.resolution property.
  42606. */
  42607. fovMultiplier: number;
  42608. /**
  42609. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  42610. * @param name Element's name, child elements will append suffixes for their own names.
  42611. * @param urlsOrVideo defines the url(s) or the video element to use
  42612. * @param options An object containing optional or exposed sub element properties
  42613. */
  42614. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  42615. resolution?: number;
  42616. clickToPlay?: boolean;
  42617. autoPlay?: boolean;
  42618. loop?: boolean;
  42619. size?: number;
  42620. poster?: string;
  42621. useDirectMapping?: boolean;
  42622. }, scene: Scene);
  42623. /**
  42624. * Releases resources associated with this node.
  42625. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  42626. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  42627. */
  42628. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  42629. }
  42630. }
  42631. declare module BABYLON {
  42632. /**
  42633. * This class can be used to get instrumentation data from a Babylon engine
  42634. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42635. */
  42636. export class EngineInstrumentation implements IDisposable {
  42637. /**
  42638. * Define the instrumented engine.
  42639. */
  42640. engine: Engine;
  42641. private _captureGPUFrameTime;
  42642. private _gpuFrameTimeToken;
  42643. private _gpuFrameTime;
  42644. private _captureShaderCompilationTime;
  42645. private _shaderCompilationTime;
  42646. private _onBeginFrameObserver;
  42647. private _onEndFrameObserver;
  42648. private _onBeforeShaderCompilationObserver;
  42649. private _onAfterShaderCompilationObserver;
  42650. /**
  42651. * Gets the perf counter used for GPU frame time
  42652. */
  42653. readonly gpuFrameTimeCounter: PerfCounter;
  42654. /**
  42655. * Gets the GPU frame time capture status
  42656. */
  42657. /**
  42658. * Enable or disable the GPU frame time capture
  42659. */
  42660. captureGPUFrameTime: boolean;
  42661. /**
  42662. * Gets the perf counter used for shader compilation time
  42663. */
  42664. readonly shaderCompilationTimeCounter: PerfCounter;
  42665. /**
  42666. * Gets the shader compilation time capture status
  42667. */
  42668. /**
  42669. * Enable or disable the shader compilation time capture
  42670. */
  42671. captureShaderCompilationTime: boolean;
  42672. /**
  42673. * Instantiates a new engine instrumentation.
  42674. * This class can be used to get instrumentation data from a Babylon engine
  42675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42676. * @param engine Defines the engine to instrument
  42677. */
  42678. constructor(
  42679. /**
  42680. * Define the instrumented engine.
  42681. */
  42682. engine: Engine);
  42683. /**
  42684. * Dispose and release associated resources.
  42685. */
  42686. dispose(): void;
  42687. }
  42688. }
  42689. declare module BABYLON {
  42690. /**
  42691. * This class can be used to get instrumentation data from a Babylon engine
  42692. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  42693. */
  42694. export class SceneInstrumentation implements IDisposable {
  42695. /**
  42696. * Defines the scene to instrument
  42697. */
  42698. scene: Scene;
  42699. private _captureActiveMeshesEvaluationTime;
  42700. private _activeMeshesEvaluationTime;
  42701. private _captureRenderTargetsRenderTime;
  42702. private _renderTargetsRenderTime;
  42703. private _captureFrameTime;
  42704. private _frameTime;
  42705. private _captureRenderTime;
  42706. private _renderTime;
  42707. private _captureInterFrameTime;
  42708. private _interFrameTime;
  42709. private _captureParticlesRenderTime;
  42710. private _particlesRenderTime;
  42711. private _captureSpritesRenderTime;
  42712. private _spritesRenderTime;
  42713. private _capturePhysicsTime;
  42714. private _physicsTime;
  42715. private _captureAnimationsTime;
  42716. private _animationsTime;
  42717. private _captureCameraRenderTime;
  42718. private _cameraRenderTime;
  42719. private _onBeforeActiveMeshesEvaluationObserver;
  42720. private _onAfterActiveMeshesEvaluationObserver;
  42721. private _onBeforeRenderTargetsRenderObserver;
  42722. private _onAfterRenderTargetsRenderObserver;
  42723. private _onAfterRenderObserver;
  42724. private _onBeforeDrawPhaseObserver;
  42725. private _onAfterDrawPhaseObserver;
  42726. private _onBeforeAnimationsObserver;
  42727. private _onBeforeParticlesRenderingObserver;
  42728. private _onAfterParticlesRenderingObserver;
  42729. private _onBeforeSpritesRenderingObserver;
  42730. private _onAfterSpritesRenderingObserver;
  42731. private _onBeforePhysicsObserver;
  42732. private _onAfterPhysicsObserver;
  42733. private _onAfterAnimationsObserver;
  42734. private _onBeforeCameraRenderObserver;
  42735. private _onAfterCameraRenderObserver;
  42736. /**
  42737. * Gets the perf counter used for active meshes evaluation time
  42738. */
  42739. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  42740. /**
  42741. * Gets the active meshes evaluation time capture status
  42742. */
  42743. /**
  42744. * Enable or disable the active meshes evaluation time capture
  42745. */
  42746. captureActiveMeshesEvaluationTime: boolean;
  42747. /**
  42748. * Gets the perf counter used for render targets render time
  42749. */
  42750. readonly renderTargetsRenderTimeCounter: PerfCounter;
  42751. /**
  42752. * Gets the render targets render time capture status
  42753. */
  42754. /**
  42755. * Enable or disable the render targets render time capture
  42756. */
  42757. captureRenderTargetsRenderTime: boolean;
  42758. /**
  42759. * Gets the perf counter used for particles render time
  42760. */
  42761. readonly particlesRenderTimeCounter: PerfCounter;
  42762. /**
  42763. * Gets the particles render time capture status
  42764. */
  42765. /**
  42766. * Enable or disable the particles render time capture
  42767. */
  42768. captureParticlesRenderTime: boolean;
  42769. /**
  42770. * Gets the perf counter used for sprites render time
  42771. */
  42772. readonly spritesRenderTimeCounter: PerfCounter;
  42773. /**
  42774. * Gets the sprites render time capture status
  42775. */
  42776. /**
  42777. * Enable or disable the sprites render time capture
  42778. */
  42779. captureSpritesRenderTime: boolean;
  42780. /**
  42781. * Gets the perf counter used for physics time
  42782. */
  42783. readonly physicsTimeCounter: PerfCounter;
  42784. /**
  42785. * Gets the physics time capture status
  42786. */
  42787. /**
  42788. * Enable or disable the physics time capture
  42789. */
  42790. capturePhysicsTime: boolean;
  42791. /**
  42792. * Gets the perf counter used for animations time
  42793. */
  42794. readonly animationsTimeCounter: PerfCounter;
  42795. /**
  42796. * Gets the animations time capture status
  42797. */
  42798. /**
  42799. * Enable or disable the animations time capture
  42800. */
  42801. captureAnimationsTime: boolean;
  42802. /**
  42803. * Gets the perf counter used for frame time capture
  42804. */
  42805. readonly frameTimeCounter: PerfCounter;
  42806. /**
  42807. * Gets the frame time capture status
  42808. */
  42809. /**
  42810. * Enable or disable the frame time capture
  42811. */
  42812. captureFrameTime: boolean;
  42813. /**
  42814. * Gets the perf counter used for inter-frames time capture
  42815. */
  42816. readonly interFrameTimeCounter: PerfCounter;
  42817. /**
  42818. * Gets the inter-frames time capture status
  42819. */
  42820. /**
  42821. * Enable or disable the inter-frames time capture
  42822. */
  42823. captureInterFrameTime: boolean;
  42824. /**
  42825. * Gets the perf counter used for render time capture
  42826. */
  42827. readonly renderTimeCounter: PerfCounter;
  42828. /**
  42829. * Gets the render time capture status
  42830. */
  42831. /**
  42832. * Enable or disable the render time capture
  42833. */
  42834. captureRenderTime: boolean;
  42835. /**
  42836. * Gets the perf counter used for camera render time capture
  42837. */
  42838. readonly cameraRenderTimeCounter: PerfCounter;
  42839. /**
  42840. * Gets the camera render time capture status
  42841. */
  42842. /**
  42843. * Enable or disable the camera render time capture
  42844. */
  42845. captureCameraRenderTime: boolean;
  42846. /**
  42847. * Gets the perf counter used for draw calls
  42848. */
  42849. readonly drawCallsCounter: PerfCounter;
  42850. /**
  42851. * Gets the perf counter used for texture collisions
  42852. */
  42853. readonly textureCollisionsCounter: PerfCounter;
  42854. /**
  42855. * Instantiates a new scene instrumentation.
  42856. * This class can be used to get instrumentation data from a Babylon engine
  42857. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  42858. * @param scene Defines the scene to instrument
  42859. */
  42860. constructor(
  42861. /**
  42862. * Defines the scene to instrument
  42863. */
  42864. scene: Scene);
  42865. /**
  42866. * Dispose and release associated resources.
  42867. */
  42868. dispose(): void;
  42869. }
  42870. }
  42871. declare module BABYLON {
  42872. /** @hidden */
  42873. export var glowMapGenerationPixelShader: {
  42874. name: string;
  42875. shader: string;
  42876. };
  42877. }
  42878. declare module BABYLON {
  42879. /** @hidden */
  42880. export var glowMapGenerationVertexShader: {
  42881. name: string;
  42882. shader: string;
  42883. };
  42884. }
  42885. declare module BABYLON {
  42886. /**
  42887. * Effect layer options. This helps customizing the behaviour
  42888. * of the effect layer.
  42889. */
  42890. export interface IEffectLayerOptions {
  42891. /**
  42892. * Multiplication factor apply to the canvas size to compute the render target size
  42893. * used to generated the objects (the smaller the faster).
  42894. */
  42895. mainTextureRatio: number;
  42896. /**
  42897. * Enforces a fixed size texture to ensure effect stability across devices.
  42898. */
  42899. mainTextureFixedSize?: number;
  42900. /**
  42901. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  42902. */
  42903. alphaBlendingMode: number;
  42904. /**
  42905. * The camera attached to the layer.
  42906. */
  42907. camera: Nullable<Camera>;
  42908. /**
  42909. * The rendering group to draw the layer in.
  42910. */
  42911. renderingGroupId: number;
  42912. }
  42913. /**
  42914. * The effect layer Helps adding post process effect blended with the main pass.
  42915. *
  42916. * This can be for instance use to generate glow or higlight effects on the scene.
  42917. *
  42918. * The effect layer class can not be used directly and is intented to inherited from to be
  42919. * customized per effects.
  42920. */
  42921. export abstract class EffectLayer {
  42922. private _vertexBuffers;
  42923. private _indexBuffer;
  42924. private _cachedDefines;
  42925. private _effectLayerMapGenerationEffect;
  42926. private _effectLayerOptions;
  42927. private _mergeEffect;
  42928. protected _scene: Scene;
  42929. protected _engine: Engine;
  42930. protected _maxSize: number;
  42931. protected _mainTextureDesiredSize: ISize;
  42932. protected _mainTexture: RenderTargetTexture;
  42933. protected _shouldRender: boolean;
  42934. protected _postProcesses: PostProcess[];
  42935. protected _textures: BaseTexture[];
  42936. protected _emissiveTextureAndColor: {
  42937. texture: Nullable<BaseTexture>;
  42938. color: Color4;
  42939. };
  42940. /**
  42941. * The name of the layer
  42942. */
  42943. name: string;
  42944. /**
  42945. * The clear color of the texture used to generate the glow map.
  42946. */
  42947. neutralColor: Color4;
  42948. /**
  42949. * Specifies wether the highlight layer is enabled or not.
  42950. */
  42951. isEnabled: boolean;
  42952. /**
  42953. * Gets the camera attached to the layer.
  42954. */
  42955. readonly camera: Nullable<Camera>;
  42956. /**
  42957. * Gets the rendering group id the layer should render in.
  42958. */
  42959. readonly renderingGroupId: number;
  42960. /**
  42961. * An event triggered when the effect layer has been disposed.
  42962. */
  42963. onDisposeObservable: Observable<EffectLayer>;
  42964. /**
  42965. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  42966. */
  42967. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  42968. /**
  42969. * An event triggered when the generated texture is being merged in the scene.
  42970. */
  42971. onBeforeComposeObservable: Observable<EffectLayer>;
  42972. /**
  42973. * An event triggered when the generated texture has been merged in the scene.
  42974. */
  42975. onAfterComposeObservable: Observable<EffectLayer>;
  42976. /**
  42977. * An event triggered when the efffect layer changes its size.
  42978. */
  42979. onSizeChangedObservable: Observable<EffectLayer>;
  42980. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  42981. /**
  42982. * Instantiates a new effect Layer and references it in the scene.
  42983. * @param name The name of the layer
  42984. * @param scene The scene to use the layer in
  42985. */
  42986. constructor(
  42987. /** The Friendly of the effect in the scene */
  42988. name: string, scene: Scene);
  42989. /**
  42990. * Get the effect name of the layer.
  42991. * @return The effect name
  42992. */
  42993. abstract getEffectName(): string;
  42994. /**
  42995. * Checks for the readiness of the element composing the layer.
  42996. * @param subMesh the mesh to check for
  42997. * @param useInstances specify wether or not to use instances to render the mesh
  42998. * @return true if ready otherwise, false
  42999. */
  43000. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43001. /**
  43002. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43003. * @returns true if the effect requires stencil during the main canvas render pass.
  43004. */
  43005. abstract needStencil(): boolean;
  43006. /**
  43007. * Create the merge effect. This is the shader use to blit the information back
  43008. * to the main canvas at the end of the scene rendering.
  43009. * @returns The effect containing the shader used to merge the effect on the main canvas
  43010. */
  43011. protected abstract _createMergeEffect(): Effect;
  43012. /**
  43013. * Creates the render target textures and post processes used in the effect layer.
  43014. */
  43015. protected abstract _createTextureAndPostProcesses(): void;
  43016. /**
  43017. * Implementation specific of rendering the generating effect on the main canvas.
  43018. * @param effect The effect used to render through
  43019. */
  43020. protected abstract _internalRender(effect: Effect): void;
  43021. /**
  43022. * Sets the required values for both the emissive texture and and the main color.
  43023. */
  43024. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  43025. /**
  43026. * Free any resources and references associated to a mesh.
  43027. * Internal use
  43028. * @param mesh The mesh to free.
  43029. */
  43030. abstract _disposeMesh(mesh: Mesh): void;
  43031. /**
  43032. * Serializes this layer (Glow or Highlight for example)
  43033. * @returns a serialized layer object
  43034. */
  43035. abstract serialize?(): any;
  43036. /**
  43037. * Initializes the effect layer with the required options.
  43038. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  43039. */
  43040. protected _init(options: Partial<IEffectLayerOptions>): void;
  43041. /**
  43042. * Generates the index buffer of the full screen quad blending to the main canvas.
  43043. */
  43044. private _generateIndexBuffer;
  43045. /**
  43046. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  43047. */
  43048. private _genrateVertexBuffer;
  43049. /**
  43050. * Sets the main texture desired size which is the closest power of two
  43051. * of the engine canvas size.
  43052. */
  43053. private _setMainTextureSize;
  43054. /**
  43055. * Creates the main texture for the effect layer.
  43056. */
  43057. protected _createMainTexture(): void;
  43058. /**
  43059. * Adds specific effects defines.
  43060. * @param defines The defines to add specifics to.
  43061. */
  43062. protected _addCustomEffectDefines(defines: string[]): void;
  43063. /**
  43064. * Checks for the readiness of the element composing the layer.
  43065. * @param subMesh the mesh to check for
  43066. * @param useInstances specify wether or not to use instances to render the mesh
  43067. * @param emissiveTexture the associated emissive texture used to generate the glow
  43068. * @return true if ready otherwise, false
  43069. */
  43070. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  43071. /**
  43072. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  43073. */
  43074. render(): void;
  43075. /**
  43076. * Determine if a given mesh will be used in the current effect.
  43077. * @param mesh mesh to test
  43078. * @returns true if the mesh will be used
  43079. */
  43080. hasMesh(mesh: AbstractMesh): boolean;
  43081. /**
  43082. * Returns true if the layer contains information to display, otherwise false.
  43083. * @returns true if the glow layer should be rendered
  43084. */
  43085. shouldRender(): boolean;
  43086. /**
  43087. * Returns true if the mesh should render, otherwise false.
  43088. * @param mesh The mesh to render
  43089. * @returns true if it should render otherwise false
  43090. */
  43091. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  43092. /**
  43093. * Returns true if the mesh can be rendered, otherwise false.
  43094. * @param mesh The mesh to render
  43095. * @param material The material used on the mesh
  43096. * @returns true if it can be rendered otherwise false
  43097. */
  43098. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  43099. /**
  43100. * Returns true if the mesh should render, otherwise false.
  43101. * @param mesh The mesh to render
  43102. * @returns true if it should render otherwise false
  43103. */
  43104. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  43105. /**
  43106. * Renders the submesh passed in parameter to the generation map.
  43107. */
  43108. protected _renderSubMesh(subMesh: SubMesh): void;
  43109. /**
  43110. * Rebuild the required buffers.
  43111. * @hidden Internal use only.
  43112. */ rebuild(): void;
  43113. /**
  43114. * Dispose only the render target textures and post process.
  43115. */
  43116. private _disposeTextureAndPostProcesses;
  43117. /**
  43118. * Dispose the highlight layer and free resources.
  43119. */
  43120. dispose(): void;
  43121. /**
  43122. * Gets the class name of the effect layer
  43123. * @returns the string with the class name of the effect layer
  43124. */
  43125. getClassName(): string;
  43126. /**
  43127. * Creates an effect layer from parsed effect layer data
  43128. * @param parsedEffectLayer defines effect layer data
  43129. * @param scene defines the current scene
  43130. * @param rootUrl defines the root URL containing the effect layer information
  43131. * @returns a parsed effect Layer
  43132. */
  43133. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  43134. }
  43135. }
  43136. declare module BABYLON {
  43137. interface AbstractScene {
  43138. /**
  43139. * The list of effect layers (highlights/glow) added to the scene
  43140. * @see http://doc.babylonjs.com/how_to/highlight_layer
  43141. * @see http://doc.babylonjs.com/how_to/glow_layer
  43142. */
  43143. effectLayers: Array<EffectLayer>;
  43144. /**
  43145. * Removes the given effect layer from this scene.
  43146. * @param toRemove defines the effect layer to remove
  43147. * @returns the index of the removed effect layer
  43148. */
  43149. removeEffectLayer(toRemove: EffectLayer): number;
  43150. /**
  43151. * Adds the given effect layer to this scene
  43152. * @param newEffectLayer defines the effect layer to add
  43153. */
  43154. addEffectLayer(newEffectLayer: EffectLayer): void;
  43155. }
  43156. /**
  43157. * Defines the layer scene component responsible to manage any effect layers
  43158. * in a given scene.
  43159. */
  43160. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  43161. /**
  43162. * The component name helpfull to identify the component in the list of scene components.
  43163. */
  43164. readonly name: string;
  43165. /**
  43166. * The scene the component belongs to.
  43167. */
  43168. scene: Scene;
  43169. private _engine;
  43170. private _renderEffects;
  43171. private _needStencil;
  43172. private _previousStencilState;
  43173. /**
  43174. * Creates a new instance of the component for the given scene
  43175. * @param scene Defines the scene to register the component in
  43176. */
  43177. constructor(scene: Scene);
  43178. /**
  43179. * Registers the component in a given scene
  43180. */
  43181. register(): void;
  43182. /**
  43183. * Rebuilds the elements related to this component in case of
  43184. * context lost for instance.
  43185. */
  43186. rebuild(): void;
  43187. /**
  43188. * Serializes the component data to the specified json object
  43189. * @param serializationObject The object to serialize to
  43190. */
  43191. serialize(serializationObject: any): void;
  43192. /**
  43193. * Adds all the element from the container to the scene
  43194. * @param container the container holding the elements
  43195. */
  43196. addFromContainer(container: AbstractScene): void;
  43197. /**
  43198. * Removes all the elements in the container from the scene
  43199. * @param container contains the elements to remove
  43200. */
  43201. removeFromContainer(container: AbstractScene): void;
  43202. /**
  43203. * Disposes the component and the associated ressources.
  43204. */
  43205. dispose(): void;
  43206. private _isReadyForMesh;
  43207. private _renderMainTexture;
  43208. private _setStencil;
  43209. private _setStencilBack;
  43210. private _draw;
  43211. private _drawCamera;
  43212. private _drawRenderingGroup;
  43213. }
  43214. }
  43215. declare module BABYLON {
  43216. /** @hidden */
  43217. export var glowMapMergePixelShader: {
  43218. name: string;
  43219. shader: string;
  43220. };
  43221. }
  43222. declare module BABYLON {
  43223. /** @hidden */
  43224. export var glowMapMergeVertexShader: {
  43225. name: string;
  43226. shader: string;
  43227. };
  43228. }
  43229. declare module BABYLON {
  43230. interface AbstractScene {
  43231. /**
  43232. * Return a the first highlight layer of the scene with a given name.
  43233. * @param name The name of the highlight layer to look for.
  43234. * @return The highlight layer if found otherwise null.
  43235. */
  43236. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  43237. }
  43238. /**
  43239. * Glow layer options. This helps customizing the behaviour
  43240. * of the glow layer.
  43241. */
  43242. export interface IGlowLayerOptions {
  43243. /**
  43244. * Multiplication factor apply to the canvas size to compute the render target size
  43245. * used to generated the glowing objects (the smaller the faster).
  43246. */
  43247. mainTextureRatio: number;
  43248. /**
  43249. * Enforces a fixed size texture to ensure resize independant blur.
  43250. */
  43251. mainTextureFixedSize?: number;
  43252. /**
  43253. * How big is the kernel of the blur texture.
  43254. */
  43255. blurKernelSize: number;
  43256. /**
  43257. * The camera attached to the layer.
  43258. */
  43259. camera: Nullable<Camera>;
  43260. /**
  43261. * Enable MSAA by chosing the number of samples.
  43262. */
  43263. mainTextureSamples?: number;
  43264. /**
  43265. * The rendering group to draw the layer in.
  43266. */
  43267. renderingGroupId: number;
  43268. }
  43269. /**
  43270. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  43271. *
  43272. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43273. * glowy meshes to your scene.
  43274. *
  43275. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  43276. */
  43277. export class GlowLayer extends EffectLayer {
  43278. /**
  43279. * Effect Name of the layer.
  43280. */
  43281. static readonly EffectName: string;
  43282. /**
  43283. * The default blur kernel size used for the glow.
  43284. */
  43285. static DefaultBlurKernelSize: number;
  43286. /**
  43287. * The default texture size ratio used for the glow.
  43288. */
  43289. static DefaultTextureRatio: number;
  43290. /**
  43291. * Sets the kernel size of the blur.
  43292. */
  43293. /**
  43294. * Gets the kernel size of the blur.
  43295. */
  43296. blurKernelSize: number;
  43297. /**
  43298. * Sets the glow intensity.
  43299. */
  43300. /**
  43301. * Gets the glow intensity.
  43302. */
  43303. intensity: number;
  43304. private _options;
  43305. private _intensity;
  43306. private _horizontalBlurPostprocess1;
  43307. private _verticalBlurPostprocess1;
  43308. private _horizontalBlurPostprocess2;
  43309. private _verticalBlurPostprocess2;
  43310. private _blurTexture1;
  43311. private _blurTexture2;
  43312. private _postProcesses1;
  43313. private _postProcesses2;
  43314. private _includedOnlyMeshes;
  43315. private _excludedMeshes;
  43316. /**
  43317. * Callback used to let the user override the color selection on a per mesh basis
  43318. */
  43319. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  43320. /**
  43321. * Callback used to let the user override the texture selection on a per mesh basis
  43322. */
  43323. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  43324. /**
  43325. * Instantiates a new glow Layer and references it to the scene.
  43326. * @param name The name of the layer
  43327. * @param scene The scene to use the layer in
  43328. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  43329. */
  43330. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  43331. /**
  43332. * Get the effect name of the layer.
  43333. * @return The effect name
  43334. */
  43335. getEffectName(): string;
  43336. /**
  43337. * Create the merge effect. This is the shader use to blit the information back
  43338. * to the main canvas at the end of the scene rendering.
  43339. */
  43340. protected _createMergeEffect(): Effect;
  43341. /**
  43342. * Creates the render target textures and post processes used in the glow layer.
  43343. */
  43344. protected _createTextureAndPostProcesses(): void;
  43345. /**
  43346. * Checks for the readiness of the element composing the layer.
  43347. * @param subMesh the mesh to check for
  43348. * @param useInstances specify wether or not to use instances to render the mesh
  43349. * @param emissiveTexture the associated emissive texture used to generate the glow
  43350. * @return true if ready otherwise, false
  43351. */
  43352. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43353. /**
  43354. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43355. */
  43356. needStencil(): boolean;
  43357. /**
  43358. * Returns true if the mesh can be rendered, otherwise false.
  43359. * @param mesh The mesh to render
  43360. * @param material The material used on the mesh
  43361. * @returns true if it can be rendered otherwise false
  43362. */
  43363. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  43364. /**
  43365. * Implementation specific of rendering the generating effect on the main canvas.
  43366. * @param effect The effect used to render through
  43367. */
  43368. protected _internalRender(effect: Effect): void;
  43369. /**
  43370. * Sets the required values for both the emissive texture and and the main color.
  43371. */
  43372. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  43373. /**
  43374. * Returns true if the mesh should render, otherwise false.
  43375. * @param mesh The mesh to render
  43376. * @returns true if it should render otherwise false
  43377. */
  43378. protected _shouldRenderMesh(mesh: Mesh): boolean;
  43379. /**
  43380. * Adds specific effects defines.
  43381. * @param defines The defines to add specifics to.
  43382. */
  43383. protected _addCustomEffectDefines(defines: string[]): void;
  43384. /**
  43385. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  43386. * @param mesh The mesh to exclude from the glow layer
  43387. */
  43388. addExcludedMesh(mesh: Mesh): void;
  43389. /**
  43390. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  43391. * @param mesh The mesh to remove
  43392. */
  43393. removeExcludedMesh(mesh: Mesh): void;
  43394. /**
  43395. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  43396. * @param mesh The mesh to include in the glow layer
  43397. */
  43398. addIncludedOnlyMesh(mesh: Mesh): void;
  43399. /**
  43400. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  43401. * @param mesh The mesh to remove
  43402. */
  43403. removeIncludedOnlyMesh(mesh: Mesh): void;
  43404. /**
  43405. * Determine if a given mesh will be used in the glow layer
  43406. * @param mesh The mesh to test
  43407. * @returns true if the mesh will be highlighted by the current glow layer
  43408. */
  43409. hasMesh(mesh: AbstractMesh): boolean;
  43410. /**
  43411. * Free any resources and references associated to a mesh.
  43412. * Internal use
  43413. * @param mesh The mesh to free.
  43414. * @hidden
  43415. */ disposeMesh(mesh: Mesh): void;
  43416. /**
  43417. * Gets the class name of the effect layer
  43418. * @returns the string with the class name of the effect layer
  43419. */
  43420. getClassName(): string;
  43421. /**
  43422. * Serializes this glow layer
  43423. * @returns a serialized glow layer object
  43424. */
  43425. serialize(): any;
  43426. /**
  43427. * Creates a Glow Layer from parsed glow layer data
  43428. * @param parsedGlowLayer defines glow layer data
  43429. * @param scene defines the current scene
  43430. * @param rootUrl defines the root URL containing the glow layer information
  43431. * @returns a parsed Glow Layer
  43432. */
  43433. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  43434. }
  43435. }
  43436. declare module BABYLON {
  43437. /** @hidden */
  43438. export var glowBlurPostProcessPixelShader: {
  43439. name: string;
  43440. shader: string;
  43441. };
  43442. }
  43443. declare module BABYLON {
  43444. interface AbstractScene {
  43445. /**
  43446. * Return a the first highlight layer of the scene with a given name.
  43447. * @param name The name of the highlight layer to look for.
  43448. * @return The highlight layer if found otherwise null.
  43449. */
  43450. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  43451. }
  43452. /**
  43453. * Highlight layer options. This helps customizing the behaviour
  43454. * of the highlight layer.
  43455. */
  43456. export interface IHighlightLayerOptions {
  43457. /**
  43458. * Multiplication factor apply to the canvas size to compute the render target size
  43459. * used to generated the glowing objects (the smaller the faster).
  43460. */
  43461. mainTextureRatio: number;
  43462. /**
  43463. * Enforces a fixed size texture to ensure resize independant blur.
  43464. */
  43465. mainTextureFixedSize?: number;
  43466. /**
  43467. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  43468. * of the picture to blur (the smaller the faster).
  43469. */
  43470. blurTextureSizeRatio: number;
  43471. /**
  43472. * How big in texel of the blur texture is the vertical blur.
  43473. */
  43474. blurVerticalSize: number;
  43475. /**
  43476. * How big in texel of the blur texture is the horizontal blur.
  43477. */
  43478. blurHorizontalSize: number;
  43479. /**
  43480. * Alpha blending mode used to apply the blur. Default is combine.
  43481. */
  43482. alphaBlendingMode: number;
  43483. /**
  43484. * The camera attached to the layer.
  43485. */
  43486. camera: Nullable<Camera>;
  43487. /**
  43488. * Should we display highlight as a solid stroke?
  43489. */
  43490. isStroke?: boolean;
  43491. /**
  43492. * The rendering group to draw the layer in.
  43493. */
  43494. renderingGroupId: number;
  43495. }
  43496. /**
  43497. * The highlight layer Helps adding a glow effect around a mesh.
  43498. *
  43499. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43500. * glowy meshes to your scene.
  43501. *
  43502. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  43503. */
  43504. export class HighlightLayer extends EffectLayer {
  43505. name: string;
  43506. /**
  43507. * Effect Name of the highlight layer.
  43508. */
  43509. static readonly EffectName: string;
  43510. /**
  43511. * The neutral color used during the preparation of the glow effect.
  43512. * This is black by default as the blend operation is a blend operation.
  43513. */
  43514. static NeutralColor: Color4;
  43515. /**
  43516. * Stencil value used for glowing meshes.
  43517. */
  43518. static GlowingMeshStencilReference: number;
  43519. /**
  43520. * Stencil value used for the other meshes in the scene.
  43521. */
  43522. static NormalMeshStencilReference: number;
  43523. /**
  43524. * Specifies whether or not the inner glow is ACTIVE in the layer.
  43525. */
  43526. innerGlow: boolean;
  43527. /**
  43528. * Specifies whether or not the outer glow is ACTIVE in the layer.
  43529. */
  43530. outerGlow: boolean;
  43531. /**
  43532. * Specifies the horizontal size of the blur.
  43533. */
  43534. /**
  43535. * Gets the horizontal size of the blur.
  43536. */
  43537. blurHorizontalSize: number;
  43538. /**
  43539. * Specifies the vertical size of the blur.
  43540. */
  43541. /**
  43542. * Gets the vertical size of the blur.
  43543. */
  43544. blurVerticalSize: number;
  43545. /**
  43546. * An event triggered when the highlight layer is being blurred.
  43547. */
  43548. onBeforeBlurObservable: Observable<HighlightLayer>;
  43549. /**
  43550. * An event triggered when the highlight layer has been blurred.
  43551. */
  43552. onAfterBlurObservable: Observable<HighlightLayer>;
  43553. private _instanceGlowingMeshStencilReference;
  43554. private _options;
  43555. private _downSamplePostprocess;
  43556. private _horizontalBlurPostprocess;
  43557. private _verticalBlurPostprocess;
  43558. private _blurTexture;
  43559. private _meshes;
  43560. private _excludedMeshes;
  43561. /**
  43562. * Instantiates a new highlight Layer and references it to the scene..
  43563. * @param name The name of the layer
  43564. * @param scene The scene to use the layer in
  43565. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  43566. */
  43567. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  43568. /**
  43569. * Get the effect name of the layer.
  43570. * @return The effect name
  43571. */
  43572. getEffectName(): string;
  43573. /**
  43574. * Create the merge effect. This is the shader use to blit the information back
  43575. * to the main canvas at the end of the scene rendering.
  43576. */
  43577. protected _createMergeEffect(): Effect;
  43578. /**
  43579. * Creates the render target textures and post processes used in the highlight layer.
  43580. */
  43581. protected _createTextureAndPostProcesses(): void;
  43582. /**
  43583. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43584. */
  43585. needStencil(): boolean;
  43586. /**
  43587. * Checks for the readiness of the element composing the layer.
  43588. * @param subMesh the mesh to check for
  43589. * @param useInstances specify wether or not to use instances to render the mesh
  43590. * @param emissiveTexture the associated emissive texture used to generate the glow
  43591. * @return true if ready otherwise, false
  43592. */
  43593. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43594. /**
  43595. * Implementation specific of rendering the generating effect on the main canvas.
  43596. * @param effect The effect used to render through
  43597. */
  43598. protected _internalRender(effect: Effect): void;
  43599. /**
  43600. * Returns true if the layer contains information to display, otherwise false.
  43601. */
  43602. shouldRender(): boolean;
  43603. /**
  43604. * Returns true if the mesh should render, otherwise false.
  43605. * @param mesh The mesh to render
  43606. * @returns true if it should render otherwise false
  43607. */
  43608. protected _shouldRenderMesh(mesh: Mesh): boolean;
  43609. /**
  43610. * Sets the required values for both the emissive texture and and the main color.
  43611. */
  43612. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  43613. /**
  43614. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  43615. * @param mesh The mesh to exclude from the highlight layer
  43616. */
  43617. addExcludedMesh(mesh: Mesh): void;
  43618. /**
  43619. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  43620. * @param mesh The mesh to highlight
  43621. */
  43622. removeExcludedMesh(mesh: Mesh): void;
  43623. /**
  43624. * Determine if a given mesh will be highlighted by the current HighlightLayer
  43625. * @param mesh mesh to test
  43626. * @returns true if the mesh will be highlighted by the current HighlightLayer
  43627. */
  43628. hasMesh(mesh: AbstractMesh): boolean;
  43629. /**
  43630. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  43631. * @param mesh The mesh to highlight
  43632. * @param color The color of the highlight
  43633. * @param glowEmissiveOnly Extract the glow from the emissive texture
  43634. */
  43635. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  43636. /**
  43637. * Remove a mesh from the highlight layer in order to make it stop glowing.
  43638. * @param mesh The mesh to highlight
  43639. */
  43640. removeMesh(mesh: Mesh): void;
  43641. /**
  43642. * Force the stencil to the normal expected value for none glowing parts
  43643. */
  43644. private _defaultStencilReference;
  43645. /**
  43646. * Free any resources and references associated to a mesh.
  43647. * Internal use
  43648. * @param mesh The mesh to free.
  43649. * @hidden
  43650. */ disposeMesh(mesh: Mesh): void;
  43651. /**
  43652. * Dispose the highlight layer and free resources.
  43653. */
  43654. dispose(): void;
  43655. /**
  43656. * Gets the class name of the effect layer
  43657. * @returns the string with the class name of the effect layer
  43658. */
  43659. getClassName(): string;
  43660. /**
  43661. * Serializes this Highlight layer
  43662. * @returns a serialized Highlight layer object
  43663. */
  43664. serialize(): any;
  43665. /**
  43666. * Creates a Highlight layer from parsed Highlight layer data
  43667. * @param parsedHightlightLayer defines the Highlight layer data
  43668. * @param scene defines the current scene
  43669. * @param rootUrl defines the root URL containing the Highlight layer information
  43670. * @returns a parsed Highlight layer
  43671. */
  43672. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  43673. }
  43674. }
  43675. declare module BABYLON {
  43676. /** @hidden */
  43677. export var lensFlarePixelShader: {
  43678. name: string;
  43679. shader: string;
  43680. };
  43681. }
  43682. declare module BABYLON {
  43683. /** @hidden */
  43684. export var lensFlareVertexShader: {
  43685. name: string;
  43686. shader: string;
  43687. };
  43688. }
  43689. declare module BABYLON {
  43690. /**
  43691. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43692. * It is usually composed of several `lensFlare`.
  43693. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43694. */
  43695. export class LensFlareSystem {
  43696. /**
  43697. * Define the name of the lens flare system
  43698. */
  43699. name: string;
  43700. /**
  43701. * List of lens flares used in this system.
  43702. */
  43703. lensFlares: LensFlare[];
  43704. /**
  43705. * Define a limit from the border the lens flare can be visible.
  43706. */
  43707. borderLimit: number;
  43708. /**
  43709. * Define a viewport border we do not want to see the lens flare in.
  43710. */
  43711. viewportBorder: number;
  43712. /**
  43713. * Define a predicate which could limit the list of meshes able to occlude the effect.
  43714. */
  43715. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43716. /**
  43717. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  43718. */
  43719. layerMask: number;
  43720. /**
  43721. * Define the id of the lens flare system in the scene.
  43722. * (equal to name by default)
  43723. */
  43724. id: string;
  43725. private _scene;
  43726. private _emitter;
  43727. private _vertexBuffers;
  43728. private _indexBuffer;
  43729. private _effect;
  43730. private _positionX;
  43731. private _positionY;
  43732. private _isEnabled;
  43733. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  43734. /**
  43735. * Instantiates a lens flare system.
  43736. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43737. * It is usually composed of several `lensFlare`.
  43738. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43739. * @param name Define the name of the lens flare system in the scene
  43740. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  43741. * @param scene Define the scene the lens flare system belongs to
  43742. */
  43743. constructor(
  43744. /**
  43745. * Define the name of the lens flare system
  43746. */
  43747. name: string, emitter: any, scene: Scene);
  43748. /**
  43749. * Define if the lens flare system is enabled.
  43750. */
  43751. isEnabled: boolean;
  43752. /**
  43753. * Get the scene the effects belongs to.
  43754. * @returns the scene holding the lens flare system
  43755. */
  43756. getScene(): Scene;
  43757. /**
  43758. * Get the emitter of the lens flare system.
  43759. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43760. * @returns the emitter of the lens flare system
  43761. */
  43762. getEmitter(): any;
  43763. /**
  43764. * Set the emitter of the lens flare system.
  43765. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43766. * @param newEmitter Define the new emitter of the system
  43767. */
  43768. setEmitter(newEmitter: any): void;
  43769. /**
  43770. * Get the lens flare system emitter position.
  43771. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  43772. * @returns the position
  43773. */
  43774. getEmitterPosition(): Vector3;
  43775. /**
  43776. * @hidden
  43777. */
  43778. computeEffectivePosition(globalViewport: Viewport): boolean;
  43779. /** @hidden */ isVisible(): boolean;
  43780. /**
  43781. * @hidden
  43782. */
  43783. render(): boolean;
  43784. /**
  43785. * Dispose and release the lens flare with its associated resources.
  43786. */
  43787. dispose(): void;
  43788. /**
  43789. * Parse a lens flare system from a JSON repressentation
  43790. * @param parsedLensFlareSystem Define the JSON to parse
  43791. * @param scene Define the scene the parsed system should be instantiated in
  43792. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  43793. * @returns the parsed system
  43794. */
  43795. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  43796. /**
  43797. * Serialize the current Lens Flare System into a JSON representation.
  43798. * @returns the serialized JSON
  43799. */
  43800. serialize(): any;
  43801. }
  43802. }
  43803. declare module BABYLON {
  43804. /**
  43805. * This represents one of the lens effect in a `lensFlareSystem`.
  43806. * It controls one of the indiviual texture used in the effect.
  43807. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43808. */
  43809. export class LensFlare {
  43810. /**
  43811. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  43812. */
  43813. size: number;
  43814. /**
  43815. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  43816. */
  43817. position: number;
  43818. /**
  43819. * Define the lens color.
  43820. */
  43821. color: Color3;
  43822. /**
  43823. * Define the lens texture.
  43824. */
  43825. texture: Nullable<Texture>;
  43826. /**
  43827. * Define the alpha mode to render this particular lens.
  43828. */
  43829. alphaMode: number;
  43830. private _system;
  43831. /**
  43832. * Creates a new Lens Flare.
  43833. * This represents one of the lens effect in a `lensFlareSystem`.
  43834. * It controls one of the indiviual texture used in the effect.
  43835. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43836. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  43837. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  43838. * @param color Define the lens color
  43839. * @param imgUrl Define the lens texture url
  43840. * @param system Define the `lensFlareSystem` this flare is part of
  43841. * @returns The newly created Lens Flare
  43842. */
  43843. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  43844. /**
  43845. * Instantiates a new Lens Flare.
  43846. * This represents one of the lens effect in a `lensFlareSystem`.
  43847. * It controls one of the indiviual texture used in the effect.
  43848. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43849. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  43850. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  43851. * @param color Define the lens color
  43852. * @param imgUrl Define the lens texture url
  43853. * @param system Define the `lensFlareSystem` this flare is part of
  43854. */
  43855. constructor(
  43856. /**
  43857. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  43858. */
  43859. size: number,
  43860. /**
  43861. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  43862. */
  43863. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  43864. /**
  43865. * Dispose and release the lens flare with its associated resources.
  43866. */
  43867. dispose(): void;
  43868. }
  43869. }
  43870. declare module BABYLON {
  43871. interface AbstractScene {
  43872. /**
  43873. * The list of lens flare system added to the scene
  43874. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43875. */
  43876. lensFlareSystems: Array<LensFlareSystem>;
  43877. /**
  43878. * Removes the given lens flare system from this scene.
  43879. * @param toRemove The lens flare system to remove
  43880. * @returns The index of the removed lens flare system
  43881. */
  43882. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  43883. /**
  43884. * Adds the given lens flare system to this scene
  43885. * @param newLensFlareSystem The lens flare system to add
  43886. */
  43887. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  43888. /**
  43889. * Gets a lens flare system using its name
  43890. * @param name defines the name to look for
  43891. * @returns the lens flare system or null if not found
  43892. */
  43893. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  43894. /**
  43895. * Gets a lens flare system using its id
  43896. * @param id defines the id to look for
  43897. * @returns the lens flare system or null if not found
  43898. */
  43899. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  43900. }
  43901. /**
  43902. * Defines the lens flare scene component responsible to manage any lens flares
  43903. * in a given scene.
  43904. */
  43905. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  43906. /**
  43907. * The component name helpfull to identify the component in the list of scene components.
  43908. */
  43909. readonly name: string;
  43910. /**
  43911. * The scene the component belongs to.
  43912. */
  43913. scene: Scene;
  43914. /**
  43915. * Creates a new instance of the component for the given scene
  43916. * @param scene Defines the scene to register the component in
  43917. */
  43918. constructor(scene: Scene);
  43919. /**
  43920. * Registers the component in a given scene
  43921. */
  43922. register(): void;
  43923. /**
  43924. * Rebuilds the elements related to this component in case of
  43925. * context lost for instance.
  43926. */
  43927. rebuild(): void;
  43928. /**
  43929. * Adds all the element from the container to the scene
  43930. * @param container the container holding the elements
  43931. */
  43932. addFromContainer(container: AbstractScene): void;
  43933. /**
  43934. * Removes all the elements in the container from the scene
  43935. * @param container contains the elements to remove
  43936. */
  43937. removeFromContainer(container: AbstractScene): void;
  43938. /**
  43939. * Serializes the component data to the specified json object
  43940. * @param serializationObject The object to serialize to
  43941. */
  43942. serialize(serializationObject: any): void;
  43943. /**
  43944. * Disposes the component and the associated ressources.
  43945. */
  43946. dispose(): void;
  43947. private _draw;
  43948. }
  43949. }
  43950. declare module BABYLON {
  43951. /**
  43952. * Defines the shadow generator component responsible to manage any shadow generators
  43953. * in a given scene.
  43954. */
  43955. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  43956. /**
  43957. * The component name helpfull to identify the component in the list of scene components.
  43958. */
  43959. readonly name: string;
  43960. /**
  43961. * The scene the component belongs to.
  43962. */
  43963. scene: Scene;
  43964. /**
  43965. * Creates a new instance of the component for the given scene
  43966. * @param scene Defines the scene to register the component in
  43967. */
  43968. constructor(scene: Scene);
  43969. /**
  43970. * Registers the component in a given scene
  43971. */
  43972. register(): void;
  43973. /**
  43974. * Rebuilds the elements related to this component in case of
  43975. * context lost for instance.
  43976. */
  43977. rebuild(): void;
  43978. /**
  43979. * Serializes the component data to the specified json object
  43980. * @param serializationObject The object to serialize to
  43981. */
  43982. serialize(serializationObject: any): void;
  43983. /**
  43984. * Adds all the element from the container to the scene
  43985. * @param container the container holding the elements
  43986. */
  43987. addFromContainer(container: AbstractScene): void;
  43988. /**
  43989. * Removes all the elements in the container from the scene
  43990. * @param container contains the elements to remove
  43991. */
  43992. removeFromContainer(container: AbstractScene): void;
  43993. /**
  43994. * Rebuilds the elements related to this component in case of
  43995. * context lost for instance.
  43996. */
  43997. dispose(): void;
  43998. private _gatherRenderTargets;
  43999. }
  44000. }
  44001. declare module BABYLON {
  44002. /**
  44003. * A directional light is defined by a direction (what a surprise!).
  44004. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44005. * 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.
  44006. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44007. */
  44008. export class DirectionalLight extends ShadowLight {
  44009. private _shadowFrustumSize;
  44010. /**
  44011. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44012. */
  44013. /**
  44014. * Specifies a fix frustum size for the shadow generation.
  44015. */
  44016. shadowFrustumSize: number;
  44017. private _shadowOrthoScale;
  44018. /**
  44019. * Gets the shadow projection scale against the optimal computed one.
  44020. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44021. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44022. */
  44023. /**
  44024. * Sets the shadow projection scale against the optimal computed one.
  44025. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44026. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44027. */
  44028. shadowOrthoScale: number;
  44029. /**
  44030. * Automatically compute the projection matrix to best fit (including all the casters)
  44031. * on each frame.
  44032. */
  44033. autoUpdateExtends: boolean;
  44034. private _orthoLeft;
  44035. private _orthoRight;
  44036. private _orthoTop;
  44037. private _orthoBottom;
  44038. /**
  44039. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44040. * The directional light is emitted from everywhere in the given direction.
  44041. * It can cast shadows.
  44042. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44043. * @param name The friendly name of the light
  44044. * @param direction The direction of the light
  44045. * @param scene The scene the light belongs to
  44046. */
  44047. constructor(name: string, direction: Vector3, scene: Scene);
  44048. /**
  44049. * Returns the string "DirectionalLight".
  44050. * @return The class name
  44051. */
  44052. getClassName(): string;
  44053. /**
  44054. * Returns the integer 1.
  44055. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44056. */
  44057. getTypeID(): number;
  44058. /**
  44059. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44060. * Returns the DirectionalLight Shadow projection matrix.
  44061. */
  44062. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44063. /**
  44064. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44065. * Returns the DirectionalLight Shadow projection matrix.
  44066. */
  44067. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44068. /**
  44069. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44070. * Returns the DirectionalLight Shadow projection matrix.
  44071. */
  44072. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44073. protected _buildUniformLayout(): void;
  44074. /**
  44075. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44076. * @param effect The effect to update
  44077. * @param lightIndex The index of the light in the effect to update
  44078. * @returns The directional light
  44079. */
  44080. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44081. /**
  44082. * Gets the minZ used for shadow according to both the scene and the light.
  44083. *
  44084. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44085. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44086. * @param activeCamera The camera we are returning the min for
  44087. * @returns the depth min z
  44088. */
  44089. getDepthMinZ(activeCamera: Camera): number;
  44090. /**
  44091. * Gets the maxZ used for shadow according to both the scene and the light.
  44092. *
  44093. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44094. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44095. * @param activeCamera The camera we are returning the max for
  44096. * @returns the depth max z
  44097. */
  44098. getDepthMaxZ(activeCamera: Camera): number;
  44099. /**
  44100. * Prepares the list of defines specific to the light type.
  44101. * @param defines the list of defines
  44102. * @param lightIndex defines the index of the light for the effect
  44103. */
  44104. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44105. }
  44106. }
  44107. declare module BABYLON {
  44108. /**
  44109. * A point light is a light defined by an unique point in world space.
  44110. * The light is emitted in every direction from this point.
  44111. * A good example of a point light is a standard light bulb.
  44112. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44113. */
  44114. export class PointLight extends ShadowLight {
  44115. private _shadowAngle;
  44116. /**
  44117. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44118. * This specifies what angle the shadow will use to be created.
  44119. *
  44120. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  44121. */
  44122. /**
  44123. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44124. * This specifies what angle the shadow will use to be created.
  44125. *
  44126. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  44127. */
  44128. shadowAngle: number;
  44129. /**
  44130. * Gets the direction if it has been set.
  44131. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44132. */
  44133. /**
  44134. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44135. */
  44136. direction: Vector3;
  44137. /**
  44138. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  44139. * A PointLight emits the light in every direction.
  44140. * It can cast shadows.
  44141. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  44142. * ```javascript
  44143. * var pointLight = new PointLight("pl", camera.position, scene);
  44144. * ```
  44145. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44146. * @param name The light friendly name
  44147. * @param position The position of the point light in the scene
  44148. * @param scene The scene the lights belongs to
  44149. */
  44150. constructor(name: string, position: Vector3, scene: Scene);
  44151. /**
  44152. * Returns the string "PointLight"
  44153. * @returns the class name
  44154. */
  44155. getClassName(): string;
  44156. /**
  44157. * Returns the integer 0.
  44158. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44159. */
  44160. getTypeID(): number;
  44161. /**
  44162. * Specifies wether or not the shadowmap should be a cube texture.
  44163. * @returns true if the shadowmap needs to be a cube texture.
  44164. */
  44165. needCube(): boolean;
  44166. /**
  44167. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  44168. * @param faceIndex The index of the face we are computed the direction to generate shadow
  44169. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  44170. */
  44171. getShadowDirection(faceIndex?: number): Vector3;
  44172. /**
  44173. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  44174. * - fov = PI / 2
  44175. * - aspect ratio : 1.0
  44176. * - z-near and far equal to the active camera minZ and maxZ.
  44177. * Returns the PointLight.
  44178. */
  44179. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44180. protected _buildUniformLayout(): void;
  44181. /**
  44182. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  44183. * @param effect The effect to update
  44184. * @param lightIndex The index of the light in the effect to update
  44185. * @returns The point light
  44186. */
  44187. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  44188. /**
  44189. * Prepares the list of defines specific to the light type.
  44190. * @param defines the list of defines
  44191. * @param lightIndex defines the index of the light for the effect
  44192. */
  44193. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44194. }
  44195. }
  44196. declare module BABYLON {
  44197. /**
  44198. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44199. * These values define a cone of light starting from the position, emitting toward the direction.
  44200. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44201. * and the exponent defines the speed of the decay of the light with distance (reach).
  44202. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44203. */
  44204. export class SpotLight extends ShadowLight {
  44205. private _angle;
  44206. private _innerAngle;
  44207. private _cosHalfAngle;
  44208. private _lightAngleScale;
  44209. private _lightAngleOffset;
  44210. /**
  44211. * Gets the cone angle of the spot light in Radians.
  44212. */
  44213. /**
  44214. * Sets the cone angle of the spot light in Radians.
  44215. */
  44216. angle: number;
  44217. /**
  44218. * Only used in gltf falloff mode, this defines the angle where
  44219. * the directional falloff will start before cutting at angle which could be seen
  44220. * as outer angle.
  44221. */
  44222. /**
  44223. * Only used in gltf falloff mode, this defines the angle where
  44224. * the directional falloff will start before cutting at angle which could be seen
  44225. * as outer angle.
  44226. */
  44227. innerAngle: number;
  44228. private _shadowAngleScale;
  44229. /**
  44230. * Allows scaling the angle of the light for shadow generation only.
  44231. */
  44232. /**
  44233. * Allows scaling the angle of the light for shadow generation only.
  44234. */
  44235. shadowAngleScale: number;
  44236. /**
  44237. * The light decay speed with the distance from the emission spot.
  44238. */
  44239. exponent: number;
  44240. private _projectionTextureMatrix;
  44241. /**
  44242. * Allows reading the projecton texture
  44243. */
  44244. readonly projectionTextureMatrix: Matrix;
  44245. protected _projectionTextureLightNear: number;
  44246. /**
  44247. * Gets the near clip of the Spotlight for texture projection.
  44248. */
  44249. /**
  44250. * Sets the near clip of the Spotlight for texture projection.
  44251. */
  44252. projectionTextureLightNear: number;
  44253. protected _projectionTextureLightFar: number;
  44254. /**
  44255. * Gets the far clip of the Spotlight for texture projection.
  44256. */
  44257. /**
  44258. * Sets the far clip of the Spotlight for texture projection.
  44259. */
  44260. projectionTextureLightFar: number;
  44261. protected _projectionTextureUpDirection: Vector3;
  44262. /**
  44263. * Gets the Up vector of the Spotlight for texture projection.
  44264. */
  44265. /**
  44266. * Sets the Up vector of the Spotlight for texture projection.
  44267. */
  44268. projectionTextureUpDirection: Vector3;
  44269. private _projectionTexture;
  44270. /**
  44271. * Gets the projection texture of the light.
  44272. */
  44273. /**
  44274. * Sets the projection texture of the light.
  44275. */
  44276. projectionTexture: Nullable<BaseTexture>;
  44277. private _projectionTextureViewLightDirty;
  44278. private _projectionTextureProjectionLightDirty;
  44279. private _projectionTextureDirty;
  44280. private _projectionTextureViewTargetVector;
  44281. private _projectionTextureViewLightMatrix;
  44282. private _projectionTextureProjectionLightMatrix;
  44283. private _projectionTextureScalingMatrix;
  44284. /**
  44285. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44286. * It can cast shadows.
  44287. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44288. * @param name The light friendly name
  44289. * @param position The position of the spot light in the scene
  44290. * @param direction The direction of the light in the scene
  44291. * @param angle The cone angle of the light in Radians
  44292. * @param exponent The light decay speed with the distance from the emission spot
  44293. * @param scene The scene the lights belongs to
  44294. */
  44295. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44296. /**
  44297. * Returns the string "SpotLight".
  44298. * @returns the class name
  44299. */
  44300. getClassName(): string;
  44301. /**
  44302. * Returns the integer 2.
  44303. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44304. */
  44305. getTypeID(): number;
  44306. /**
  44307. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44308. */
  44309. protected _setDirection(value: Vector3): void;
  44310. /**
  44311. * Overrides the position setter to recompute the projection texture view light Matrix.
  44312. */
  44313. protected _setPosition(value: Vector3): void;
  44314. /**
  44315. * 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.
  44316. * Returns the SpotLight.
  44317. */
  44318. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44319. protected _computeProjectionTextureViewLightMatrix(): void;
  44320. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44321. /**
  44322. * Main function for light texture projection matrix computing.
  44323. */
  44324. protected _computeProjectionTextureMatrix(): void;
  44325. protected _buildUniformLayout(): void;
  44326. private _computeAngleValues;
  44327. /**
  44328. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44329. * @param effect The effect to update
  44330. * @param lightIndex The index of the light in the effect to update
  44331. * @returns The spot light
  44332. */
  44333. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44334. /**
  44335. * Disposes the light and the associated resources.
  44336. */
  44337. dispose(): void;
  44338. /**
  44339. * Prepares the list of defines specific to the light type.
  44340. * @param defines the list of defines
  44341. * @param lightIndex defines the index of the light for the effect
  44342. */
  44343. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44344. }
  44345. }
  44346. declare module BABYLON {
  44347. /**
  44348. * Header information of HDR texture files.
  44349. */
  44350. export interface HDRInfo {
  44351. /**
  44352. * The height of the texture in pixels.
  44353. */
  44354. height: number;
  44355. /**
  44356. * The width of the texture in pixels.
  44357. */
  44358. width: number;
  44359. /**
  44360. * The index of the beginning of the data in the binary file.
  44361. */
  44362. dataPosition: number;
  44363. }
  44364. /**
  44365. * This groups tools to convert HDR texture to native colors array.
  44366. */
  44367. export class HDRTools {
  44368. private static Ldexp;
  44369. private static Rgbe2float;
  44370. private static readStringLine;
  44371. /**
  44372. * Reads header information from an RGBE texture stored in a native array.
  44373. * More information on this format are available here:
  44374. * https://en.wikipedia.org/wiki/RGBE_image_format
  44375. *
  44376. * @param uint8array The binary file stored in native array.
  44377. * @return The header information.
  44378. */
  44379. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  44380. /**
  44381. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  44382. * This RGBE texture needs to store the information as a panorama.
  44383. *
  44384. * More information on this format are available here:
  44385. * https://en.wikipedia.org/wiki/RGBE_image_format
  44386. *
  44387. * @param buffer The binary file stored in an array buffer.
  44388. * @param size The expected size of the extracted cubemap.
  44389. * @return The Cube Map information.
  44390. */
  44391. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  44392. /**
  44393. * Returns the pixels data extracted from an RGBE texture.
  44394. * This pixels will be stored left to right up to down in the R G B order in one array.
  44395. *
  44396. * More information on this format are available here:
  44397. * https://en.wikipedia.org/wiki/RGBE_image_format
  44398. *
  44399. * @param uint8array The binary file stored in an array buffer.
  44400. * @param hdrInfo The header information of the file.
  44401. * @return The pixels data in RGB right to left up to down order.
  44402. */
  44403. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  44404. private static RGBE_ReadPixels_RLE;
  44405. }
  44406. }
  44407. declare module BABYLON {
  44408. /**
  44409. * This represents a texture coming from an HDR input.
  44410. *
  44411. * The only supported format is currently panorama picture stored in RGBE format.
  44412. * Example of such files can be found on HDRLib: http://hdrlib.com/
  44413. */
  44414. export class HDRCubeTexture extends BaseTexture {
  44415. private static _facesMapping;
  44416. private _generateHarmonics;
  44417. private _noMipmap;
  44418. private _textureMatrix;
  44419. private _size;
  44420. private _onLoad;
  44421. private _onError;
  44422. /**
  44423. * The texture URL.
  44424. */
  44425. url: string;
  44426. /**
  44427. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  44428. */
  44429. coordinatesMode: number;
  44430. protected _isBlocking: boolean;
  44431. /**
  44432. * Sets wether or not the texture is blocking during loading.
  44433. */
  44434. /**
  44435. * Gets wether or not the texture is blocking during loading.
  44436. */
  44437. isBlocking: boolean;
  44438. protected _rotationY: number;
  44439. /**
  44440. * Sets texture matrix rotation angle around Y axis in radians.
  44441. */
  44442. /**
  44443. * Gets texture matrix rotation angle around Y axis radians.
  44444. */
  44445. rotationY: number;
  44446. /**
  44447. * Gets or sets the center of the bounding box associated with the cube texture
  44448. * It must define where the camera used to render the texture was set
  44449. */
  44450. boundingBoxPosition: Vector3;
  44451. private _boundingBoxSize;
  44452. /**
  44453. * Gets or sets the size of the bounding box associated with the cube texture
  44454. * When defined, the cubemap will switch to local mode
  44455. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  44456. * @example https://www.babylonjs-playground.com/#RNASML
  44457. */
  44458. boundingBoxSize: Vector3;
  44459. /**
  44460. * Instantiates an HDRTexture from the following parameters.
  44461. *
  44462. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  44463. * @param scene The scene the texture will be used in
  44464. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  44465. * @param noMipmap Forces to not generate the mipmap if true
  44466. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  44467. * @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)
  44468. * @param reserved Reserved flag for internal use.
  44469. */
  44470. 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>);
  44471. /**
  44472. * Get the current class name of the texture useful for serialization or dynamic coding.
  44473. * @returns "HDRCubeTexture"
  44474. */
  44475. getClassName(): string;
  44476. /**
  44477. * Occurs when the file is raw .hdr file.
  44478. */
  44479. private loadTexture;
  44480. clone(): HDRCubeTexture;
  44481. delayLoad(): void;
  44482. /**
  44483. * Get the texture reflection matrix used to rotate/transform the reflection.
  44484. * @returns the reflection matrix
  44485. */
  44486. getReflectionTextureMatrix(): Matrix;
  44487. /**
  44488. * Set the texture reflection matrix used to rotate/transform the reflection.
  44489. * @param value Define the reflection matrix to set
  44490. */
  44491. setReflectionTextureMatrix(value: Matrix): void;
  44492. /**
  44493. * Parses a JSON representation of an HDR Texture in order to create the texture
  44494. * @param parsedTexture Define the JSON representation
  44495. * @param scene Define the scene the texture should be created in
  44496. * @param rootUrl Define the root url in case we need to load relative dependencies
  44497. * @returns the newly created texture after parsing
  44498. */
  44499. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  44500. serialize(): any;
  44501. }
  44502. }
  44503. declare module BABYLON {
  44504. /**
  44505. * Class used to control physics engine
  44506. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  44507. */
  44508. export class PhysicsEngine implements IPhysicsEngine {
  44509. private _physicsPlugin;
  44510. /**
  44511. * Global value used to control the smallest number supported by the simulation
  44512. */
  44513. static Epsilon: number;
  44514. private _impostors;
  44515. private _joints;
  44516. /**
  44517. * Gets the gravity vector used by the simulation
  44518. */
  44519. gravity: Vector3;
  44520. /**
  44521. * Factory used to create the default physics plugin.
  44522. * @returns The default physics plugin
  44523. */
  44524. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  44525. /**
  44526. * Creates a new Physics Engine
  44527. * @param gravity defines the gravity vector used by the simulation
  44528. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  44529. */
  44530. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  44531. /**
  44532. * Sets the gravity vector used by the simulation
  44533. * @param gravity defines the gravity vector to use
  44534. */
  44535. setGravity(gravity: Vector3): void;
  44536. /**
  44537. * Set the time step of the physics engine.
  44538. * Default is 1/60.
  44539. * To slow it down, enter 1/600 for example.
  44540. * To speed it up, 1/30
  44541. * @param newTimeStep defines the new timestep to apply to this world.
  44542. */
  44543. setTimeStep(newTimeStep?: number): void;
  44544. /**
  44545. * Get the time step of the physics engine.
  44546. * @returns the current time step
  44547. */
  44548. getTimeStep(): number;
  44549. /**
  44550. * Release all resources
  44551. */
  44552. dispose(): void;
  44553. /**
  44554. * Gets the name of the current physics plugin
  44555. * @returns the name of the plugin
  44556. */
  44557. getPhysicsPluginName(): string;
  44558. /**
  44559. * Adding a new impostor for the impostor tracking.
  44560. * This will be done by the impostor itself.
  44561. * @param impostor the impostor to add
  44562. */
  44563. addImpostor(impostor: PhysicsImpostor): void;
  44564. /**
  44565. * Remove an impostor from the engine.
  44566. * This impostor and its mesh will not longer be updated by the physics engine.
  44567. * @param impostor the impostor to remove
  44568. */
  44569. removeImpostor(impostor: PhysicsImpostor): void;
  44570. /**
  44571. * Add a joint to the physics engine
  44572. * @param mainImpostor defines the main impostor to which the joint is added.
  44573. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  44574. * @param joint defines the joint that will connect both impostors.
  44575. */
  44576. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  44577. /**
  44578. * Removes a joint from the simulation
  44579. * @param mainImpostor defines the impostor used with the joint
  44580. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  44581. * @param joint defines the joint to remove
  44582. */
  44583. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  44584. /**
  44585. * Called by the scene. No need to call it.
  44586. * @param delta defines the timespam between frames
  44587. */ step(delta: number): void;
  44588. /**
  44589. * Gets the current plugin used to run the simulation
  44590. * @returns current plugin
  44591. */
  44592. getPhysicsPlugin(): IPhysicsEnginePlugin;
  44593. /**
  44594. * Gets the list of physic impostors
  44595. * @returns an array of PhysicsImpostor
  44596. */
  44597. getImpostors(): Array<PhysicsImpostor>;
  44598. /**
  44599. * Gets the impostor for a physics enabled object
  44600. * @param object defines the object impersonated by the impostor
  44601. * @returns the PhysicsImpostor or null if not found
  44602. */
  44603. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  44604. /**
  44605. * Gets the impostor for a physics body object
  44606. * @param body defines physics body used by the impostor
  44607. * @returns the PhysicsImpostor or null if not found
  44608. */
  44609. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  44610. }
  44611. }
  44612. declare module BABYLON {
  44613. /** @hidden */
  44614. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  44615. private _useDeltaForWorldStep;
  44616. world: any;
  44617. name: string;
  44618. private _physicsMaterials;
  44619. private _fixedTimeStep;
  44620. BJSCANNON: any;
  44621. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  44622. setGravity(gravity: Vector3): void;
  44623. setTimeStep(timeStep: number): void;
  44624. getTimeStep(): number;
  44625. executeStep(delta: number): void;
  44626. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  44627. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  44628. generatePhysicsBody(impostor: PhysicsImpostor): void;
  44629. private _processChildMeshes;
  44630. removePhysicsBody(impostor: PhysicsImpostor): void;
  44631. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  44632. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  44633. private _addMaterial;
  44634. private _checkWithEpsilon;
  44635. private _createShape;
  44636. private _createHeightmap;
  44637. private _minus90X;
  44638. private _plus90X;
  44639. private _tmpPosition;
  44640. private _tmpDeltaPosition;
  44641. private _tmpUnityRotation;
  44642. private _updatePhysicsBodyTransformation;
  44643. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  44644. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  44645. isSupported(): boolean;
  44646. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  44647. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  44648. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  44649. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  44650. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  44651. getBodyMass(impostor: PhysicsImpostor): number;
  44652. getBodyFriction(impostor: PhysicsImpostor): number;
  44653. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  44654. getBodyRestitution(impostor: PhysicsImpostor): number;
  44655. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  44656. sleepBody(impostor: PhysicsImpostor): void;
  44657. wakeUpBody(impostor: PhysicsImpostor): void;
  44658. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  44659. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  44660. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  44661. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  44662. getRadius(impostor: PhysicsImpostor): number;
  44663. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  44664. dispose(): void;
  44665. private _extendNamespace;
  44666. }
  44667. }
  44668. declare module BABYLON {
  44669. /** @hidden */
  44670. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  44671. world: any;
  44672. name: string;
  44673. BJSOIMO: any;
  44674. constructor(iterations?: number, oimoInjection?: any);
  44675. setGravity(gravity: Vector3): void;
  44676. setTimeStep(timeStep: number): void;
  44677. getTimeStep(): number;
  44678. private _tmpImpostorsArray;
  44679. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  44680. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  44681. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  44682. generatePhysicsBody(impostor: PhysicsImpostor): void;
  44683. private _tmpPositionVector;
  44684. removePhysicsBody(impostor: PhysicsImpostor): void;
  44685. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  44686. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  44687. isSupported(): boolean;
  44688. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  44689. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  44690. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  44691. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  44692. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  44693. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  44694. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  44695. getBodyMass(impostor: PhysicsImpostor): number;
  44696. getBodyFriction(impostor: PhysicsImpostor): number;
  44697. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  44698. getBodyRestitution(impostor: PhysicsImpostor): number;
  44699. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  44700. sleepBody(impostor: PhysicsImpostor): void;
  44701. wakeUpBody(impostor: PhysicsImpostor): void;
  44702. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  44703. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  44704. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  44705. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  44706. getRadius(impostor: PhysicsImpostor): number;
  44707. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  44708. dispose(): void;
  44709. }
  44710. }
  44711. declare module BABYLON {
  44712. interface AbstractScene {
  44713. /**
  44714. * The list of reflection probes added to the scene
  44715. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  44716. */
  44717. reflectionProbes: Array<ReflectionProbe>;
  44718. /**
  44719. * Removes the given reflection probe from this scene.
  44720. * @param toRemove The reflection probe to remove
  44721. * @returns The index of the removed reflection probe
  44722. */
  44723. removeReflectionProbe(toRemove: ReflectionProbe): number;
  44724. /**
  44725. * Adds the given reflection probe to this scene.
  44726. * @param newReflectionProbe The reflection probe to add
  44727. */
  44728. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  44729. }
  44730. /**
  44731. * Class used to generate realtime reflection / refraction cube textures
  44732. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  44733. */
  44734. export class ReflectionProbe {
  44735. /** defines the name of the probe */
  44736. name: string;
  44737. private _scene;
  44738. private _renderTargetTexture;
  44739. private _projectionMatrix;
  44740. private _viewMatrix;
  44741. private _target;
  44742. private _add;
  44743. private _attachedMesh;
  44744. private _invertYAxis;
  44745. /** Gets or sets probe position (center of the cube map) */
  44746. position: Vector3;
  44747. /**
  44748. * Creates a new reflection probe
  44749. * @param name defines the name of the probe
  44750. * @param size defines the texture resolution (for each face)
  44751. * @param scene defines the hosting scene
  44752. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  44753. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  44754. */
  44755. constructor(
  44756. /** defines the name of the probe */
  44757. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  44758. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  44759. samples: number;
  44760. /** Gets or sets the refresh rate to use (on every frame by default) */
  44761. refreshRate: number;
  44762. /**
  44763. * Gets the hosting scene
  44764. * @returns a Scene
  44765. */
  44766. getScene(): Scene;
  44767. /** Gets the internal CubeTexture used to render to */
  44768. readonly cubeTexture: RenderTargetTexture;
  44769. /** Gets the list of meshes to render */
  44770. readonly renderList: Nullable<AbstractMesh[]>;
  44771. /**
  44772. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  44773. * @param mesh defines the mesh to attach to
  44774. */
  44775. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44776. /**
  44777. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  44778. * @param renderingGroupId The rendering group id corresponding to its index
  44779. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44780. */
  44781. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  44782. /**
  44783. * Clean all associated resources
  44784. */
  44785. dispose(): void;
  44786. /**
  44787. * Converts the reflection probe information to a readable string for debug purpose.
  44788. * @param fullDetails Supports for multiple levels of logging within scene loading
  44789. * @returns the human readable reflection probe info
  44790. */
  44791. toString(fullDetails?: boolean): string;
  44792. /**
  44793. * Get the class name of the relfection probe.
  44794. * @returns "ReflectionProbe"
  44795. */
  44796. getClassName(): string;
  44797. /**
  44798. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  44799. * @returns The JSON representation of the texture
  44800. */
  44801. serialize(): any;
  44802. /**
  44803. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  44804. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  44805. * @param scene Define the scene the parsed reflection probe should be instantiated in
  44806. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  44807. * @returns The parsed reflection probe if successful
  44808. */
  44809. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  44810. }
  44811. }
  44812. declare module BABYLON {
  44813. /** @hidden */
  44814. export var _BabylonLoaderRegistered: boolean;
  44815. }
  44816. declare module BABYLON {
  44817. /**
  44818. * The Physically based simple base material of BJS.
  44819. *
  44820. * This enables better naming and convention enforcements on top of the pbrMaterial.
  44821. * It is used as the base class for both the specGloss and metalRough conventions.
  44822. */
  44823. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  44824. /**
  44825. * Number of Simultaneous lights allowed on the material.
  44826. */
  44827. maxSimultaneousLights: number;
  44828. /**
  44829. * If sets to true, disables all the lights affecting the material.
  44830. */
  44831. disableLighting: boolean;
  44832. /**
  44833. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  44834. */
  44835. environmentTexture: BaseTexture;
  44836. /**
  44837. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44838. */
  44839. invertNormalMapX: boolean;
  44840. /**
  44841. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44842. */
  44843. invertNormalMapY: boolean;
  44844. /**
  44845. * Normal map used in the model.
  44846. */
  44847. normalTexture: BaseTexture;
  44848. /**
  44849. * Emissivie color used to self-illuminate the model.
  44850. */
  44851. emissiveColor: Color3;
  44852. /**
  44853. * Emissivie texture used to self-illuminate the model.
  44854. */
  44855. emissiveTexture: BaseTexture;
  44856. /**
  44857. * Occlusion Channel Strenght.
  44858. */
  44859. occlusionStrength: number;
  44860. /**
  44861. * Occlusion Texture of the material (adding extra occlusion effects).
  44862. */
  44863. occlusionTexture: BaseTexture;
  44864. /**
  44865. * Defines the alpha limits in alpha test mode.
  44866. */
  44867. alphaCutOff: number;
  44868. /**
  44869. * Gets the current double sided mode.
  44870. */
  44871. /**
  44872. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44873. */
  44874. doubleSided: boolean;
  44875. /**
  44876. * Stores the pre-calculated light information of a mesh in a texture.
  44877. */
  44878. lightmapTexture: BaseTexture;
  44879. /**
  44880. * If true, the light map contains occlusion information instead of lighting info.
  44881. */
  44882. useLightmapAsShadowmap: boolean;
  44883. /**
  44884. * Return the active textures of the material.
  44885. */
  44886. getActiveTextures(): BaseTexture[];
  44887. hasTexture(texture: BaseTexture): boolean;
  44888. /**
  44889. * Instantiates a new PBRMaterial instance.
  44890. *
  44891. * @param name The material name
  44892. * @param scene The scene the material will be use in.
  44893. */
  44894. constructor(name: string, scene: Scene);
  44895. getClassName(): string;
  44896. }
  44897. }
  44898. declare module BABYLON {
  44899. /**
  44900. * The PBR material of BJS following the metal roughness convention.
  44901. *
  44902. * This fits to the PBR convention in the GLTF definition:
  44903. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  44904. */
  44905. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  44906. /**
  44907. * The base color has two different interpretations depending on the value of metalness.
  44908. * When the material is a metal, the base color is the specific measured reflectance value
  44909. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  44910. * of the material.
  44911. */
  44912. baseColor: Color3;
  44913. /**
  44914. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  44915. * well as opacity information in the alpha channel.
  44916. */
  44917. baseTexture: BaseTexture;
  44918. /**
  44919. * Specifies the metallic scalar value of the material.
  44920. * Can also be used to scale the metalness values of the metallic texture.
  44921. */
  44922. metallic: number;
  44923. /**
  44924. * Specifies the roughness scalar value of the material.
  44925. * Can also be used to scale the roughness values of the metallic texture.
  44926. */
  44927. roughness: number;
  44928. /**
  44929. * Texture containing both the metallic value in the B channel and the
  44930. * roughness value in the G channel to keep better precision.
  44931. */
  44932. metallicRoughnessTexture: BaseTexture;
  44933. /**
  44934. * Instantiates a new PBRMetalRoughnessMaterial instance.
  44935. *
  44936. * @param name The material name
  44937. * @param scene The scene the material will be use in.
  44938. */
  44939. constructor(name: string, scene: Scene);
  44940. /**
  44941. * Return the currrent class name of the material.
  44942. */
  44943. getClassName(): string;
  44944. /**
  44945. * Return the active textures of the material.
  44946. */
  44947. getActiveTextures(): BaseTexture[];
  44948. /**
  44949. * Checks to see if a texture is used in the material.
  44950. * @param texture - Base texture to use.
  44951. * @returns - Boolean specifying if a texture is used in the material.
  44952. */
  44953. hasTexture(texture: BaseTexture): boolean;
  44954. /**
  44955. * Makes a duplicate of the current material.
  44956. * @param name - name to use for the new material.
  44957. */
  44958. clone(name: string): PBRMetallicRoughnessMaterial;
  44959. /**
  44960. * Serialize the material to a parsable JSON object.
  44961. */
  44962. serialize(): any;
  44963. /**
  44964. * Parses a JSON object correponding to the serialize function.
  44965. */
  44966. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  44967. }
  44968. }
  44969. declare module BABYLON {
  44970. /**
  44971. * The PBR material of BJS following the specular glossiness convention.
  44972. *
  44973. * This fits to the PBR convention in the GLTF definition:
  44974. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  44975. */
  44976. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  44977. /**
  44978. * Specifies the diffuse color of the material.
  44979. */
  44980. diffuseColor: Color3;
  44981. /**
  44982. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  44983. * channel.
  44984. */
  44985. diffuseTexture: BaseTexture;
  44986. /**
  44987. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  44988. */
  44989. specularColor: Color3;
  44990. /**
  44991. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  44992. */
  44993. glossiness: number;
  44994. /**
  44995. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  44996. */
  44997. specularGlossinessTexture: BaseTexture;
  44998. /**
  44999. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  45000. *
  45001. * @param name The material name
  45002. * @param scene The scene the material will be use in.
  45003. */
  45004. constructor(name: string, scene: Scene);
  45005. /**
  45006. * Return the currrent class name of the material.
  45007. */
  45008. getClassName(): string;
  45009. /**
  45010. * Return the active textures of the material.
  45011. */
  45012. getActiveTextures(): BaseTexture[];
  45013. /**
  45014. * Checks to see if a texture is used in the material.
  45015. * @param texture - Base texture to use.
  45016. * @returns - Boolean specifying if a texture is used in the material.
  45017. */
  45018. hasTexture(texture: BaseTexture): boolean;
  45019. /**
  45020. * Makes a duplicate of the current material.
  45021. * @param name - name to use for the new material.
  45022. */
  45023. clone(name: string): PBRSpecularGlossinessMaterial;
  45024. /**
  45025. * Serialize the material to a parsable JSON object.
  45026. */
  45027. serialize(): any;
  45028. /**
  45029. * Parses a JSON object correponding to the serialize function.
  45030. */
  45031. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  45032. }
  45033. }
  45034. declare module BABYLON {
  45035. /**
  45036. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  45037. * It can help converting any input color in a desired output one. This can then be used to create effects
  45038. * from sepia, black and white to sixties or futuristic rendering...
  45039. *
  45040. * The only supported format is currently 3dl.
  45041. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  45042. */
  45043. export class ColorGradingTexture extends BaseTexture {
  45044. /**
  45045. * The current texture matrix. (will always be identity in color grading texture)
  45046. */
  45047. private _textureMatrix;
  45048. /**
  45049. * The texture URL.
  45050. */
  45051. url: string;
  45052. /**
  45053. * Empty line regex stored for GC.
  45054. */
  45055. private static _noneEmptyLineRegex;
  45056. private _engine;
  45057. /**
  45058. * Instantiates a ColorGradingTexture from the following parameters.
  45059. *
  45060. * @param url The location of the color gradind data (currently only supporting 3dl)
  45061. * @param scene The scene the texture will be used in
  45062. */
  45063. constructor(url: string, scene: Scene);
  45064. /**
  45065. * Returns the texture matrix used in most of the material.
  45066. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  45067. */
  45068. getTextureMatrix(): Matrix;
  45069. /**
  45070. * Occurs when the file being loaded is a .3dl LUT file.
  45071. */
  45072. private load3dlTexture;
  45073. /**
  45074. * Starts the loading process of the texture.
  45075. */
  45076. private loadTexture;
  45077. /**
  45078. * Clones the color gradind texture.
  45079. */
  45080. clone(): ColorGradingTexture;
  45081. /**
  45082. * Called during delayed load for textures.
  45083. */
  45084. delayLoad(): void;
  45085. /**
  45086. * Parses a color grading texture serialized by Babylon.
  45087. * @param parsedTexture The texture information being parsedTexture
  45088. * @param scene The scene to load the texture in
  45089. * @param rootUrl The root url of the data assets to load
  45090. * @return A color gradind texture
  45091. */
  45092. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  45093. /**
  45094. * Serializes the LUT texture to json format.
  45095. */
  45096. serialize(): any;
  45097. }
  45098. }
  45099. declare module BABYLON {
  45100. /**
  45101. * Direct draw surface info
  45102. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45103. */
  45104. export interface DDSInfo {
  45105. /**
  45106. * Width of the texture
  45107. */
  45108. width: number;
  45109. /**
  45110. * Width of the texture
  45111. */
  45112. height: number;
  45113. /**
  45114. * Number of Mipmaps for the texture
  45115. * @see https://en.wikipedia.org/wiki/Mipmap
  45116. */
  45117. mipmapCount: number;
  45118. /**
  45119. * If the textures format is a known fourCC format
  45120. * @see https://www.fourcc.org/
  45121. */
  45122. isFourCC: boolean;
  45123. /**
  45124. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45125. */
  45126. isRGB: boolean;
  45127. /**
  45128. * If the texture is a lumincance format
  45129. */
  45130. isLuminance: boolean;
  45131. /**
  45132. * If this is a cube texture
  45133. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45134. */
  45135. isCube: boolean;
  45136. /**
  45137. * If the texture is a compressed format eg. FOURCC_DXT1
  45138. */
  45139. isCompressed: boolean;
  45140. /**
  45141. * The dxgiFormat of the texture
  45142. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45143. */
  45144. dxgiFormat: number;
  45145. /**
  45146. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45147. */
  45148. textureType: number;
  45149. /**
  45150. * Sphericle polynomial created for the dds texture
  45151. */
  45152. sphericalPolynomial?: SphericalPolynomial;
  45153. }
  45154. /**
  45155. * Class used to provide DDS decompression tools
  45156. */
  45157. export class DDSTools {
  45158. /**
  45159. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45160. */
  45161. static StoreLODInAlphaChannel: boolean;
  45162. /**
  45163. * Gets DDS information from an array buffer
  45164. * @param arrayBuffer defines the array buffer to read data from
  45165. * @returns the DDS information
  45166. */
  45167. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45168. private static _FloatView;
  45169. private static _Int32View;
  45170. private static _ToHalfFloat;
  45171. private static _FromHalfFloat;
  45172. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45173. private static _GetHalfFloatRGBAArrayBuffer;
  45174. private static _GetFloatRGBAArrayBuffer;
  45175. private static _GetFloatAsUIntRGBAArrayBuffer;
  45176. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45177. private static _GetRGBAArrayBuffer;
  45178. private static _ExtractLongWordOrder;
  45179. private static _GetRGBArrayBuffer;
  45180. private static _GetLuminanceArrayBuffer;
  45181. /**
  45182. * Uploads DDS Levels to a Babylon Texture
  45183. * @hidden
  45184. */
  45185. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45186. }
  45187. interface Engine {
  45188. /**
  45189. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45190. * @param rootUrl defines the url where the file to load is located
  45191. * @param scene defines the current scene
  45192. * @param lodScale defines scale to apply to the mip map selection
  45193. * @param lodOffset defines offset to apply to the mip map selection
  45194. * @param onLoad defines an optional callback raised when the texture is loaded
  45195. * @param onError defines an optional callback raised if there is an issue to load the texture
  45196. * @param format defines the format of the data
  45197. * @param forcedExtension defines the extension to use to pick the right loader
  45198. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45199. * @returns the cube texture as an InternalTexture
  45200. */
  45201. 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;
  45202. }
  45203. }
  45204. declare module BABYLON {
  45205. /**
  45206. * Implementation of the DDS Texture Loader.
  45207. * @hidden
  45208. */
  45209. export class _DDSTextureLoader implements IInternalTextureLoader {
  45210. /**
  45211. * Defines wether the loader supports cascade loading the different faces.
  45212. */
  45213. readonly supportCascades: boolean;
  45214. /**
  45215. * This returns if the loader support the current file information.
  45216. * @param extension defines the file extension of the file being loaded
  45217. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45218. * @param fallback defines the fallback internal texture if any
  45219. * @param isBase64 defines whether the texture is encoded as a base64
  45220. * @param isBuffer defines whether the texture data are stored as a buffer
  45221. * @returns true if the loader can load the specified file
  45222. */
  45223. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45224. /**
  45225. * Transform the url before loading if required.
  45226. * @param rootUrl the url of the texture
  45227. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45228. * @returns the transformed texture
  45229. */
  45230. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45231. /**
  45232. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45233. * @param rootUrl the url of the texture
  45234. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45235. * @returns the fallback texture
  45236. */
  45237. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45238. /**
  45239. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45240. * @param data contains the texture data
  45241. * @param texture defines the BabylonJS internal texture
  45242. * @param createPolynomials will be true if polynomials have been requested
  45243. * @param onLoad defines the callback to trigger once the texture is ready
  45244. * @param onError defines the callback to trigger in case of error
  45245. */
  45246. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45247. /**
  45248. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45249. * @param data contains the texture data
  45250. * @param texture defines the BabylonJS internal texture
  45251. * @param callback defines the method to call once ready to upload
  45252. */
  45253. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45254. }
  45255. }
  45256. declare module BABYLON {
  45257. /** @hidden */
  45258. export var rgbdEncodePixelShader: {
  45259. name: string;
  45260. shader: string;
  45261. };
  45262. }
  45263. declare module BABYLON {
  45264. /** @hidden */
  45265. export var rgbdDecodePixelShader: {
  45266. name: string;
  45267. shader: string;
  45268. };
  45269. }
  45270. declare module BABYLON {
  45271. /**
  45272. * Raw texture data and descriptor sufficient for WebGL texture upload
  45273. */
  45274. export interface EnvironmentTextureInfo {
  45275. /**
  45276. * Version of the environment map
  45277. */
  45278. version: number;
  45279. /**
  45280. * Width of image
  45281. */
  45282. width: number;
  45283. /**
  45284. * Irradiance information stored in the file.
  45285. */
  45286. irradiance: any;
  45287. /**
  45288. * Specular information stored in the file.
  45289. */
  45290. specular: any;
  45291. }
  45292. /**
  45293. * Sets of helpers addressing the serialization and deserialization of environment texture
  45294. * stored in a BabylonJS env file.
  45295. * Those files are usually stored as .env files.
  45296. */
  45297. export class EnvironmentTextureTools {
  45298. /**
  45299. * Magic number identifying the env file.
  45300. */
  45301. private static _MagicBytes;
  45302. /**
  45303. * Gets the environment info from an env file.
  45304. * @param data The array buffer containing the .env bytes.
  45305. * @returns the environment file info (the json header) if successfully parsed.
  45306. */
  45307. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45308. /**
  45309. * Creates an environment texture from a loaded cube texture.
  45310. * @param texture defines the cube texture to convert in env file
  45311. * @return a promise containing the environment data if succesfull.
  45312. */
  45313. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45314. /**
  45315. * Creates a JSON representation of the spherical data.
  45316. * @param texture defines the texture containing the polynomials
  45317. * @return the JSON representation of the spherical info
  45318. */
  45319. private static _CreateEnvTextureIrradiance;
  45320. /**
  45321. * Uploads the texture info contained in the env file to the GPU.
  45322. * @param texture defines the internal texture to upload to
  45323. * @param arrayBuffer defines the buffer cotaining the data to load
  45324. * @param info defines the texture info retrieved through the GetEnvInfo method
  45325. * @returns a promise
  45326. */
  45327. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45328. /**
  45329. * Uploads the levels of image data to the GPU.
  45330. * @param texture defines the internal texture to upload to
  45331. * @param imageData defines the array buffer views of image data [mipmap][face]
  45332. * @returns a promise
  45333. */
  45334. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45335. /**
  45336. * Uploads spherical polynomials information to the texture.
  45337. * @param texture defines the texture we are trying to upload the information to
  45338. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45339. */
  45340. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45341. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45342. }
  45343. }
  45344. declare module BABYLON {
  45345. /**
  45346. * Implementation of the ENV Texture Loader.
  45347. * @hidden
  45348. */
  45349. export class _ENVTextureLoader implements IInternalTextureLoader {
  45350. /**
  45351. * Defines wether the loader supports cascade loading the different faces.
  45352. */
  45353. readonly supportCascades: boolean;
  45354. /**
  45355. * This returns if the loader support the current file information.
  45356. * @param extension defines the file extension of the file being loaded
  45357. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45358. * @param fallback defines the fallback internal texture if any
  45359. * @param isBase64 defines whether the texture is encoded as a base64
  45360. * @param isBuffer defines whether the texture data are stored as a buffer
  45361. * @returns true if the loader can load the specified file
  45362. */
  45363. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45364. /**
  45365. * Transform the url before loading if required.
  45366. * @param rootUrl the url of the texture
  45367. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45368. * @returns the transformed texture
  45369. */
  45370. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45371. /**
  45372. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45373. * @param rootUrl the url of the texture
  45374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45375. * @returns the fallback texture
  45376. */
  45377. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45378. /**
  45379. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45380. * @param data contains the texture data
  45381. * @param texture defines the BabylonJS internal texture
  45382. * @param createPolynomials will be true if polynomials have been requested
  45383. * @param onLoad defines the callback to trigger once the texture is ready
  45384. * @param onError defines the callback to trigger in case of error
  45385. */
  45386. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45387. /**
  45388. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45389. * @param data contains the texture data
  45390. * @param texture defines the BabylonJS internal texture
  45391. * @param callback defines the method to call once ready to upload
  45392. */
  45393. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45394. }
  45395. }
  45396. declare module BABYLON {
  45397. /**
  45398. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45399. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45400. */
  45401. export class KhronosTextureContainer {
  45402. /** contents of the KTX container file */
  45403. arrayBuffer: any;
  45404. private static HEADER_LEN;
  45405. private static COMPRESSED_2D;
  45406. private static COMPRESSED_3D;
  45407. private static TEX_2D;
  45408. private static TEX_3D;
  45409. /**
  45410. * Gets the openGL type
  45411. */
  45412. glType: number;
  45413. /**
  45414. * Gets the openGL type size
  45415. */
  45416. glTypeSize: number;
  45417. /**
  45418. * Gets the openGL format
  45419. */
  45420. glFormat: number;
  45421. /**
  45422. * Gets the openGL internal format
  45423. */
  45424. glInternalFormat: number;
  45425. /**
  45426. * Gets the base internal format
  45427. */
  45428. glBaseInternalFormat: number;
  45429. /**
  45430. * Gets image width in pixel
  45431. */
  45432. pixelWidth: number;
  45433. /**
  45434. * Gets image height in pixel
  45435. */
  45436. pixelHeight: number;
  45437. /**
  45438. * Gets image depth in pixels
  45439. */
  45440. pixelDepth: number;
  45441. /**
  45442. * Gets the number of array elements
  45443. */
  45444. numberOfArrayElements: number;
  45445. /**
  45446. * Gets the number of faces
  45447. */
  45448. numberOfFaces: number;
  45449. /**
  45450. * Gets the number of mipmap levels
  45451. */
  45452. numberOfMipmapLevels: number;
  45453. /**
  45454. * Gets the bytes of key value data
  45455. */
  45456. bytesOfKeyValueData: number;
  45457. /**
  45458. * Gets the load type
  45459. */
  45460. loadType: number;
  45461. /**
  45462. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45463. */
  45464. isInvalid: boolean;
  45465. /**
  45466. * Creates a new KhronosTextureContainer
  45467. * @param arrayBuffer contents of the KTX container file
  45468. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45469. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45470. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45471. */
  45472. constructor(
  45473. /** contents of the KTX container file */
  45474. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45475. /**
  45476. * Uploads KTX content to a Babylon Texture.
  45477. * It is assumed that the texture has already been created & is currently bound
  45478. * @hidden
  45479. */
  45480. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45481. private _upload2DCompressedLevels;
  45482. }
  45483. }
  45484. declare module BABYLON {
  45485. /**
  45486. * Implementation of the KTX Texture Loader.
  45487. * @hidden
  45488. */
  45489. export class _KTXTextureLoader implements IInternalTextureLoader {
  45490. /**
  45491. * Defines wether the loader supports cascade loading the different faces.
  45492. */
  45493. readonly supportCascades: boolean;
  45494. /**
  45495. * This returns if the loader support the current file information.
  45496. * @param extension defines the file extension of the file being loaded
  45497. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45498. * @param fallback defines the fallback internal texture if any
  45499. * @param isBase64 defines whether the texture is encoded as a base64
  45500. * @param isBuffer defines whether the texture data are stored as a buffer
  45501. * @returns true if the loader can load the specified file
  45502. */
  45503. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45504. /**
  45505. * Transform the url before loading if required.
  45506. * @param rootUrl the url of the texture
  45507. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45508. * @returns the transformed texture
  45509. */
  45510. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45511. /**
  45512. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45513. * @param rootUrl the url of the texture
  45514. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45515. * @returns the fallback texture
  45516. */
  45517. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45518. /**
  45519. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45520. * @param data contains the texture data
  45521. * @param texture defines the BabylonJS internal texture
  45522. * @param createPolynomials will be true if polynomials have been requested
  45523. * @param onLoad defines the callback to trigger once the texture is ready
  45524. * @param onError defines the callback to trigger in case of error
  45525. */
  45526. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45527. /**
  45528. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45529. * @param data contains the texture data
  45530. * @param texture defines the BabylonJS internal texture
  45531. * @param callback defines the method to call once ready to upload
  45532. */
  45533. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45534. }
  45535. }
  45536. declare module BABYLON {
  45537. /**
  45538. * Based on jsTGALoader - Javascript loader for TGA file
  45539. * By Vincent Thibault
  45540. * @see http://blog.robrowser.com/javascript-tga-loader.html
  45541. */
  45542. export class TGATools {
  45543. private static _TYPE_INDEXED;
  45544. private static _TYPE_RGB;
  45545. private static _TYPE_GREY;
  45546. private static _TYPE_RLE_INDEXED;
  45547. private static _TYPE_RLE_RGB;
  45548. private static _TYPE_RLE_GREY;
  45549. private static _ORIGIN_MASK;
  45550. private static _ORIGIN_SHIFT;
  45551. private static _ORIGIN_BL;
  45552. private static _ORIGIN_BR;
  45553. private static _ORIGIN_UL;
  45554. private static _ORIGIN_UR;
  45555. /**
  45556. * Gets the header of a TGA file
  45557. * @param data defines the TGA data
  45558. * @returns the header
  45559. */
  45560. static GetTGAHeader(data: Uint8Array): any;
  45561. /**
  45562. * Uploads TGA content to a Babylon Texture
  45563. * @hidden
  45564. */
  45565. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  45566. /** @hidden */ 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;
  45567. /** @hidden */ 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;
  45568. /** @hidden */ 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;
  45569. /** @hidden */ 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;
  45570. /** @hidden */ 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;
  45571. /** @hidden */ 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;
  45572. }
  45573. }
  45574. declare module BABYLON {
  45575. /**
  45576. * Implementation of the TGA Texture Loader.
  45577. * @hidden
  45578. */
  45579. export class _TGATextureLoader implements IInternalTextureLoader {
  45580. /**
  45581. * Defines wether the loader supports cascade loading the different faces.
  45582. */
  45583. readonly supportCascades: boolean;
  45584. /**
  45585. * This returns if the loader support the current file information.
  45586. * @param extension defines the file extension of the file being loaded
  45587. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45588. * @param fallback defines the fallback internal texture if any
  45589. * @param isBase64 defines whether the texture is encoded as a base64
  45590. * @param isBuffer defines whether the texture data are stored as a buffer
  45591. * @returns true if the loader can load the specified file
  45592. */
  45593. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45594. /**
  45595. * Transform the url before loading if required.
  45596. * @param rootUrl the url of the texture
  45597. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45598. * @returns the transformed texture
  45599. */
  45600. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45601. /**
  45602. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45603. * @param rootUrl the url of the texture
  45604. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45605. * @returns the fallback texture
  45606. */
  45607. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45608. /**
  45609. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45610. * @param data contains the texture data
  45611. * @param texture defines the BabylonJS internal texture
  45612. * @param createPolynomials will be true if polynomials have been requested
  45613. * @param onLoad defines the callback to trigger once the texture is ready
  45614. * @param onError defines the callback to trigger in case of error
  45615. */
  45616. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45617. /**
  45618. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45619. * @param data contains the texture data
  45620. * @param texture defines the BabylonJS internal texture
  45621. * @param callback defines the method to call once ready to upload
  45622. */
  45623. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45624. }
  45625. }
  45626. declare module BABYLON {
  45627. /**
  45628. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  45629. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  45630. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  45631. */
  45632. export class CustomProceduralTexture extends ProceduralTexture {
  45633. private _animate;
  45634. private _time;
  45635. private _config;
  45636. private _texturePath;
  45637. /**
  45638. * Instantiates a new Custom Procedural Texture.
  45639. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  45640. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  45641. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  45642. * @param name Define the name of the texture
  45643. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  45644. * @param size Define the size of the texture to create
  45645. * @param scene Define the scene the texture belongs to
  45646. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  45647. * @param generateMipMaps Define if the texture should creates mip maps or not
  45648. */
  45649. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  45650. private _loadJson;
  45651. /**
  45652. * Is the texture ready to be used ? (rendered at least once)
  45653. * @returns true if ready, otherwise, false.
  45654. */
  45655. isReady(): boolean;
  45656. /**
  45657. * Render the texture to its associated render target.
  45658. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  45659. */
  45660. render(useCameraPostProcess?: boolean): void;
  45661. /**
  45662. * Update the list of dependant textures samplers in the shader.
  45663. */
  45664. updateTextures(): void;
  45665. /**
  45666. * Update the uniform values of the procedural texture in the shader.
  45667. */
  45668. updateShaderUniforms(): void;
  45669. /**
  45670. * Define if the texture animates or not.
  45671. */
  45672. animate: boolean;
  45673. }
  45674. }
  45675. declare module BABYLON {
  45676. /** @hidden */
  45677. export var noisePixelShader: {
  45678. name: string;
  45679. shader: string;
  45680. };
  45681. }
  45682. declare module BABYLON {
  45683. /**
  45684. * Class used to generate noise procedural textures
  45685. */
  45686. export class NoiseProceduralTexture extends ProceduralTexture {
  45687. private _time;
  45688. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  45689. brightness: number;
  45690. /** Defines the number of octaves to process */
  45691. octaves: number;
  45692. /** Defines the level of persistence (0.8 by default) */
  45693. persistence: number;
  45694. /** Gets or sets animation speed factor (default is 1) */
  45695. animationSpeedFactor: number;
  45696. /**
  45697. * Creates a new NoiseProceduralTexture
  45698. * @param name defines the name fo the texture
  45699. * @param size defines the size of the texture (default is 256)
  45700. * @param scene defines the hosting scene
  45701. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  45702. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  45703. */
  45704. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  45705. private _updateShaderUniforms;
  45706. protected _getDefines(): string;
  45707. /** Generate the current state of the procedural texture */
  45708. render(useCameraPostProcess?: boolean): void;
  45709. /**
  45710. * Serializes this noise procedural texture
  45711. * @returns a serialized noise procedural texture object
  45712. */
  45713. serialize(): any;
  45714. /**
  45715. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  45716. * @param parsedTexture defines parsed texture data
  45717. * @param scene defines the current scene
  45718. * @param rootUrl defines the root URL containing noise procedural texture information
  45719. * @returns a parsed NoiseProceduralTexture
  45720. */
  45721. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  45722. }
  45723. }
  45724. declare module BABYLON {
  45725. /**
  45726. * Raw cube texture where the raw buffers are passed in
  45727. */
  45728. export class RawCubeTexture extends CubeTexture {
  45729. /**
  45730. * Creates a cube texture where the raw buffers are passed in.
  45731. * @param scene defines the scene the texture is attached to
  45732. * @param data defines the array of data to use to create each face
  45733. * @param size defines the size of the textures
  45734. * @param format defines the format of the data
  45735. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45736. * @param generateMipMaps defines if the engine should generate the mip levels
  45737. * @param invertY defines if data must be stored with Y axis inverted
  45738. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45739. * @param compression defines the compression used (null by default)
  45740. */
  45741. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  45742. /**
  45743. * Updates the raw cube texture.
  45744. * @param data defines the data to store
  45745. * @param format defines the data format
  45746. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45747. * @param invertY defines if data must be stored with Y axis inverted
  45748. * @param compression defines the compression used (null by default)
  45749. * @param level defines which level of the texture to update
  45750. */
  45751. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  45752. /**
  45753. * Updates a raw cube texture with RGBD encoded data.
  45754. * @param data defines the array of data [mipmap][face] to use to create each face
  45755. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  45756. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45757. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45758. * @returns a promsie that resolves when the operation is complete
  45759. */
  45760. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  45761. /**
  45762. * Clones the raw cube texture.
  45763. * @return a new cube texture
  45764. */
  45765. clone(): CubeTexture;
  45766. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45767. }
  45768. }
  45769. declare module BABYLON {
  45770. /**
  45771. * Class used to store 3D textures containing user data
  45772. */
  45773. export class RawTexture3D extends Texture {
  45774. /** Gets or sets the texture format to use */
  45775. format: number;
  45776. private _engine;
  45777. /**
  45778. * Create a new RawTexture3D
  45779. * @param data defines the data of the texture
  45780. * @param width defines the width of the texture
  45781. * @param height defines the height of the texture
  45782. * @param depth defines the depth of the texture
  45783. * @param format defines the texture format to use
  45784. * @param scene defines the hosting scene
  45785. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  45786. * @param invertY defines if texture must be stored with Y axis inverted
  45787. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  45788. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45789. */
  45790. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  45791. /** Gets or sets the texture format to use */
  45792. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  45793. /**
  45794. * Update the texture with new data
  45795. * @param data defines the data to store in the texture
  45796. */
  45797. update(data: ArrayBufferView): void;
  45798. }
  45799. }
  45800. declare module BABYLON {
  45801. /**
  45802. * Creates a refraction texture used by refraction channel of the standard material.
  45803. * It is like a mirror but to see through a material.
  45804. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  45805. */
  45806. export class RefractionTexture extends RenderTargetTexture {
  45807. /**
  45808. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  45809. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  45810. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  45811. */
  45812. refractionPlane: Plane;
  45813. /**
  45814. * Define how deep under the surface we should see.
  45815. */
  45816. depth: number;
  45817. /**
  45818. * Creates a refraction texture used by refraction channel of the standard material.
  45819. * It is like a mirror but to see through a material.
  45820. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  45821. * @param name Define the texture name
  45822. * @param size Define the size of the underlying texture
  45823. * @param scene Define the scene the refraction belongs to
  45824. * @param generateMipMaps Define if we need to generate mips level for the refraction
  45825. */
  45826. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  45827. /**
  45828. * Clone the refraction texture.
  45829. * @returns the cloned texture
  45830. */
  45831. clone(): RefractionTexture;
  45832. /**
  45833. * Serialize the texture to a JSON representation you could use in Parse later on
  45834. * @returns the serialized JSON representation
  45835. */
  45836. serialize(): any;
  45837. }
  45838. }
  45839. declare module BABYLON {
  45840. /**
  45841. * Configuration for Draco compression
  45842. */
  45843. export interface IDracoCompressionConfiguration {
  45844. /**
  45845. * Configuration for the decoder.
  45846. */
  45847. decoder?: {
  45848. /**
  45849. * The url to the WebAssembly module.
  45850. */
  45851. wasmUrl?: string;
  45852. /**
  45853. * The url to the WebAssembly binary.
  45854. */
  45855. wasmBinaryUrl?: string;
  45856. /**
  45857. * The url to the fallback JavaScript module.
  45858. */
  45859. fallbackUrl?: string;
  45860. };
  45861. }
  45862. /**
  45863. * Draco compression (https://google.github.io/draco/)
  45864. *
  45865. * This class wraps the Draco module.
  45866. *
  45867. * **Encoder**
  45868. *
  45869. * The encoder is not currently implemented.
  45870. *
  45871. * **Decoder**
  45872. *
  45873. * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.
  45874. *
  45875. * To update the configuration, use the following code:
  45876. * ```javascript
  45877. * DracoCompression.Configuration = {
  45878. * decoder: {
  45879. * wasmUrl: "<url to the WebAssembly library>",
  45880. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  45881. * fallbackUrl: "<url to the fallback JavaScript library>",
  45882. * }
  45883. * };
  45884. * ```
  45885. *
  45886. * 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.
  45887. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  45888. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  45889. *
  45890. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  45891. * ```javascript
  45892. * var dracoCompression = new DracoCompression();
  45893. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  45894. * [VertexBuffer.PositionKind]: 0
  45895. * });
  45896. * ```
  45897. *
  45898. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  45899. */
  45900. export class DracoCompression implements IDisposable {
  45901. private static _DecoderModulePromise;
  45902. /**
  45903. * The configuration. Defaults to the following urls:
  45904. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  45905. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  45906. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  45907. */
  45908. static Configuration: IDracoCompressionConfiguration;
  45909. /**
  45910. * Returns true if the decoder is available.
  45911. */
  45912. static readonly DecoderAvailable: boolean;
  45913. /**
  45914. * Constructor
  45915. */
  45916. constructor();
  45917. /**
  45918. * Stop all async operations and release resources.
  45919. */
  45920. dispose(): void;
  45921. /**
  45922. * Decode Draco compressed mesh data to vertex data.
  45923. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  45924. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  45925. * @returns A promise that resolves with the decoded vertex data
  45926. */
  45927. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  45928. [kind: string]: number;
  45929. }): Promise<VertexData>;
  45930. private static _GetDecoderModule;
  45931. private static _LoadScriptAsync;
  45932. private static _LoadFileAsync;
  45933. }
  45934. }
  45935. declare module BABYLON {
  45936. /**
  45937. * Class for building Constructive Solid Geometry
  45938. */
  45939. export class CSG {
  45940. private polygons;
  45941. /**
  45942. * The world matrix
  45943. */
  45944. matrix: Matrix;
  45945. /**
  45946. * Stores the position
  45947. */
  45948. position: Vector3;
  45949. /**
  45950. * Stores the rotation
  45951. */
  45952. rotation: Vector3;
  45953. /**
  45954. * Stores the rotation quaternion
  45955. */
  45956. rotationQuaternion: Nullable<Quaternion>;
  45957. /**
  45958. * Stores the scaling vector
  45959. */
  45960. scaling: Vector3;
  45961. /**
  45962. * Convert the Mesh to CSG
  45963. * @param mesh The Mesh to convert to CSG
  45964. * @returns A new CSG from the Mesh
  45965. */
  45966. static FromMesh(mesh: Mesh): CSG;
  45967. /**
  45968. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  45969. * @param polygons Polygons used to construct a CSG solid
  45970. */
  45971. private static FromPolygons;
  45972. /**
  45973. * Clones, or makes a deep copy, of the CSG
  45974. * @returns A new CSG
  45975. */
  45976. clone(): CSG;
  45977. /**
  45978. * Unions this CSG with another CSG
  45979. * @param csg The CSG to union against this CSG
  45980. * @returns The unioned CSG
  45981. */
  45982. union(csg: CSG): CSG;
  45983. /**
  45984. * Unions this CSG with another CSG in place
  45985. * @param csg The CSG to union against this CSG
  45986. */
  45987. unionInPlace(csg: CSG): void;
  45988. /**
  45989. * Subtracts this CSG with another CSG
  45990. * @param csg The CSG to subtract against this CSG
  45991. * @returns A new CSG
  45992. */
  45993. subtract(csg: CSG): CSG;
  45994. /**
  45995. * Subtracts this CSG with another CSG in place
  45996. * @param csg The CSG to subtact against this CSG
  45997. */
  45998. subtractInPlace(csg: CSG): void;
  45999. /**
  46000. * Intersect this CSG with another CSG
  46001. * @param csg The CSG to intersect against this CSG
  46002. * @returns A new CSG
  46003. */
  46004. intersect(csg: CSG): CSG;
  46005. /**
  46006. * Intersects this CSG with another CSG in place
  46007. * @param csg The CSG to intersect against this CSG
  46008. */
  46009. intersectInPlace(csg: CSG): void;
  46010. /**
  46011. * Return a new CSG solid with solid and empty space switched. This solid is
  46012. * not modified.
  46013. * @returns A new CSG solid with solid and empty space switched
  46014. */
  46015. inverse(): CSG;
  46016. /**
  46017. * Inverses the CSG in place
  46018. */
  46019. inverseInPlace(): void;
  46020. /**
  46021. * This is used to keep meshes transformations so they can be restored
  46022. * when we build back a Babylon Mesh
  46023. * NB : All CSG operations are performed in world coordinates
  46024. * @param csg The CSG to copy the transform attributes from
  46025. * @returns This CSG
  46026. */
  46027. copyTransformAttributes(csg: CSG): CSG;
  46028. /**
  46029. * Build Raw mesh from CSG
  46030. * Coordinates here are in world space
  46031. * @param name The name of the mesh geometry
  46032. * @param scene The Scene
  46033. * @param keepSubMeshes Specifies if the submeshes should be kept
  46034. * @returns A new Mesh
  46035. */
  46036. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  46037. /**
  46038. * Build Mesh from CSG taking material and transforms into account
  46039. * @param name The name of the Mesh
  46040. * @param material The material of the Mesh
  46041. * @param scene The Scene
  46042. * @param keepSubMeshes Specifies if submeshes should be kept
  46043. * @returns The new Mesh
  46044. */
  46045. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  46046. }
  46047. }
  46048. declare module BABYLON {
  46049. /**
  46050. * Class containing static functions to help procedurally build meshes
  46051. */
  46052. export class RibbonBuilder {
  46053. /**
  46054. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  46055. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  46056. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  46057. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  46058. * * 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
  46059. * * 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
  46060. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  46061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46062. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46064. * * 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
  46065. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  46066. * * 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
  46067. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  46068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46069. * @param name defines the name of the mesh
  46070. * @param options defines the options used to create the mesh
  46071. * @param scene defines the hosting scene
  46072. * @returns the ribbon mesh
  46073. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  46074. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46075. */
  46076. static CreateRibbon(name: string, options: {
  46077. pathArray: Vector3[][];
  46078. closeArray?: boolean;
  46079. closePath?: boolean;
  46080. offset?: number;
  46081. updatable?: boolean;
  46082. sideOrientation?: number;
  46083. frontUVs?: Vector4;
  46084. backUVs?: Vector4;
  46085. instance?: Mesh;
  46086. invertUV?: boolean;
  46087. uvs?: Vector2[];
  46088. colors?: Color4[];
  46089. }, scene?: Nullable<Scene>): Mesh;
  46090. }
  46091. }
  46092. declare module BABYLON {
  46093. /**
  46094. * Class containing static functions to help procedurally build meshes
  46095. */
  46096. export class TorusKnotBuilder {
  46097. /**
  46098. * Creates a torus knot mesh
  46099. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  46100. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  46101. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  46102. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  46103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46104. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46106. * @param name defines the name of the mesh
  46107. * @param options defines the options used to create the mesh
  46108. * @param scene defines the hosting scene
  46109. * @returns the torus knot mesh
  46110. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  46111. */
  46112. static CreateTorusKnot(name: string, options: {
  46113. radius?: number;
  46114. tube?: number;
  46115. radialSegments?: number;
  46116. tubularSegments?: number;
  46117. p?: number;
  46118. q?: number;
  46119. updatable?: boolean;
  46120. sideOrientation?: number;
  46121. frontUVs?: Vector4;
  46122. backUVs?: Vector4;
  46123. }, scene: any): Mesh;
  46124. }
  46125. }
  46126. declare module BABYLON {
  46127. /**
  46128. * Polygon
  46129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  46130. */
  46131. export class Polygon {
  46132. /**
  46133. * Creates a rectangle
  46134. * @param xmin bottom X coord
  46135. * @param ymin bottom Y coord
  46136. * @param xmax top X coord
  46137. * @param ymax top Y coord
  46138. * @returns points that make the resulting rectation
  46139. */
  46140. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  46141. /**
  46142. * Creates a circle
  46143. * @param radius radius of circle
  46144. * @param cx scale in x
  46145. * @param cy scale in y
  46146. * @param numberOfSides number of sides that make up the circle
  46147. * @returns points that make the resulting circle
  46148. */
  46149. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  46150. /**
  46151. * Creates a polygon from input string
  46152. * @param input Input polygon data
  46153. * @returns the parsed points
  46154. */
  46155. static Parse(input: string): Vector2[];
  46156. /**
  46157. * Starts building a polygon from x and y coordinates
  46158. * @param x x coordinate
  46159. * @param y y coordinate
  46160. * @returns the started path2
  46161. */
  46162. static StartingAt(x: number, y: number): Path2;
  46163. }
  46164. /**
  46165. * Builds a polygon
  46166. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  46167. */
  46168. export class PolygonMeshBuilder {
  46169. private _points;
  46170. private _outlinepoints;
  46171. private _holes;
  46172. private _name;
  46173. private _scene;
  46174. private _epoints;
  46175. private _eholes;
  46176. private _addToepoint;
  46177. /**
  46178. * Babylon reference to the earcut plugin.
  46179. */
  46180. bjsEarcut: any;
  46181. /**
  46182. * Creates a PolygonMeshBuilder
  46183. * @param name name of the builder
  46184. * @param contours Path of the polygon
  46185. * @param scene scene to add to
  46186. * @param earcutInjection can be used to inject your own earcut reference
  46187. */
  46188. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  46189. /**
  46190. * Adds a whole within the polygon
  46191. * @param hole Array of points defining the hole
  46192. * @returns this
  46193. */
  46194. addHole(hole: Vector2[]): PolygonMeshBuilder;
  46195. /**
  46196. * Creates the polygon
  46197. * @param updatable If the mesh should be updatable
  46198. * @param depth The depth of the mesh created
  46199. * @returns the created mesh
  46200. */
  46201. build(updatable?: boolean, depth?: number): Mesh;
  46202. /**
  46203. * Adds a side to the polygon
  46204. * @param positions points that make the polygon
  46205. * @param normals normals of the polygon
  46206. * @param uvs uvs of the polygon
  46207. * @param indices indices of the polygon
  46208. * @param bounds bounds of the polygon
  46209. * @param points points of the polygon
  46210. * @param depth depth of the polygon
  46211. * @param flip flip of the polygon
  46212. */
  46213. private addSide;
  46214. }
  46215. }
  46216. declare module BABYLON {
  46217. /**
  46218. * Class containing static functions to help procedurally build meshes
  46219. */
  46220. export class PolygonBuilder {
  46221. /**
  46222. * Creates a polygon mesh
  46223. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  46224. * * 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
  46225. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  46226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46227. * * 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)
  46228. * * Remember you can only change the shape positions, not their number when updating a polygon
  46229. * @param name defines the name of the mesh
  46230. * @param options defines the options used to create the mesh
  46231. * @param scene defines the hosting scene
  46232. * @param earcutInjection can be used to inject your own earcut reference
  46233. * @returns the polygon mesh
  46234. */
  46235. static CreatePolygon(name: string, options: {
  46236. shape: Vector3[];
  46237. holes?: Vector3[][];
  46238. depth?: number;
  46239. faceUV?: Vector4[];
  46240. faceColors?: Color4[];
  46241. updatable?: boolean;
  46242. sideOrientation?: number;
  46243. frontUVs?: Vector4;
  46244. backUVs?: Vector4;
  46245. }, scene: Scene, earcutInjection?: any): Mesh;
  46246. /**
  46247. * Creates an extruded polygon mesh, with depth in the Y direction.
  46248. * * 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)
  46249. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46250. * @param name defines the name of the mesh
  46251. * @param options defines the options used to create the mesh
  46252. * @param scene defines the hosting scene
  46253. * @param earcutInjection can be used to inject your own earcut reference
  46254. * @returns the polygon mesh
  46255. */
  46256. static ExtrudePolygon(name: string, options: {
  46257. shape: Vector3[];
  46258. holes?: Vector3[][];
  46259. depth?: number;
  46260. faceUV?: Vector4[];
  46261. faceColors?: Color4[];
  46262. updatable?: boolean;
  46263. sideOrientation?: number;
  46264. frontUVs?: Vector4;
  46265. backUVs?: Vector4;
  46266. }, scene: Scene, earcutInjection?: any): Mesh;
  46267. }
  46268. }
  46269. declare module BABYLON {
  46270. /**
  46271. * Class containing static functions to help procedurally build meshes
  46272. */
  46273. export class ShapeBuilder {
  46274. /**
  46275. * 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.
  46276. * * 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.
  46277. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46278. * * 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.
  46279. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  46280. * * 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
  46281. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  46282. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  46283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46284. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46285. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  46286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46287. * @param name defines the name of the mesh
  46288. * @param options defines the options used to create the mesh
  46289. * @param scene defines the hosting scene
  46290. * @returns the extruded shape mesh
  46291. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46293. */
  46294. static ExtrudeShape(name: string, options: {
  46295. shape: Vector3[];
  46296. path: Vector3[];
  46297. scale?: number;
  46298. rotation?: number;
  46299. cap?: number;
  46300. updatable?: boolean;
  46301. sideOrientation?: number;
  46302. frontUVs?: Vector4;
  46303. backUVs?: Vector4;
  46304. instance?: Mesh;
  46305. invertUV?: boolean;
  46306. }, scene?: Nullable<Scene>): Mesh;
  46307. /**
  46308. * Creates an custom extruded shape mesh.
  46309. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  46310. * * 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.
  46311. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46312. * * 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
  46313. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  46314. * * 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
  46315. * * It must returns a float value that will be the scale value applied to the shape on each path point
  46316. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  46317. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  46318. * * 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
  46319. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  46320. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  46321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46322. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46323. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46325. * @param name defines the name of the mesh
  46326. * @param options defines the options used to create the mesh
  46327. * @param scene defines the hosting scene
  46328. * @returns the custom extruded shape mesh
  46329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  46330. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46332. */
  46333. static ExtrudeShapeCustom(name: string, options: {
  46334. shape: Vector3[];
  46335. path: Vector3[];
  46336. scaleFunction?: any;
  46337. rotationFunction?: any;
  46338. ribbonCloseArray?: boolean;
  46339. ribbonClosePath?: boolean;
  46340. cap?: number;
  46341. updatable?: boolean;
  46342. sideOrientation?: number;
  46343. frontUVs?: Vector4;
  46344. backUVs?: Vector4;
  46345. instance?: Mesh;
  46346. invertUV?: boolean;
  46347. }, scene: Scene): Mesh;
  46348. private static _ExtrudeShapeGeneric;
  46349. }
  46350. }
  46351. declare module BABYLON {
  46352. /**
  46353. * Class containing static functions to help procedurally build meshes
  46354. */
  46355. export class LatheBuilder {
  46356. /**
  46357. * Creates lathe mesh.
  46358. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  46359. * * 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
  46360. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  46361. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  46362. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  46363. * * 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
  46364. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  46365. * * 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
  46366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46367. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46368. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46370. * @param name defines the name of the mesh
  46371. * @param options defines the options used to create the mesh
  46372. * @param scene defines the hosting scene
  46373. * @returns the lathe mesh
  46374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  46375. */
  46376. static CreateLathe(name: string, options: {
  46377. shape: Vector3[];
  46378. radius?: number;
  46379. tessellation?: number;
  46380. clip?: number;
  46381. arc?: number;
  46382. closed?: boolean;
  46383. updatable?: boolean;
  46384. sideOrientation?: number;
  46385. frontUVs?: Vector4;
  46386. backUVs?: Vector4;
  46387. cap?: number;
  46388. invertUV?: boolean;
  46389. }, scene: Scene): Mesh;
  46390. }
  46391. }
  46392. declare module BABYLON {
  46393. /**
  46394. * Class containing static functions to help procedurally build meshes
  46395. */
  46396. export class TubeBuilder {
  46397. /**
  46398. * Creates a tube mesh.
  46399. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  46400. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  46401. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  46402. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  46403. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  46404. * * 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)
  46405. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  46406. * * 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
  46407. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  46408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46409. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46412. * @param name defines the name of the mesh
  46413. * @param options defines the options used to create the mesh
  46414. * @param scene defines the hosting scene
  46415. * @returns the tube mesh
  46416. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46417. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  46418. */
  46419. static CreateTube(name: string, options: {
  46420. path: Vector3[];
  46421. radius?: number;
  46422. tessellation?: number;
  46423. radiusFunction?: {
  46424. (i: number, distance: number): number;
  46425. };
  46426. cap?: number;
  46427. arc?: number;
  46428. updatable?: boolean;
  46429. sideOrientation?: number;
  46430. frontUVs?: Vector4;
  46431. backUVs?: Vector4;
  46432. instance?: Mesh;
  46433. invertUV?: boolean;
  46434. }, scene: Scene): Mesh;
  46435. }
  46436. }
  46437. declare module BABYLON {
  46438. /**
  46439. * Class containing static functions to help procedurally build meshes
  46440. */
  46441. export class IcoSphereBuilder {
  46442. /**
  46443. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  46444. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  46445. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  46446. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  46447. * * 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
  46448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46449. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46451. * @param name defines the name of the mesh
  46452. * @param options defines the options used to create the mesh
  46453. * @param scene defines the hosting scene
  46454. * @returns the icosahedron mesh
  46455. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  46456. */
  46457. static CreateIcoSphere(name: string, options: {
  46458. radius?: number;
  46459. radiusX?: number;
  46460. radiusY?: number;
  46461. radiusZ?: number;
  46462. flat?: boolean;
  46463. subdivisions?: number;
  46464. sideOrientation?: number;
  46465. frontUVs?: Vector4;
  46466. backUVs?: Vector4;
  46467. updatable?: boolean;
  46468. }, scene: Scene): Mesh;
  46469. }
  46470. }
  46471. declare module BABYLON {
  46472. /**
  46473. * Class containing static functions to help procedurally build meshes
  46474. */
  46475. export class DecalBuilder {
  46476. /**
  46477. * Creates a decal mesh.
  46478. * 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
  46479. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  46480. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  46481. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  46482. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  46483. * @param name defines the name of the mesh
  46484. * @param sourceMesh defines the mesh where the decal must be applied
  46485. * @param options defines the options used to create the mesh
  46486. * @param scene defines the hosting scene
  46487. * @returns the decal mesh
  46488. * @see https://doc.babylonjs.com/how_to/decals
  46489. */
  46490. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  46491. position?: Vector3;
  46492. normal?: Vector3;
  46493. size?: Vector3;
  46494. angle?: number;
  46495. }): Mesh;
  46496. }
  46497. }
  46498. declare module BABYLON {
  46499. /**
  46500. * Class containing static functions to help procedurally build meshes
  46501. */
  46502. export class MeshBuilder {
  46503. /**
  46504. * Creates a box mesh
  46505. * * The parameter `size` sets the size (float) of each box side (default 1)
  46506. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46507. * * 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)
  46508. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46510. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46512. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46513. * @param name defines the name of the mesh
  46514. * @param options defines the options used to create the mesh
  46515. * @param scene defines the hosting scene
  46516. * @returns the box mesh
  46517. */
  46518. static CreateBox(name: string, options: {
  46519. size?: number;
  46520. width?: number;
  46521. height?: number;
  46522. depth?: number;
  46523. faceUV?: Vector4[];
  46524. faceColors?: Color4[];
  46525. sideOrientation?: number;
  46526. frontUVs?: Vector4;
  46527. backUVs?: Vector4;
  46528. updatable?: boolean;
  46529. }, scene?: Nullable<Scene>): Mesh;
  46530. /**
  46531. * Creates a sphere mesh
  46532. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46533. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  46534. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46535. * * 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
  46536. * * 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)
  46537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46538. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46540. * @param name defines the name of the mesh
  46541. * @param options defines the options used to create the mesh
  46542. * @param scene defines the hosting scene
  46543. * @returns the sphere mesh
  46544. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46545. */
  46546. static CreateSphere(name: string, options: {
  46547. segments?: number;
  46548. diameter?: number;
  46549. diameterX?: number;
  46550. diameterY?: number;
  46551. diameterZ?: number;
  46552. arc?: number;
  46553. slice?: number;
  46554. sideOrientation?: number;
  46555. frontUVs?: Vector4;
  46556. backUVs?: Vector4;
  46557. updatable?: boolean;
  46558. }, scene: any): Mesh;
  46559. /**
  46560. * Creates a plane polygonal mesh. By default, this is a disc
  46561. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  46562. * * 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
  46563. * * 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
  46564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46565. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46567. * @param name defines the name of the mesh
  46568. * @param options defines the options used to create the mesh
  46569. * @param scene defines the hosting scene
  46570. * @returns the plane polygonal mesh
  46571. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  46572. */
  46573. static CreateDisc(name: string, options: {
  46574. radius?: number;
  46575. tessellation?: number;
  46576. arc?: number;
  46577. updatable?: boolean;
  46578. sideOrientation?: number;
  46579. frontUVs?: Vector4;
  46580. backUVs?: Vector4;
  46581. }, scene?: Nullable<Scene>): Mesh;
  46582. /**
  46583. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  46584. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  46585. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  46586. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  46587. * * 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
  46588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46589. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46591. * @param name defines the name of the mesh
  46592. * @param options defines the options used to create the mesh
  46593. * @param scene defines the hosting scene
  46594. * @returns the icosahedron mesh
  46595. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  46596. */
  46597. static CreateIcoSphere(name: string, options: {
  46598. radius?: number;
  46599. radiusX?: number;
  46600. radiusY?: number;
  46601. radiusZ?: number;
  46602. flat?: boolean;
  46603. subdivisions?: number;
  46604. sideOrientation?: number;
  46605. frontUVs?: Vector4;
  46606. backUVs?: Vector4;
  46607. updatable?: boolean;
  46608. }, scene: Scene): Mesh;
  46609. /**
  46610. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  46611. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  46612. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  46613. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  46614. * * 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
  46615. * * 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
  46616. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  46617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46618. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46619. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46620. * * 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
  46621. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  46622. * * 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
  46623. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  46624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46625. * @param name defines the name of the mesh
  46626. * @param options defines the options used to create the mesh
  46627. * @param scene defines the hosting scene
  46628. * @returns the ribbon mesh
  46629. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  46630. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46631. */
  46632. static CreateRibbon(name: string, options: {
  46633. pathArray: Vector3[][];
  46634. closeArray?: boolean;
  46635. closePath?: boolean;
  46636. offset?: number;
  46637. updatable?: boolean;
  46638. sideOrientation?: number;
  46639. frontUVs?: Vector4;
  46640. backUVs?: Vector4;
  46641. instance?: Mesh;
  46642. invertUV?: boolean;
  46643. uvs?: Vector2[];
  46644. colors?: Color4[];
  46645. }, scene?: Nullable<Scene>): Mesh;
  46646. /**
  46647. * Creates a cylinder or a cone mesh
  46648. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46649. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46650. * * 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.
  46651. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46652. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46653. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46654. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46655. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46656. * * 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).
  46657. * * 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
  46658. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46659. * * 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
  46660. * * 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.
  46661. * * If `enclose` is false, a ring surface is one element.
  46662. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46663. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  46664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46665. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46667. * @param name defines the name of the mesh
  46668. * @param options defines the options used to create the mesh
  46669. * @param scene defines the hosting scene
  46670. * @returns the cylinder mesh
  46671. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46672. */
  46673. static CreateCylinder(name: string, options: {
  46674. height?: number;
  46675. diameterTop?: number;
  46676. diameterBottom?: number;
  46677. diameter?: number;
  46678. tessellation?: number;
  46679. subdivisions?: number;
  46680. arc?: number;
  46681. faceColors?: Color4[];
  46682. faceUV?: Vector4[];
  46683. updatable?: boolean;
  46684. hasRings?: boolean;
  46685. enclose?: boolean;
  46686. sideOrientation?: number;
  46687. frontUVs?: Vector4;
  46688. backUVs?: Vector4;
  46689. }, scene: any): Mesh;
  46690. /**
  46691. * Creates a torus mesh
  46692. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46693. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46694. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46696. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46698. * @param name defines the name of the mesh
  46699. * @param options defines the options used to create the mesh
  46700. * @param scene defines the hosting scene
  46701. * @returns the torus mesh
  46702. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46703. */
  46704. static CreateTorus(name: string, options: {
  46705. diameter?: number;
  46706. thickness?: number;
  46707. tessellation?: number;
  46708. updatable?: boolean;
  46709. sideOrientation?: number;
  46710. frontUVs?: Vector4;
  46711. backUVs?: Vector4;
  46712. }, scene: any): Mesh;
  46713. /**
  46714. * Creates a torus knot mesh
  46715. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  46716. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  46717. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  46718. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  46719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46720. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46722. * @param name defines the name of the mesh
  46723. * @param options defines the options used to create the mesh
  46724. * @param scene defines the hosting scene
  46725. * @returns the torus knot mesh
  46726. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  46727. */
  46728. static CreateTorusKnot(name: string, options: {
  46729. radius?: number;
  46730. tube?: number;
  46731. radialSegments?: number;
  46732. tubularSegments?: number;
  46733. p?: number;
  46734. q?: number;
  46735. updatable?: boolean;
  46736. sideOrientation?: number;
  46737. frontUVs?: Vector4;
  46738. backUVs?: Vector4;
  46739. }, scene: any): Mesh;
  46740. /**
  46741. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46742. * * 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
  46743. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46744. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46745. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46746. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46747. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46748. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  46749. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46752. * @param name defines the name of the new line system
  46753. * @param options defines the options used to create the line system
  46754. * @param scene defines the hosting scene
  46755. * @returns a new line system mesh
  46756. */
  46757. static CreateLineSystem(name: string, options: {
  46758. lines: Vector3[][];
  46759. updatable?: boolean;
  46760. instance?: Nullable<LinesMesh>;
  46761. colors?: Nullable<Color4[][]>;
  46762. useVertexAlpha?: boolean;
  46763. }, scene: Nullable<Scene>): LinesMesh;
  46764. /**
  46765. * Creates a line mesh
  46766. * 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
  46767. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46768. * * The parameter `points` is an array successive Vector3
  46769. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  46770. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46771. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46772. * * When updating an instance, remember that only point positions can change, not the number of points
  46773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46775. * @param name defines the name of the new line system
  46776. * @param options defines the options used to create the line system
  46777. * @param scene defines the hosting scene
  46778. * @returns a new line mesh
  46779. */
  46780. static CreateLines(name: string, options: {
  46781. points: Vector3[];
  46782. updatable?: boolean;
  46783. instance?: Nullable<LinesMesh>;
  46784. colors?: Color4[];
  46785. useVertexAlpha?: boolean;
  46786. }, scene?: Nullable<Scene>): LinesMesh;
  46787. /**
  46788. * Creates a dashed line mesh
  46789. * * 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
  46790. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46791. * * The parameter `points` is an array successive Vector3
  46792. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46793. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46794. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46795. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  46796. * * When updating an instance, remember that only point positions can change, not the number of points
  46797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46798. * @param name defines the name of the mesh
  46799. * @param options defines the options used to create the mesh
  46800. * @param scene defines the hosting scene
  46801. * @returns the dashed line mesh
  46802. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46803. */
  46804. static CreateDashedLines(name: string, options: {
  46805. points: Vector3[];
  46806. dashSize?: number;
  46807. gapSize?: number;
  46808. dashNb?: number;
  46809. updatable?: boolean;
  46810. instance?: LinesMesh;
  46811. }, scene?: Nullable<Scene>): LinesMesh;
  46812. /**
  46813. * 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.
  46814. * * 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.
  46815. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46816. * * 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.
  46817. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  46818. * * 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
  46819. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  46820. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  46821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46822. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46823. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  46824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46825. * @param name defines the name of the mesh
  46826. * @param options defines the options used to create the mesh
  46827. * @param scene defines the hosting scene
  46828. * @returns the extruded shape mesh
  46829. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46831. */
  46832. static ExtrudeShape(name: string, options: {
  46833. shape: Vector3[];
  46834. path: Vector3[];
  46835. scale?: number;
  46836. rotation?: number;
  46837. cap?: number;
  46838. updatable?: boolean;
  46839. sideOrientation?: number;
  46840. frontUVs?: Vector4;
  46841. backUVs?: Vector4;
  46842. instance?: Mesh;
  46843. invertUV?: boolean;
  46844. }, scene?: Nullable<Scene>): Mesh;
  46845. /**
  46846. * Creates an custom extruded shape mesh.
  46847. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  46848. * * 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.
  46849. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46850. * * 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
  46851. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  46852. * * 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
  46853. * * It must returns a float value that will be the scale value applied to the shape on each path point
  46854. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  46855. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  46856. * * 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
  46857. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  46858. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  46859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46860. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46861. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46863. * @param name defines the name of the mesh
  46864. * @param options defines the options used to create the mesh
  46865. * @param scene defines the hosting scene
  46866. * @returns the custom extruded shape mesh
  46867. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  46868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46870. */
  46871. static ExtrudeShapeCustom(name: string, options: {
  46872. shape: Vector3[];
  46873. path: Vector3[];
  46874. scaleFunction?: any;
  46875. rotationFunction?: any;
  46876. ribbonCloseArray?: boolean;
  46877. ribbonClosePath?: boolean;
  46878. cap?: number;
  46879. updatable?: boolean;
  46880. sideOrientation?: number;
  46881. frontUVs?: Vector4;
  46882. backUVs?: Vector4;
  46883. instance?: Mesh;
  46884. invertUV?: boolean;
  46885. }, scene: Scene): Mesh;
  46886. /**
  46887. * Creates lathe mesh.
  46888. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  46889. * * 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
  46890. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  46891. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  46892. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  46893. * * 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
  46894. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  46895. * * 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
  46896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46897. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46898. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46900. * @param name defines the name of the mesh
  46901. * @param options defines the options used to create the mesh
  46902. * @param scene defines the hosting scene
  46903. * @returns the lathe mesh
  46904. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  46905. */
  46906. static CreateLathe(name: string, options: {
  46907. shape: Vector3[];
  46908. radius?: number;
  46909. tessellation?: number;
  46910. clip?: number;
  46911. arc?: number;
  46912. closed?: boolean;
  46913. updatable?: boolean;
  46914. sideOrientation?: number;
  46915. frontUVs?: Vector4;
  46916. backUVs?: Vector4;
  46917. cap?: number;
  46918. invertUV?: boolean;
  46919. }, scene: Scene): Mesh;
  46920. /**
  46921. * Creates a plane mesh
  46922. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46923. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46924. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46926. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46928. * @param name defines the name of the mesh
  46929. * @param options defines the options used to create the mesh
  46930. * @param scene defines the hosting scene
  46931. * @returns the plane mesh
  46932. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46933. */
  46934. static CreatePlane(name: string, options: {
  46935. size?: number;
  46936. width?: number;
  46937. height?: number;
  46938. sideOrientation?: number;
  46939. frontUVs?: Vector4;
  46940. backUVs?: Vector4;
  46941. updatable?: boolean;
  46942. sourcePlane?: Plane;
  46943. }, scene: Scene): Mesh;
  46944. /**
  46945. * Creates a ground mesh
  46946. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46947. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46949. * @param name defines the name of the mesh
  46950. * @param options defines the options used to create the mesh
  46951. * @param scene defines the hosting scene
  46952. * @returns the ground mesh
  46953. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46954. */
  46955. static CreateGround(name: string, options: {
  46956. width?: number;
  46957. height?: number;
  46958. subdivisions?: number;
  46959. subdivisionsX?: number;
  46960. subdivisionsY?: number;
  46961. updatable?: boolean;
  46962. }, scene: any): Mesh;
  46963. /**
  46964. * Creates a tiled ground mesh
  46965. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46966. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46967. * * 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
  46968. * * 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
  46969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46970. * @param name defines the name of the mesh
  46971. * @param options defines the options used to create the mesh
  46972. * @param scene defines the hosting scene
  46973. * @returns the tiled ground mesh
  46974. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46975. */
  46976. static CreateTiledGround(name: string, options: {
  46977. xmin: number;
  46978. zmin: number;
  46979. xmax: number;
  46980. zmax: number;
  46981. subdivisions?: {
  46982. w: number;
  46983. h: number;
  46984. };
  46985. precision?: {
  46986. w: number;
  46987. h: number;
  46988. };
  46989. updatable?: boolean;
  46990. }, scene: Scene): Mesh;
  46991. /**
  46992. * Creates a ground mesh from a height map
  46993. * * The parameter `url` sets the URL of the height map image resource.
  46994. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46995. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46996. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46997. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46998. * * 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.
  46999. * * 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).
  47000. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47002. * @param name defines the name of the mesh
  47003. * @param url defines the url to the height map
  47004. * @param options defines the options used to create the mesh
  47005. * @param scene defines the hosting scene
  47006. * @returns the ground mesh
  47007. * @see https://doc.babylonjs.com/babylon101/height_map
  47008. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47009. */
  47010. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47011. width?: number;
  47012. height?: number;
  47013. subdivisions?: number;
  47014. minHeight?: number;
  47015. maxHeight?: number;
  47016. colorFilter?: Color3;
  47017. alphaFilter?: number;
  47018. updatable?: boolean;
  47019. onReady?: (mesh: GroundMesh) => void;
  47020. }, scene: Scene): GroundMesh;
  47021. /**
  47022. * Creates a polygon mesh
  47023. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  47024. * * 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
  47025. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  47026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47027. * * 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)
  47028. * * Remember you can only change the shape positions, not their number when updating a polygon
  47029. * @param name defines the name of the mesh
  47030. * @param options defines the options used to create the mesh
  47031. * @param scene defines the hosting scene
  47032. * @param earcutInjection can be used to inject your own earcut reference
  47033. * @returns the polygon mesh
  47034. */
  47035. static CreatePolygon(name: string, options: {
  47036. shape: Vector3[];
  47037. holes?: Vector3[][];
  47038. depth?: number;
  47039. faceUV?: Vector4[];
  47040. faceColors?: Color4[];
  47041. updatable?: boolean;
  47042. sideOrientation?: number;
  47043. frontUVs?: Vector4;
  47044. backUVs?: Vector4;
  47045. }, scene: Scene, earcutInjection?: any): Mesh;
  47046. /**
  47047. * Creates an extruded polygon mesh, with depth in the Y direction.
  47048. * * 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)
  47049. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47050. * @param name defines the name of the mesh
  47051. * @param options defines the options used to create the mesh
  47052. * @param scene defines the hosting scene
  47053. * @param earcutInjection can be used to inject your own earcut reference
  47054. * @returns the polygon mesh
  47055. */
  47056. static ExtrudePolygon(name: string, options: {
  47057. shape: Vector3[];
  47058. holes?: Vector3[][];
  47059. depth?: number;
  47060. faceUV?: Vector4[];
  47061. faceColors?: Color4[];
  47062. updatable?: boolean;
  47063. sideOrientation?: number;
  47064. frontUVs?: Vector4;
  47065. backUVs?: Vector4;
  47066. }, scene: Scene, earcutInjection?: any): Mesh;
  47067. /**
  47068. * Creates a tube mesh.
  47069. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47070. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  47071. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  47072. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  47073. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  47074. * * 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)
  47075. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  47076. * * 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
  47077. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  47078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47079. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47080. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47082. * @param name defines the name of the mesh
  47083. * @param options defines the options used to create the mesh
  47084. * @param scene defines the hosting scene
  47085. * @returns the tube mesh
  47086. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47087. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  47088. */
  47089. static CreateTube(name: string, options: {
  47090. path: Vector3[];
  47091. radius?: number;
  47092. tessellation?: number;
  47093. radiusFunction?: {
  47094. (i: number, distance: number): number;
  47095. };
  47096. cap?: number;
  47097. arc?: number;
  47098. updatable?: boolean;
  47099. sideOrientation?: number;
  47100. frontUVs?: Vector4;
  47101. backUVs?: Vector4;
  47102. instance?: Mesh;
  47103. invertUV?: boolean;
  47104. }, scene: Scene): Mesh;
  47105. /**
  47106. * Creates a polyhedron mesh
  47107. * * 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
  47108. * * The parameter `size` (positive float, default 1) sets the polygon size
  47109. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47110. * * 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`
  47111. * * 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
  47112. * * 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)`)
  47113. * * 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 : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47114. * * 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
  47115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47116. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47118. * @param name defines the name of the mesh
  47119. * @param options defines the options used to create the mesh
  47120. * @param scene defines the hosting scene
  47121. * @returns the polyhedron mesh
  47122. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47123. */
  47124. static CreatePolyhedron(name: string, options: {
  47125. type?: number;
  47126. size?: number;
  47127. sizeX?: number;
  47128. sizeY?: number;
  47129. sizeZ?: number;
  47130. custom?: any;
  47131. faceUV?: Vector4[];
  47132. faceColors?: Color4[];
  47133. flat?: boolean;
  47134. updatable?: boolean;
  47135. sideOrientation?: number;
  47136. frontUVs?: Vector4;
  47137. backUVs?: Vector4;
  47138. }, scene: Scene): Mesh;
  47139. /**
  47140. * Creates a decal mesh.
  47141. * 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
  47142. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  47143. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  47144. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  47145. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  47146. * @param name defines the name of the mesh
  47147. * @param sourceMesh defines the mesh where the decal must be applied
  47148. * @param options defines the options used to create the mesh
  47149. * @param scene defines the hosting scene
  47150. * @returns the decal mesh
  47151. * @see https://doc.babylonjs.com/how_to/decals
  47152. */
  47153. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  47154. position?: Vector3;
  47155. normal?: Vector3;
  47156. size?: Vector3;
  47157. angle?: number;
  47158. }): Mesh;
  47159. }
  47160. }
  47161. declare module BABYLON {
  47162. /**
  47163. * A simplifier interface for future simplification implementations
  47164. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47165. */
  47166. export interface ISimplifier {
  47167. /**
  47168. * Simplification of a given mesh according to the given settings.
  47169. * Since this requires computation, it is assumed that the function runs async.
  47170. * @param settings The settings of the simplification, including quality and distance
  47171. * @param successCallback A callback that will be called after the mesh was simplified.
  47172. * @param errorCallback in case of an error, this callback will be called. optional.
  47173. */
  47174. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  47175. }
  47176. /**
  47177. * Expected simplification settings.
  47178. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  47179. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47180. */
  47181. export interface ISimplificationSettings {
  47182. /**
  47183. * Gets or sets the expected quality
  47184. */
  47185. quality: number;
  47186. /**
  47187. * Gets or sets the distance when this optimized version should be used
  47188. */
  47189. distance: number;
  47190. /**
  47191. * Gets an already optimized mesh
  47192. */
  47193. optimizeMesh?: boolean;
  47194. }
  47195. /**
  47196. * Class used to specify simplification options
  47197. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47198. */
  47199. export class SimplificationSettings implements ISimplificationSettings {
  47200. /** expected quality */
  47201. quality: number;
  47202. /** distance when this optimized version should be used */
  47203. distance: number;
  47204. /** already optimized mesh */
  47205. optimizeMesh?: boolean | undefined;
  47206. /**
  47207. * Creates a SimplificationSettings
  47208. * @param quality expected quality
  47209. * @param distance distance when this optimized version should be used
  47210. * @param optimizeMesh already optimized mesh
  47211. */
  47212. constructor(
  47213. /** expected quality */
  47214. quality: number,
  47215. /** distance when this optimized version should be used */
  47216. distance: number,
  47217. /** already optimized mesh */
  47218. optimizeMesh?: boolean | undefined);
  47219. }
  47220. /**
  47221. * Interface used to define a simplification task
  47222. */
  47223. export interface ISimplificationTask {
  47224. /**
  47225. * Array of settings
  47226. */
  47227. settings: Array<ISimplificationSettings>;
  47228. /**
  47229. * Simplification type
  47230. */
  47231. simplificationType: SimplificationType;
  47232. /**
  47233. * Mesh to simplify
  47234. */
  47235. mesh: Mesh;
  47236. /**
  47237. * Callback called on success
  47238. */
  47239. successCallback?: () => void;
  47240. /**
  47241. * Defines if parallel processing can be used
  47242. */
  47243. parallelProcessing: boolean;
  47244. }
  47245. /**
  47246. * Queue used to order the simplification tasks
  47247. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47248. */
  47249. export class SimplificationQueue {
  47250. private _simplificationArray;
  47251. /**
  47252. * Gets a boolean indicating that the process is still running
  47253. */
  47254. running: boolean;
  47255. /**
  47256. * Creates a new queue
  47257. */
  47258. constructor();
  47259. /**
  47260. * Adds a new simplification task
  47261. * @param task defines a task to add
  47262. */
  47263. addTask(task: ISimplificationTask): void;
  47264. /**
  47265. * Execute next task
  47266. */
  47267. executeNext(): void;
  47268. /**
  47269. * Execute a simplification task
  47270. * @param task defines the task to run
  47271. */
  47272. runSimplification(task: ISimplificationTask): void;
  47273. private getSimplifier;
  47274. }
  47275. /**
  47276. * The implemented types of simplification
  47277. * At the moment only Quadratic Error Decimation is implemented
  47278. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47279. */
  47280. export enum SimplificationType {
  47281. /** Quadratic error decimation */
  47282. QUADRATIC = 0
  47283. }
  47284. }
  47285. declare module BABYLON {
  47286. interface Scene {
  47287. /** @hidden (Backing field) */ simplificationQueue: SimplificationQueue;
  47288. /**
  47289. * Gets or sets the simplification queue attached to the scene
  47290. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47291. */
  47292. simplificationQueue: SimplificationQueue;
  47293. }
  47294. interface Mesh {
  47295. /**
  47296. * Simplify the mesh according to the given array of settings.
  47297. * Function will return immediately and will simplify async
  47298. * @param settings a collection of simplification settings
  47299. * @param parallelProcessing should all levels calculate parallel or one after the other
  47300. * @param simplificationType the type of simplification to run
  47301. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  47302. * @returns the current mesh
  47303. */
  47304. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  47305. }
  47306. /**
  47307. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  47308. * created in a scene
  47309. */
  47310. export class SimplicationQueueSceneComponent implements ISceneComponent {
  47311. /**
  47312. * The component name helpfull to identify the component in the list of scene components.
  47313. */
  47314. readonly name: string;
  47315. /**
  47316. * The scene the component belongs to.
  47317. */
  47318. scene: Scene;
  47319. /**
  47320. * Creates a new instance of the component for the given scene
  47321. * @param scene Defines the scene to register the component in
  47322. */
  47323. constructor(scene: Scene);
  47324. /**
  47325. * Registers the component in a given scene
  47326. */
  47327. register(): void;
  47328. /**
  47329. * Rebuilds the elements related to this component in case of
  47330. * context lost for instance.
  47331. */
  47332. rebuild(): void;
  47333. /**
  47334. * Disposes the component and the associated ressources
  47335. */
  47336. dispose(): void;
  47337. private _beforeCameraUpdate;
  47338. }
  47339. }
  47340. declare module BABYLON {
  47341. /**
  47342. * Class used to enable access to IndexedDB
  47343. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  47344. */
  47345. export class Database implements IOfflineProvider {
  47346. private _callbackManifestChecked;
  47347. private _currentSceneUrl;
  47348. private _db;
  47349. private _enableSceneOffline;
  47350. private _enableTexturesOffline;
  47351. private _manifestVersionFound;
  47352. private _mustUpdateRessources;
  47353. private _hasReachedQuota;
  47354. private _isSupported;
  47355. private _idbFactory;
  47356. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  47357. private static IsUASupportingBlobStorage;
  47358. /**
  47359. * Gets a boolean indicating if Database storate is enabled (off by default)
  47360. */
  47361. static IDBStorageEnabled: boolean;
  47362. /**
  47363. * Gets a boolean indicating if scene must be saved in the database
  47364. */
  47365. readonly enableSceneOffline: boolean;
  47366. /**
  47367. * Gets a boolean indicating if textures must be saved in the database
  47368. */
  47369. readonly enableTexturesOffline: boolean;
  47370. /**
  47371. * Creates a new Database
  47372. * @param urlToScene defines the url to load the scene
  47373. * @param callbackManifestChecked defines the callback to use when manifest is checked
  47374. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  47375. */
  47376. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  47377. private static _ParseURL;
  47378. private static _ReturnFullUrlLocation;
  47379. private _checkManifestFile;
  47380. /**
  47381. * Open the database and make it available
  47382. * @param successCallback defines the callback to call on success
  47383. * @param errorCallback defines the callback to call on error
  47384. */
  47385. open(successCallback: () => void, errorCallback: () => void): void;
  47386. /**
  47387. * Loads an image from the database
  47388. * @param url defines the url to load from
  47389. * @param image defines the target DOM image
  47390. */
  47391. loadImage(url: string, image: HTMLImageElement): void;
  47392. private _loadImageFromDBAsync;
  47393. private _saveImageIntoDBAsync;
  47394. private _checkVersionFromDB;
  47395. private _loadVersionFromDBAsync;
  47396. private _saveVersionIntoDBAsync;
  47397. /**
  47398. * Loads a file from database
  47399. * @param url defines the URL to load from
  47400. * @param sceneLoaded defines a callback to call on success
  47401. * @param progressCallBack defines a callback to call when progress changed
  47402. * @param errorCallback defines a callback to call on error
  47403. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  47404. */
  47405. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  47406. private _loadFileAsync;
  47407. private _saveFileAsync;
  47408. /**
  47409. * Validates if xhr data is correct
  47410. * @param xhr defines the request to validate
  47411. * @param dataType defines the expected data type
  47412. * @returns true if data is correct
  47413. */
  47414. private static _ValidateXHRData;
  47415. }
  47416. }
  47417. declare module BABYLON {
  47418. /** @hidden */
  47419. export var gpuUpdateParticlesPixelShader: {
  47420. name: string;
  47421. shader: string;
  47422. };
  47423. }
  47424. declare module BABYLON {
  47425. /** @hidden */
  47426. export var gpuUpdateParticlesVertexShader: {
  47427. name: string;
  47428. shader: string;
  47429. };
  47430. }
  47431. declare module BABYLON {
  47432. /** @hidden */
  47433. export var clipPlaneFragmentDeclaration2: {
  47434. name: string;
  47435. shader: string;
  47436. };
  47437. }
  47438. declare module BABYLON {
  47439. /** @hidden */
  47440. export var gpuRenderParticlesPixelShader: {
  47441. name: string;
  47442. shader: string;
  47443. };
  47444. }
  47445. declare module BABYLON {
  47446. /** @hidden */
  47447. export var clipPlaneVertexDeclaration2: {
  47448. name: string;
  47449. shader: string;
  47450. };
  47451. }
  47452. declare module BABYLON {
  47453. /** @hidden */
  47454. export var gpuRenderParticlesVertexShader: {
  47455. name: string;
  47456. shader: string;
  47457. };
  47458. }
  47459. declare module BABYLON {
  47460. /**
  47461. * This represents a GPU particle system in Babylon
  47462. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  47463. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  47464. */
  47465. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  47466. /**
  47467. * The layer mask we are rendering the particles through.
  47468. */
  47469. layerMask: number;
  47470. private _capacity;
  47471. private _activeCount;
  47472. private _currentActiveCount;
  47473. private _accumulatedCount;
  47474. private _renderEffect;
  47475. private _updateEffect;
  47476. private _buffer0;
  47477. private _buffer1;
  47478. private _spriteBuffer;
  47479. private _updateVAO;
  47480. private _renderVAO;
  47481. private _targetIndex;
  47482. private _sourceBuffer;
  47483. private _targetBuffer;
  47484. private _engine;
  47485. private _currentRenderId;
  47486. private _started;
  47487. private _stopped;
  47488. private _timeDelta;
  47489. private _randomTexture;
  47490. private _randomTexture2;
  47491. private _attributesStrideSize;
  47492. private _updateEffectOptions;
  47493. private _randomTextureSize;
  47494. private _actualFrame;
  47495. private readonly _rawTextureWidth;
  47496. /**
  47497. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  47498. */
  47499. static readonly IsSupported: boolean;
  47500. /**
  47501. * An event triggered when the system is disposed.
  47502. */
  47503. onDisposeObservable: Observable<GPUParticleSystem>;
  47504. /**
  47505. * Gets the maximum number of particles active at the same time.
  47506. * @returns The max number of active particles.
  47507. */
  47508. getCapacity(): number;
  47509. /**
  47510. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  47511. * to override the particles.
  47512. */
  47513. forceDepthWrite: boolean;
  47514. /**
  47515. * Gets or set the number of active particles
  47516. */
  47517. activeParticleCount: number;
  47518. private _preWarmDone;
  47519. /**
  47520. * Is this system ready to be used/rendered
  47521. * @return true if the system is ready
  47522. */
  47523. isReady(): boolean;
  47524. /**
  47525. * Gets if the system has been started. (Note: this will still be true after stop is called)
  47526. * @returns True if it has been started, otherwise false.
  47527. */
  47528. isStarted(): boolean;
  47529. /**
  47530. * Starts the particle system and begins to emit
  47531. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  47532. */
  47533. start(delay?: number): void;
  47534. /**
  47535. * Stops the particle system.
  47536. */
  47537. stop(): void;
  47538. /**
  47539. * Remove all active particles
  47540. */
  47541. reset(): void;
  47542. /**
  47543. * Returns the string "GPUParticleSystem"
  47544. * @returns a string containing the class name
  47545. */
  47546. getClassName(): string;
  47547. private _colorGradientsTexture;
  47548. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  47549. /**
  47550. * Adds a new color gradient
  47551. * @param gradient defines the gradient to use (between 0 and 1)
  47552. * @param color1 defines the color to affect to the specified gradient
  47553. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  47554. * @returns the current particle system
  47555. */
  47556. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  47557. /**
  47558. * Remove a specific color gradient
  47559. * @param gradient defines the gradient to remove
  47560. * @returns the current particle system
  47561. */
  47562. removeColorGradient(gradient: number): GPUParticleSystem;
  47563. private _angularSpeedGradientsTexture;
  47564. private _sizeGradientsTexture;
  47565. private _velocityGradientsTexture;
  47566. private _limitVelocityGradientsTexture;
  47567. private _dragGradientsTexture;
  47568. private _addFactorGradient;
  47569. /**
  47570. * Adds a new size gradient
  47571. * @param gradient defines the gradient to use (between 0 and 1)
  47572. * @param factor defines the size factor to affect to the specified gradient
  47573. * @returns the current particle system
  47574. */
  47575. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  47576. /**
  47577. * Remove a specific size gradient
  47578. * @param gradient defines the gradient to remove
  47579. * @returns the current particle system
  47580. */
  47581. removeSizeGradient(gradient: number): GPUParticleSystem;
  47582. /**
  47583. * Adds a new angular speed gradient
  47584. * @param gradient defines the gradient to use (between 0 and 1)
  47585. * @param factor defines the angular speed to affect to the specified gradient
  47586. * @returns the current particle system
  47587. */
  47588. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  47589. /**
  47590. * Remove a specific angular speed gradient
  47591. * @param gradient defines the gradient to remove
  47592. * @returns the current particle system
  47593. */
  47594. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  47595. /**
  47596. * Adds a new velocity gradient
  47597. * @param gradient defines the gradient to use (between 0 and 1)
  47598. * @param factor defines the velocity to affect to the specified gradient
  47599. * @returns the current particle system
  47600. */
  47601. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  47602. /**
  47603. * Remove a specific velocity gradient
  47604. * @param gradient defines the gradient to remove
  47605. * @returns the current particle system
  47606. */
  47607. removeVelocityGradient(gradient: number): GPUParticleSystem;
  47608. /**
  47609. * Adds a new limit velocity gradient
  47610. * @param gradient defines the gradient to use (between 0 and 1)
  47611. * @param factor defines the limit velocity value to affect to the specified gradient
  47612. * @returns the current particle system
  47613. */
  47614. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  47615. /**
  47616. * Remove a specific limit velocity gradient
  47617. * @param gradient defines the gradient to remove
  47618. * @returns the current particle system
  47619. */
  47620. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  47621. /**
  47622. * Adds a new drag gradient
  47623. * @param gradient defines the gradient to use (between 0 and 1)
  47624. * @param factor defines the drag value to affect to the specified gradient
  47625. * @returns the current particle system
  47626. */
  47627. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  47628. /**
  47629. * Remove a specific drag gradient
  47630. * @param gradient defines the gradient to remove
  47631. * @returns the current particle system
  47632. */
  47633. removeDragGradient(gradient: number): GPUParticleSystem;
  47634. /**
  47635. * Not supported by GPUParticleSystem
  47636. * @param gradient defines the gradient to use (between 0 and 1)
  47637. * @param factor defines the emit rate value to affect to the specified gradient
  47638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47639. * @returns the current particle system
  47640. */
  47641. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47642. /**
  47643. * Not supported by GPUParticleSystem
  47644. * @param gradient defines the gradient to remove
  47645. * @returns the current particle system
  47646. */
  47647. removeEmitRateGradient(gradient: number): IParticleSystem;
  47648. /**
  47649. * Not supported by GPUParticleSystem
  47650. * @param gradient defines the gradient to use (between 0 and 1)
  47651. * @param factor defines the start size value to affect to the specified gradient
  47652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47653. * @returns the current particle system
  47654. */
  47655. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47656. /**
  47657. * Not supported by GPUParticleSystem
  47658. * @param gradient defines the gradient to remove
  47659. * @returns the current particle system
  47660. */
  47661. removeStartSizeGradient(gradient: number): IParticleSystem;
  47662. /**
  47663. * Not supported by GPUParticleSystem
  47664. * @param gradient defines the gradient to use (between 0 and 1)
  47665. * @param min defines the color remap minimal range
  47666. * @param max defines the color remap maximal range
  47667. * @returns the current particle system
  47668. */
  47669. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  47670. /**
  47671. * Not supported by GPUParticleSystem
  47672. * @param gradient defines the gradient to remove
  47673. * @returns the current particle system
  47674. */
  47675. removeColorRemapGradient(): IParticleSystem;
  47676. /**
  47677. * Not supported by GPUParticleSystem
  47678. * @param gradient defines the gradient to use (between 0 and 1)
  47679. * @param min defines the alpha remap minimal range
  47680. * @param max defines the alpha remap maximal range
  47681. * @returns the current particle system
  47682. */
  47683. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  47684. /**
  47685. * Not supported by GPUParticleSystem
  47686. * @param gradient defines the gradient to remove
  47687. * @returns the current particle system
  47688. */
  47689. removeAlphaRemapGradient(): IParticleSystem;
  47690. /**
  47691. * Not supported by GPUParticleSystem
  47692. * @param gradient defines the gradient to use (between 0 and 1)
  47693. * @param color defines the color to affect to the specified gradient
  47694. * @returns the current particle system
  47695. */
  47696. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  47697. /**
  47698. * Not supported by GPUParticleSystem
  47699. * @param gradient defines the gradient to remove
  47700. * @returns the current particle system
  47701. */
  47702. removeRampGradient(): IParticleSystem;
  47703. /**
  47704. * Not supported by GPUParticleSystem
  47705. * @returns the list of ramp gradients
  47706. */
  47707. getRampGradients(): Nullable<Array<Color3Gradient>>;
  47708. /**
  47709. * Not supported by GPUParticleSystem
  47710. * Gets or sets a boolean indicating that ramp gradients must be used
  47711. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  47712. */
  47713. useRampGradients: boolean;
  47714. /**
  47715. * Not supported by GPUParticleSystem
  47716. * @param gradient defines the gradient to use (between 0 and 1)
  47717. * @param factor defines the life time factor to affect to the specified gradient
  47718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47719. * @returns the current particle system
  47720. */
  47721. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47722. /**
  47723. * Not supported by GPUParticleSystem
  47724. * @param gradient defines the gradient to remove
  47725. * @returns the current particle system
  47726. */
  47727. removeLifeTimeGradient(gradient: number): IParticleSystem;
  47728. /**
  47729. * Instantiates a GPU particle system.
  47730. * 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.
  47731. * @param name The name of the particle system
  47732. * @param options The options used to create the system
  47733. * @param scene The scene the particle system belongs to
  47734. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  47735. */
  47736. constructor(name: string, options: Partial<{
  47737. capacity: number;
  47738. randomTextureSize: number;
  47739. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  47740. protected _reset(): void;
  47741. private _createUpdateVAO;
  47742. private _createRenderVAO;
  47743. private _initialize;
  47744. /** @hidden */ recreateUpdateEffect(): void;
  47745. /** @hidden */ recreateRenderEffect(): void;
  47746. /**
  47747. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  47748. * @param preWarm defines if we are in the pre-warmimg phase
  47749. */
  47750. animate(preWarm?: boolean): void;
  47751. private _createFactorGradientTexture;
  47752. private _createSizeGradientTexture;
  47753. private _createAngularSpeedGradientTexture;
  47754. private _createVelocityGradientTexture;
  47755. private _createLimitVelocityGradientTexture;
  47756. private _createDragGradientTexture;
  47757. private _createColorGradientTexture;
  47758. /**
  47759. * Renders the particle system in its current state
  47760. * @param preWarm defines if the system should only update the particles but not render them
  47761. * @returns the current number of particles
  47762. */
  47763. render(preWarm?: boolean): number;
  47764. /**
  47765. * Rebuilds the particle system
  47766. */
  47767. rebuild(): void;
  47768. private _releaseBuffers;
  47769. private _releaseVAOs;
  47770. /**
  47771. * Disposes the particle system and free the associated resources
  47772. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  47773. */
  47774. dispose(disposeTexture?: boolean): void;
  47775. /**
  47776. * Clones the particle system.
  47777. * @param name The name of the cloned object
  47778. * @param newEmitter The new emitter to use
  47779. * @returns the cloned particle system
  47780. */
  47781. clone(name: string, newEmitter: any): GPUParticleSystem;
  47782. /**
  47783. * Serializes the particle system to a JSON object.
  47784. * @returns the JSON object
  47785. */
  47786. serialize(): any;
  47787. /**
  47788. * Parses a JSON object to create a GPU particle system.
  47789. * @param parsedParticleSystem The JSON object to parse
  47790. * @param scene The scene to create the particle system in
  47791. * @param rootUrl The root url to use to load external dependencies like texture
  47792. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  47793. * @returns the parsed GPU particle system
  47794. */
  47795. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  47796. }
  47797. }
  47798. declare module BABYLON {
  47799. /**
  47800. * Represents a set of particle systems working together to create a specific effect
  47801. */
  47802. export class ParticleSystemSet implements IDisposable {
  47803. private _emitterCreationOptions;
  47804. private _emitterNode;
  47805. /**
  47806. * Gets the particle system list
  47807. */
  47808. systems: IParticleSystem[];
  47809. /**
  47810. * Gets the emitter node used with this set
  47811. */
  47812. readonly emitterNode: Nullable<TransformNode>;
  47813. /**
  47814. * Creates a new emitter mesh as a sphere
  47815. * @param options defines the options used to create the sphere
  47816. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  47817. * @param scene defines the hosting scene
  47818. */
  47819. setEmitterAsSphere(options: {
  47820. diameter: number;
  47821. segments: number;
  47822. color: Color3;
  47823. }, renderingGroupId: number, scene: Scene): void;
  47824. /**
  47825. * Starts all particle systems of the set
  47826. * @param emitter defines an optional mesh to use as emitter for the particle systems
  47827. */
  47828. start(emitter?: AbstractMesh): void;
  47829. /**
  47830. * Release all associated resources
  47831. */
  47832. dispose(): void;
  47833. /**
  47834. * Serialize the set into a JSON compatible object
  47835. * @returns a JSON compatible representation of the set
  47836. */
  47837. serialize(): any;
  47838. /**
  47839. * Parse a new ParticleSystemSet from a serialized source
  47840. * @param data defines a JSON compatible representation of the set
  47841. * @param scene defines the hosting scene
  47842. * @param gpu defines if we want GPU particles or CPU particles
  47843. * @returns a new ParticleSystemSet
  47844. */
  47845. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  47846. }
  47847. }
  47848. declare module BABYLON {
  47849. /**
  47850. * This class is made for on one-liner static method to help creating particle system set.
  47851. */
  47852. export class ParticleHelper {
  47853. /**
  47854. * Gets or sets base Assets URL
  47855. */
  47856. static BaseAssetsUrl: string;
  47857. /**
  47858. * Create a default particle system that you can tweak
  47859. * @param emitter defines the emitter to use
  47860. * @param capacity defines the system capacity (default is 500 particles)
  47861. * @param scene defines the hosting scene
  47862. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  47863. * @returns the new Particle system
  47864. */
  47865. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  47866. /**
  47867. * This is the main static method (one-liner) of this helper to create different particle systems
  47868. * @param type This string represents the type to the particle system to create
  47869. * @param scene The scene where the particle system should live
  47870. * @param gpu If the system will use gpu
  47871. * @returns the ParticleSystemSet created
  47872. */
  47873. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  47874. /**
  47875. * Static function used to export a particle system to a ParticleSystemSet variable.
  47876. * Please note that the emitter shape is not exported
  47877. * @param systems defines the particle systems to export
  47878. * @returns the created particle system set
  47879. */
  47880. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  47881. }
  47882. }
  47883. declare module BABYLON {
  47884. interface Engine {
  47885. /**
  47886. * Create an effect to use with particle systems.
  47887. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  47888. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  47889. * @param uniformsNames defines a list of attribute names
  47890. * @param samplers defines an array of string used to represent textures
  47891. * @param defines defines the string containing the defines to use to compile the shaders
  47892. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  47893. * @param onCompiled defines a function to call when the effect creation is successful
  47894. * @param onError defines a function to call when the effect creation has failed
  47895. * @returns the new Effect
  47896. */
  47897. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  47898. }
  47899. interface Mesh {
  47900. /**
  47901. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  47902. * @returns an array of IParticleSystem
  47903. */
  47904. getEmittedParticleSystems(): IParticleSystem[];
  47905. /**
  47906. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  47907. * @returns an array of IParticleSystem
  47908. */
  47909. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  47910. }
  47911. /**
  47912. * @hidden
  47913. */
  47914. export var _IDoNeedToBeInTheBuild: number;
  47915. }
  47916. declare module BABYLON {
  47917. interface Scene {
  47918. /** @hidden (Backing field) */ physicsEngine: Nullable<IPhysicsEngine>;
  47919. /**
  47920. * Gets the current physics engine
  47921. * @returns a IPhysicsEngine or null if none attached
  47922. */
  47923. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  47924. /**
  47925. * Enables physics to the current scene
  47926. * @param gravity defines the scene's gravity for the physics engine
  47927. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  47928. * @return a boolean indicating if the physics engine was initialized
  47929. */
  47930. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  47931. /**
  47932. * Disables and disposes the physics engine associated with the scene
  47933. */
  47934. disablePhysicsEngine(): void;
  47935. /**
  47936. * Gets a boolean indicating if there is an active physics engine
  47937. * @returns a boolean indicating if there is an active physics engine
  47938. */
  47939. isPhysicsEnabled(): boolean;
  47940. /**
  47941. * Deletes a physics compound impostor
  47942. * @param compound defines the compound to delete
  47943. */
  47944. deleteCompoundImpostor(compound: any): void;
  47945. /**
  47946. * An event triggered when physic simulation is about to be run
  47947. */
  47948. onBeforePhysicsObservable: Observable<Scene>;
  47949. /**
  47950. * An event triggered when physic simulation has been done
  47951. */
  47952. onAfterPhysicsObservable: Observable<Scene>;
  47953. }
  47954. interface AbstractMesh {
  47955. /** @hidden */ physicsImpostor: Nullable<PhysicsImpostor>;
  47956. /**
  47957. * Gets or sets impostor used for physic simulation
  47958. * @see http://doc.babylonjs.com/features/physics_engine
  47959. */
  47960. physicsImpostor: Nullable<PhysicsImpostor>;
  47961. /**
  47962. * Gets the current physics impostor
  47963. * @see http://doc.babylonjs.com/features/physics_engine
  47964. * @returns a physics impostor or null
  47965. */
  47966. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  47967. /** Apply a physic impulse to the mesh
  47968. * @param force defines the force to apply
  47969. * @param contactPoint defines where to apply the force
  47970. * @returns the current mesh
  47971. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47972. */
  47973. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  47974. /**
  47975. * Creates a physic joint between two meshes
  47976. * @param otherMesh defines the other mesh to use
  47977. * @param pivot1 defines the pivot to use on this mesh
  47978. * @param pivot2 defines the pivot to use on the other mesh
  47979. * @param options defines additional options (can be plugin dependent)
  47980. * @returns the current mesh
  47981. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  47982. */
  47983. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  47984. /** @hidden */ disposePhysicsObserver: Nullable<Observer<Node>>;
  47985. }
  47986. /**
  47987. * Defines the physics engine scene component responsible to manage a physics engine
  47988. */
  47989. export class PhysicsEngineSceneComponent implements ISceneComponent {
  47990. /**
  47991. * The component name helpful to identify the component in the list of scene components.
  47992. */
  47993. readonly name: string;
  47994. /**
  47995. * The scene the component belongs to.
  47996. */
  47997. scene: Scene;
  47998. /**
  47999. * Creates a new instance of the component for the given scene
  48000. * @param scene Defines the scene to register the component in
  48001. */
  48002. constructor(scene: Scene);
  48003. /**
  48004. * Registers the component in a given scene
  48005. */
  48006. register(): void;
  48007. /**
  48008. * Rebuilds the elements related to this component in case of
  48009. * context lost for instance.
  48010. */
  48011. rebuild(): void;
  48012. /**
  48013. * Disposes the component and the associated ressources
  48014. */
  48015. dispose(): void;
  48016. }
  48017. }
  48018. declare module BABYLON {
  48019. /**
  48020. * A helper for physics simulations
  48021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48022. */
  48023. export class PhysicsHelper {
  48024. private _scene;
  48025. private _physicsEngine;
  48026. /**
  48027. * Initializes the Physics helper
  48028. * @param scene Babylon.js scene
  48029. */
  48030. constructor(scene: Scene);
  48031. /**
  48032. * Applies a radial explosion impulse
  48033. * @param origin the origin of the explosion
  48034. * @param radius the explosion radius
  48035. * @param strength the explosion strength
  48036. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48037. * @returns A physics radial explosion event, or null
  48038. */
  48039. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48040. /**
  48041. * Applies a radial explosion force
  48042. * @param origin the origin of the explosion
  48043. * @param radius the explosion radius
  48044. * @param strength the explosion strength
  48045. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48046. * @returns A physics radial explosion event, or null
  48047. */
  48048. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48049. /**
  48050. * Creates a gravitational field
  48051. * @param origin the origin of the explosion
  48052. * @param radius the explosion radius
  48053. * @param strength the explosion strength
  48054. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48055. * @returns A physics gravitational field event, or null
  48056. */
  48057. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  48058. /**
  48059. * Creates a physics updraft event
  48060. * @param origin the origin of the updraft
  48061. * @param radius the radius of the updraft
  48062. * @param strength the strength of the updraft
  48063. * @param height the height of the updraft
  48064. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  48065. * @returns A physics updraft event, or null
  48066. */
  48067. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  48068. /**
  48069. * Creates a physics vortex event
  48070. * @param origin the of the vortex
  48071. * @param radius the radius of the vortex
  48072. * @param strength the strength of the vortex
  48073. * @param height the height of the vortex
  48074. * @returns a Physics vortex event, or null
  48075. * A physics vortex event or null
  48076. */
  48077. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  48078. }
  48079. /**
  48080. * Represents a physics radial explosion event
  48081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48082. */
  48083. export class PhysicsRadialExplosionEvent {
  48084. private _scene;
  48085. private _sphere;
  48086. private _sphereOptions;
  48087. private _rays;
  48088. private _dataFetched;
  48089. /**
  48090. * Initializes a radial explosioin event
  48091. * @param scene BabylonJS scene
  48092. */
  48093. constructor(scene: Scene);
  48094. /**
  48095. * Returns the data related to the radial explosion event (sphere & rays).
  48096. * @returns The radial explosion event data
  48097. */
  48098. getData(): PhysicsRadialExplosionEventData;
  48099. /**
  48100. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  48101. * @param impostor A physics imposter
  48102. * @param origin the origin of the explosion
  48103. * @param radius the explosion radius
  48104. * @param strength the explosion strength
  48105. * @param falloff possible options: Constant & Linear
  48106. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  48107. */
  48108. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  48109. /**
  48110. * Disposes the sphere.
  48111. * @param force Specifies if the sphere should be disposed by force
  48112. */
  48113. dispose(force?: boolean): void;
  48114. /*** Helpers ***/
  48115. private _prepareSphere;
  48116. private _intersectsWithSphere;
  48117. }
  48118. /**
  48119. * Represents a gravitational field event
  48120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48121. */
  48122. export class PhysicsGravitationalFieldEvent {
  48123. private _physicsHelper;
  48124. private _scene;
  48125. private _origin;
  48126. private _radius;
  48127. private _strength;
  48128. private _falloff;
  48129. private _tickCallback;
  48130. private _sphere;
  48131. private _dataFetched;
  48132. /**
  48133. * Initializes the physics gravitational field event
  48134. * @param physicsHelper A physics helper
  48135. * @param scene BabylonJS scene
  48136. * @param origin The origin position of the gravitational field event
  48137. * @param radius The radius of the gravitational field event
  48138. * @param strength The strength of the gravitational field event
  48139. * @param falloff The falloff for the gravitational field event
  48140. */
  48141. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  48142. /**
  48143. * Returns the data related to the gravitational field event (sphere).
  48144. * @returns A gravitational field event
  48145. */
  48146. getData(): PhysicsGravitationalFieldEventData;
  48147. /**
  48148. * Enables the gravitational field.
  48149. */
  48150. enable(): void;
  48151. /**
  48152. * Disables the gravitational field.
  48153. */
  48154. disable(): void;
  48155. /**
  48156. * Disposes the sphere.
  48157. * @param force The force to dispose from the gravitational field event
  48158. */
  48159. dispose(force?: boolean): void;
  48160. private _tick;
  48161. }
  48162. /**
  48163. * Represents a physics updraft event
  48164. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48165. */
  48166. export class PhysicsUpdraftEvent {
  48167. private _scene;
  48168. private _origin;
  48169. private _radius;
  48170. private _strength;
  48171. private _height;
  48172. private _updraftMode;
  48173. private _physicsEngine;
  48174. private _originTop;
  48175. private _originDirection;
  48176. private _tickCallback;
  48177. private _cylinder;
  48178. private _cylinderPosition;
  48179. private _dataFetched;
  48180. /**
  48181. * Initializes the physics updraft event
  48182. * @param _scene BabylonJS scene
  48183. * @param _origin The origin position of the updraft
  48184. * @param _radius The radius of the updraft
  48185. * @param _strength The strength of the updraft
  48186. * @param _height The height of the updraft
  48187. * @param _updraftMode The mode of the updraft
  48188. */
  48189. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  48190. /**
  48191. * Returns the data related to the updraft event (cylinder).
  48192. * @returns A physics updraft event
  48193. */
  48194. getData(): PhysicsUpdraftEventData;
  48195. /**
  48196. * Enables the updraft.
  48197. */
  48198. enable(): void;
  48199. /**
  48200. * Disables the cortex.
  48201. */
  48202. disable(): void;
  48203. /**
  48204. * Disposes the sphere.
  48205. * @param force Specifies if the updraft should be disposed by force
  48206. */
  48207. dispose(force?: boolean): void;
  48208. private getImpostorForceAndContactPoint;
  48209. private _tick;
  48210. /*** Helpers ***/
  48211. private _prepareCylinder;
  48212. private _intersectsWithCylinder;
  48213. }
  48214. /**
  48215. * Represents a physics vortex event
  48216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48217. */
  48218. export class PhysicsVortexEvent {
  48219. private _scene;
  48220. private _origin;
  48221. private _radius;
  48222. private _strength;
  48223. private _height;
  48224. private _physicsEngine;
  48225. private _originTop;
  48226. private _centripetalForceThreshold;
  48227. private _updraftMultiplier;
  48228. private _tickCallback;
  48229. private _cylinder;
  48230. private _cylinderPosition;
  48231. private _dataFetched;
  48232. /**
  48233. * Initializes the physics vortex event
  48234. * @param _scene The BabylonJS scene
  48235. * @param _origin The origin position of the vortex
  48236. * @param _radius The radius of the vortex
  48237. * @param _strength The strength of the vortex
  48238. * @param _height The height of the vortex
  48239. */
  48240. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  48241. /**
  48242. * Returns the data related to the vortex event (cylinder).
  48243. * @returns The physics vortex event data
  48244. */
  48245. getData(): PhysicsVortexEventData;
  48246. /**
  48247. * Enables the vortex.
  48248. */
  48249. enable(): void;
  48250. /**
  48251. * Disables the cortex.
  48252. */
  48253. disable(): void;
  48254. /**
  48255. * Disposes the sphere.
  48256. * @param force
  48257. */
  48258. dispose(force?: boolean): void;
  48259. private getImpostorForceAndContactPoint;
  48260. private _tick;
  48261. /*** Helpers ***/
  48262. private _prepareCylinder;
  48263. private _intersectsWithCylinder;
  48264. }
  48265. /**
  48266. * The strenght of the force in correspondence to the distance of the affected object
  48267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48268. */
  48269. export enum PhysicsRadialImpulseFalloff {
  48270. /** Defines that impulse is constant in strength across it's whole radius */
  48271. Constant = 0,
  48272. /** DEfines that impulse gets weaker if it's further from the origin */
  48273. Linear = 1
  48274. }
  48275. /**
  48276. * The strength of the force in correspondence to the distance of the affected object
  48277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48278. */
  48279. export enum PhysicsUpdraftMode {
  48280. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  48281. Center = 0,
  48282. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  48283. Perpendicular = 1
  48284. }
  48285. /**
  48286. * Interface for a physics force and contact point
  48287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48288. */
  48289. export interface PhysicsForceAndContactPoint {
  48290. /**
  48291. * The force applied at the contact point
  48292. */
  48293. force: Vector3;
  48294. /**
  48295. * The contact point
  48296. */
  48297. contactPoint: Vector3;
  48298. }
  48299. /**
  48300. * Interface for radial explosion event data
  48301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48302. */
  48303. export interface PhysicsRadialExplosionEventData {
  48304. /**
  48305. * A sphere used for the radial explosion event
  48306. */
  48307. sphere: Mesh;
  48308. /**
  48309. * An array of rays for the radial explosion event
  48310. */
  48311. rays: Array<Ray>;
  48312. }
  48313. /**
  48314. * Interface for gravitational field event data
  48315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48316. */
  48317. export interface PhysicsGravitationalFieldEventData {
  48318. /**
  48319. * A sphere mesh used for the gravitational field event
  48320. */
  48321. sphere: Mesh;
  48322. }
  48323. /**
  48324. * Interface for updraft event data
  48325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48326. */
  48327. export interface PhysicsUpdraftEventData {
  48328. /**
  48329. * A cylinder used for the updraft event
  48330. */
  48331. cylinder: Mesh;
  48332. }
  48333. /**
  48334. * Interface for vortex event data
  48335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48336. */
  48337. export interface PhysicsVortexEventData {
  48338. /**
  48339. * A cylinder used for the vortex event
  48340. */
  48341. cylinder: Mesh;
  48342. }
  48343. }
  48344. declare module BABYLON {
  48345. /**
  48346. * AmmoJS Physics plugin
  48347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48348. * @see https://github.com/kripken/ammo.js/
  48349. */
  48350. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48351. private _useDeltaForWorldStep;
  48352. /**
  48353. * Reference to the Ammo library
  48354. */
  48355. bjsAMMO: any;
  48356. /**
  48357. * Created ammoJS world which physics bodies are added to
  48358. */
  48359. world: any;
  48360. /**
  48361. * Name of the plugin
  48362. */
  48363. name: string;
  48364. private _timeStep;
  48365. private _fixedTimeStep;
  48366. private _maxSteps;
  48367. private _tmpQuaternion;
  48368. private _tmpAmmoTransform;
  48369. private _tmpAmmoQuaternion;
  48370. private _tmpAmmoConcreteContactResultCallback;
  48371. private _collisionConfiguration;
  48372. private _dispatcher;
  48373. private _overlappingPairCache;
  48374. private _solver;
  48375. private _tmpAmmoVectorA;
  48376. private _tmpAmmoVectorB;
  48377. private _tmpAmmoVectorC;
  48378. private _tmpContactCallbackResult;
  48379. private static readonly DISABLE_COLLISION_FLAG;
  48380. private static readonly KINEMATIC_FLAG;
  48381. private static readonly DISABLE_DEACTIVATION_FLAG;
  48382. /**
  48383. * Initializes the ammoJS plugin
  48384. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48385. * @param ammoInjection can be used to inject your own ammo reference
  48386. */
  48387. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48388. /**
  48389. * Sets the gravity of the physics world (m/(s^2))
  48390. * @param gravity Gravity to set
  48391. */
  48392. setGravity(gravity: Vector3): void;
  48393. /**
  48394. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48395. * @param timeStep timestep to use in seconds
  48396. */
  48397. setTimeStep(timeStep: number): void;
  48398. /**
  48399. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  48400. * @param fixedTimeStep fixedTimeStep to use in seconds
  48401. */
  48402. setFixedTimeStep(fixedTimeStep: number): void;
  48403. /**
  48404. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48405. * @param maxSteps the maximum number of steps by the physics engine per frame
  48406. */
  48407. setMaxSteps(maxSteps: number): void;
  48408. /**
  48409. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48410. * @returns the current timestep in seconds
  48411. */
  48412. getTimeStep(): number;
  48413. private _isImpostorInContact;
  48414. private _isImpostorPairInContact;
  48415. private _stepSimulation;
  48416. /**
  48417. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48418. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48419. * After the step the babylon meshes are set to the position of the physics imposters
  48420. * @param delta amount of time to step forward
  48421. * @param impostors array of imposters to update before/after the step
  48422. */
  48423. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48424. private _tmpVector;
  48425. private _tmpMatrix;
  48426. /**
  48427. * Applies an implulse on the imposter
  48428. * @param impostor imposter to apply impulse
  48429. * @param force amount of force to be applied to the imposter
  48430. * @param contactPoint the location to apply the impulse on the imposter
  48431. */
  48432. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48433. /**
  48434. * Applies a force on the imposter
  48435. * @param impostor imposter to apply force
  48436. * @param force amount of force to be applied to the imposter
  48437. * @param contactPoint the location to apply the force on the imposter
  48438. */
  48439. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48440. /**
  48441. * Creates a physics body using the plugin
  48442. * @param impostor the imposter to create the physics body on
  48443. */
  48444. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48445. /**
  48446. * Removes the physics body from the imposter and disposes of the body's memory
  48447. * @param impostor imposter to remove the physics body from
  48448. */
  48449. removePhysicsBody(impostor: PhysicsImpostor): void;
  48450. /**
  48451. * Generates a joint
  48452. * @param impostorJoint the imposter joint to create the joint with
  48453. */
  48454. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48455. /**
  48456. * Removes a joint
  48457. * @param impostorJoint the imposter joint to remove the joint from
  48458. */
  48459. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48460. private _addMeshVerts;
  48461. private _createShape;
  48462. /**
  48463. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48464. * @param impostor imposter containing the physics body and babylon object
  48465. */
  48466. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48467. /**
  48468. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48469. * @param impostor imposter containing the physics body and babylon object
  48470. * @param newPosition new position
  48471. * @param newRotation new rotation
  48472. */
  48473. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48474. /**
  48475. * If this plugin is supported
  48476. * @returns true if its supported
  48477. */
  48478. isSupported(): boolean;
  48479. /**
  48480. * Sets the linear velocity of the physics body
  48481. * @param impostor imposter to set the velocity on
  48482. * @param velocity velocity to set
  48483. */
  48484. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48485. /**
  48486. * Sets the angular velocity of the physics body
  48487. * @param impostor imposter to set the velocity on
  48488. * @param velocity velocity to set
  48489. */
  48490. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48491. /**
  48492. * gets the linear velocity
  48493. * @param impostor imposter to get linear velocity from
  48494. * @returns linear velocity
  48495. */
  48496. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48497. /**
  48498. * gets the angular velocity
  48499. * @param impostor imposter to get angular velocity from
  48500. * @returns angular velocity
  48501. */
  48502. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48503. /**
  48504. * Sets the mass of physics body
  48505. * @param impostor imposter to set the mass on
  48506. * @param mass mass to set
  48507. */
  48508. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48509. /**
  48510. * Gets the mass of the physics body
  48511. * @param impostor imposter to get the mass from
  48512. * @returns mass
  48513. */
  48514. getBodyMass(impostor: PhysicsImpostor): number;
  48515. /**
  48516. * Gets friction of the impostor
  48517. * @param impostor impostor to get friction from
  48518. * @returns friction value
  48519. */
  48520. getBodyFriction(impostor: PhysicsImpostor): number;
  48521. /**
  48522. * Sets friction of the impostor
  48523. * @param impostor impostor to set friction on
  48524. * @param friction friction value
  48525. */
  48526. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48527. /**
  48528. * Gets restitution of the impostor
  48529. * @param impostor impostor to get restitution from
  48530. * @returns restitution value
  48531. */
  48532. getBodyRestitution(impostor: PhysicsImpostor): number;
  48533. /**
  48534. * Sets resitution of the impostor
  48535. * @param impostor impostor to set resitution on
  48536. * @param restitution resitution value
  48537. */
  48538. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48539. /**
  48540. * Sleeps the physics body and stops it from being active
  48541. * @param impostor impostor to sleep
  48542. */
  48543. sleepBody(impostor: PhysicsImpostor): void;
  48544. /**
  48545. * Activates the physics body
  48546. * @param impostor impostor to activate
  48547. */
  48548. wakeUpBody(impostor: PhysicsImpostor): void;
  48549. /**
  48550. * Updates the distance parameters of the joint
  48551. * @param joint joint to update
  48552. * @param maxDistance maximum distance of the joint
  48553. * @param minDistance minimum distance of the joint
  48554. */
  48555. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48556. /**
  48557. * Sets a motor on the joint
  48558. * @param joint joint to set motor on
  48559. * @param speed speed of the motor
  48560. * @param maxForce maximum force of the motor
  48561. * @param motorIndex index of the motor
  48562. */
  48563. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48564. /**
  48565. * Sets the motors limit
  48566. * @param joint joint to set limit on
  48567. * @param upperLimit upper limit
  48568. * @param lowerLimit lower limit
  48569. */
  48570. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48571. /**
  48572. * Syncs the position and rotation of a mesh with the impostor
  48573. * @param mesh mesh to sync
  48574. * @param impostor impostor to update the mesh with
  48575. */
  48576. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48577. /**
  48578. * Gets the radius of the impostor
  48579. * @param impostor impostor to get radius from
  48580. * @returns the radius
  48581. */
  48582. getRadius(impostor: PhysicsImpostor): number;
  48583. /**
  48584. * Gets the box size of the impostor
  48585. * @param impostor impostor to get box size from
  48586. * @param result the resulting box size
  48587. */
  48588. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48589. /**
  48590. * Disposes of the impostor
  48591. */
  48592. dispose(): void;
  48593. }
  48594. }
  48595. declare module BABYLON {
  48596. /** @hidden */
  48597. export var blackAndWhitePixelShader: {
  48598. name: string;
  48599. shader: string;
  48600. };
  48601. }
  48602. declare module BABYLON {
  48603. /**
  48604. * Post process used to render in black and white
  48605. */
  48606. export class BlackAndWhitePostProcess extends PostProcess {
  48607. /**
  48608. * Linear about to convert he result to black and white (default: 1)
  48609. */
  48610. degree: number;
  48611. /**
  48612. * Creates a black and white post process
  48613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  48614. * @param name The name of the effect.
  48615. * @param options The required width/height ratio to downsize to before computing the render pass.
  48616. * @param camera The camera to apply the render pass to.
  48617. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48618. * @param engine The engine which the post process will be applied. (default: current engine)
  48619. * @param reusable If the post process can be reused on the same frame. (default: false)
  48620. */
  48621. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  48622. }
  48623. }
  48624. declare module BABYLON {
  48625. /**
  48626. * This represents a set of one or more post processes in Babylon.
  48627. * A post process can be used to apply a shader to a texture after it is rendered.
  48628. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48629. */
  48630. export class PostProcessRenderEffect {
  48631. private _postProcesses;
  48632. private _getPostProcesses;
  48633. private _singleInstance;
  48634. private _cameras;
  48635. private _indicesForCamera;
  48636. /**
  48637. * Name of the effect
  48638. * @hidden
  48639. */ name: string;
  48640. /**
  48641. * Instantiates a post process render effect.
  48642. * A post process can be used to apply a shader to a texture after it is rendered.
  48643. * @param engine The engine the effect is tied to
  48644. * @param name The name of the effect
  48645. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  48646. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  48647. */
  48648. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  48649. /**
  48650. * Checks if all the post processes in the effect are supported.
  48651. */
  48652. readonly isSupported: boolean;
  48653. /**
  48654. * Updates the current state of the effect
  48655. * @hidden
  48656. */ update(): void;
  48657. /**
  48658. * Attaches the effect on cameras
  48659. * @param cameras The camera to attach to.
  48660. * @hidden
  48661. */ attachCameras(cameras: Camera): void;
  48662. /**
  48663. * Attaches the effect on cameras
  48664. * @param cameras The camera to attach to.
  48665. * @hidden
  48666. */ attachCameras(cameras: Camera[]): void;
  48667. /**
  48668. * Detatches the effect on cameras
  48669. * @param cameras The camera to detatch from.
  48670. * @hidden
  48671. */ detachCameras(cameras: Camera): void;
  48672. /**
  48673. * Detatches the effect on cameras
  48674. * @param cameras The camera to detatch from.
  48675. * @hidden
  48676. */ detachCameras(cameras: Camera[]): void;
  48677. /**
  48678. * Enables the effect on given cameras
  48679. * @param cameras The camera to enable.
  48680. * @hidden
  48681. */ enable(cameras: Camera): void;
  48682. /**
  48683. * Enables the effect on given cameras
  48684. * @param cameras The camera to enable.
  48685. * @hidden
  48686. */ enable(cameras: Nullable<Camera[]>): void;
  48687. /**
  48688. * Disables the effect on the given cameras
  48689. * @param cameras The camera to disable.
  48690. * @hidden
  48691. */ disable(cameras: Camera): void;
  48692. /**
  48693. * Disables the effect on the given cameras
  48694. * @param cameras The camera to disable.
  48695. * @hidden
  48696. */ disable(cameras: Nullable<Camera[]>): void;
  48697. /**
  48698. * Gets a list of the post processes contained in the effect.
  48699. * @param camera The camera to get the post processes on.
  48700. * @returns The list of the post processes in the effect.
  48701. */
  48702. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  48703. }
  48704. }
  48705. declare module BABYLON {
  48706. /** @hidden */
  48707. export var extractHighlightsPixelShader: {
  48708. name: string;
  48709. shader: string;
  48710. };
  48711. }
  48712. declare module BABYLON {
  48713. /**
  48714. * 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.
  48715. */
  48716. export class ExtractHighlightsPostProcess extends PostProcess {
  48717. /**
  48718. * The luminance threshold, pixels below this value will be set to black.
  48719. */
  48720. threshold: number;
  48721. /** @hidden */ exposure: number;
  48722. /**
  48723. * Post process which has the input texture to be used when performing highlight extraction
  48724. * @hidden
  48725. */ inputPostProcess: Nullable<PostProcess>;
  48726. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48727. }
  48728. }
  48729. declare module BABYLON {
  48730. /** @hidden */
  48731. export var bloomMergePixelShader: {
  48732. name: string;
  48733. shader: string;
  48734. };
  48735. }
  48736. declare module BABYLON {
  48737. /**
  48738. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  48739. */
  48740. export class BloomMergePostProcess extends PostProcess {
  48741. /** Weight of the bloom to be added to the original input. */
  48742. weight: number;
  48743. /**
  48744. * Creates a new instance of @see BloomMergePostProcess
  48745. * @param name The name of the effect.
  48746. * @param originalFromInput Post process which's input will be used for the merge.
  48747. * @param blurred Blurred highlights post process which's output will be used.
  48748. * @param weight Weight of the bloom to be added to the original input.
  48749. * @param options The required width/height ratio to downsize to before computing the render pass.
  48750. * @param camera The camera to apply the render pass to.
  48751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48752. * @param engine The engine which the post process will be applied. (default: current engine)
  48753. * @param reusable If the post process can be reused on the same frame. (default: false)
  48754. * @param textureType Type of textures used when performing the post process. (default: 0)
  48755. * @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)
  48756. */
  48757. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  48758. /** Weight of the bloom to be added to the original input. */
  48759. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48760. }
  48761. }
  48762. declare module BABYLON {
  48763. /**
  48764. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  48765. */
  48766. export class BloomEffect extends PostProcessRenderEffect {
  48767. private bloomScale;
  48768. /**
  48769. * @hidden Internal
  48770. */ effects: Array<PostProcess>;
  48771. /**
  48772. * @hidden Internal
  48773. */ downscale: ExtractHighlightsPostProcess;
  48774. private _blurX;
  48775. private _blurY;
  48776. private _merge;
  48777. /**
  48778. * The luminance threshold to find bright areas of the image to bloom.
  48779. */
  48780. threshold: number;
  48781. /**
  48782. * The strength of the bloom.
  48783. */
  48784. weight: number;
  48785. /**
  48786. * Specifies the size of the bloom blur kernel, relative to the final output size
  48787. */
  48788. kernel: number;
  48789. /**
  48790. * Creates a new instance of @see BloomEffect
  48791. * @param scene The scene the effect belongs to.
  48792. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  48793. * @param bloomKernel The size of the kernel to be used when applying the blur.
  48794. * @param bloomWeight The the strength of bloom.
  48795. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  48796. * @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)
  48797. */
  48798. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  48799. /**
  48800. * Disposes each of the internal effects for a given camera.
  48801. * @param camera The camera to dispose the effect on.
  48802. */
  48803. disposeEffects(camera: Camera): void;
  48804. /**
  48805. * @hidden Internal
  48806. */ updateEffects(): void;
  48807. /**
  48808. * Internal
  48809. * @returns if all the contained post processes are ready.
  48810. * @hidden
  48811. */ isReady(): boolean;
  48812. }
  48813. }
  48814. declare module BABYLON {
  48815. /** @hidden */
  48816. export var chromaticAberrationPixelShader: {
  48817. name: string;
  48818. shader: string;
  48819. };
  48820. }
  48821. declare module BABYLON {
  48822. /**
  48823. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  48824. */
  48825. export class ChromaticAberrationPostProcess extends PostProcess {
  48826. /**
  48827. * The amount of seperation of rgb channels (default: 30)
  48828. */
  48829. aberrationAmount: number;
  48830. /**
  48831. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  48832. */
  48833. radialIntensity: number;
  48834. /**
  48835. * 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))
  48836. */
  48837. direction: Vector2;
  48838. /**
  48839. * 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))
  48840. */
  48841. centerPosition: Vector2;
  48842. /**
  48843. * Creates a new instance ChromaticAberrationPostProcess
  48844. * @param name The name of the effect.
  48845. * @param screenWidth The width of the screen to apply the effect on.
  48846. * @param screenHeight The height of the screen to apply the effect on.
  48847. * @param options The required width/height ratio to downsize to before computing the render pass.
  48848. * @param camera The camera to apply the render pass to.
  48849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48850. * @param engine The engine which the post process will be applied. (default: current engine)
  48851. * @param reusable If the post process can be reused on the same frame. (default: false)
  48852. * @param textureType Type of textures used when performing the post process. (default: 0)
  48853. * @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)
  48854. */
  48855. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48856. }
  48857. }
  48858. declare module BABYLON {
  48859. /** @hidden */
  48860. export var circleOfConfusionPixelShader: {
  48861. name: string;
  48862. shader: string;
  48863. };
  48864. }
  48865. declare module BABYLON {
  48866. /**
  48867. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  48868. */
  48869. export class CircleOfConfusionPostProcess extends PostProcess {
  48870. /**
  48871. * 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.
  48872. */
  48873. lensSize: number;
  48874. /**
  48875. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  48876. */
  48877. fStop: number;
  48878. /**
  48879. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  48880. */
  48881. focusDistance: number;
  48882. /**
  48883. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  48884. */
  48885. focalLength: number;
  48886. private _depthTexture;
  48887. /**
  48888. * Creates a new instance CircleOfConfusionPostProcess
  48889. * @param name The name of the effect.
  48890. * @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.
  48891. * @param options The required width/height ratio to downsize to before computing the render pass.
  48892. * @param camera The camera to apply the render pass to.
  48893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48894. * @param engine The engine which the post process will be applied. (default: current engine)
  48895. * @param reusable If the post process can be reused on the same frame. (default: false)
  48896. * @param textureType Type of textures used when performing the post process. (default: 0)
  48897. * @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)
  48898. */
  48899. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48900. /**
  48901. * 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.
  48902. */
  48903. depthTexture: RenderTargetTexture;
  48904. }
  48905. }
  48906. declare module BABYLON {
  48907. /** @hidden */
  48908. export var colorCorrectionPixelShader: {
  48909. name: string;
  48910. shader: string;
  48911. };
  48912. }
  48913. declare module BABYLON {
  48914. /**
  48915. *
  48916. * This post-process allows the modification of rendered colors by using
  48917. * a 'look-up table' (LUT). This effect is also called Color Grading.
  48918. *
  48919. * The object needs to be provided an url to a texture containing the color
  48920. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  48921. * Use an image editing software to tweak the LUT to match your needs.
  48922. *
  48923. * For an example of a color LUT, see here:
  48924. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  48925. * For explanations on color grading, see here:
  48926. * @see http://udn.epicgames.com/Three/ColorGrading.html
  48927. *
  48928. */
  48929. export class ColorCorrectionPostProcess extends PostProcess {
  48930. private _colorTableTexture;
  48931. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  48932. }
  48933. }
  48934. declare module BABYLON {
  48935. /** @hidden */
  48936. export var convolutionPixelShader: {
  48937. name: string;
  48938. shader: string;
  48939. };
  48940. }
  48941. declare module BABYLON {
  48942. /**
  48943. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  48944. * input texture to perform effects such as edge detection or sharpening
  48945. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  48946. */
  48947. export class ConvolutionPostProcess extends PostProcess {
  48948. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  48949. kernel: number[];
  48950. /**
  48951. * Creates a new instance ConvolutionPostProcess
  48952. * @param name The name of the effect.
  48953. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  48954. * @param options The required width/height ratio to downsize to before computing the render pass.
  48955. * @param camera The camera to apply the render pass to.
  48956. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48957. * @param engine The engine which the post process will be applied. (default: current engine)
  48958. * @param reusable If the post process can be reused on the same frame. (default: false)
  48959. * @param textureType Type of textures used when performing the post process. (default: 0)
  48960. */
  48961. constructor(name: string,
  48962. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  48963. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  48964. /**
  48965. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48966. */
  48967. static EdgeDetect0Kernel: number[];
  48968. /**
  48969. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48970. */
  48971. static EdgeDetect1Kernel: number[];
  48972. /**
  48973. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48974. */
  48975. static EdgeDetect2Kernel: number[];
  48976. /**
  48977. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48978. */
  48979. static SharpenKernel: number[];
  48980. /**
  48981. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48982. */
  48983. static EmbossKernel: number[];
  48984. /**
  48985. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48986. */
  48987. static GaussianKernel: number[];
  48988. }
  48989. }
  48990. declare module BABYLON {
  48991. /**
  48992. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  48993. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  48994. * based on samples that have a large difference in distance than the center pixel.
  48995. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  48996. */
  48997. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  48998. direction: Vector2;
  48999. /**
  49000. * Creates a new instance CircleOfConfusionPostProcess
  49001. * @param name The name of the effect.
  49002. * @param scene The scene the effect belongs to.
  49003. * @param direction The direction the blur should be applied.
  49004. * @param kernel The size of the kernel used to blur.
  49005. * @param options The required width/height ratio to downsize to before computing the render pass.
  49006. * @param camera The camera to apply the render pass to.
  49007. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  49008. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  49009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49010. * @param engine The engine which the post process will be applied. (default: current engine)
  49011. * @param reusable If the post process can be reused on the same frame. (default: false)
  49012. * @param textureType Type of textures used when performing the post process. (default: 0)
  49013. * @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)
  49014. */
  49015. 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);
  49016. }
  49017. }
  49018. declare module BABYLON {
  49019. /** @hidden */
  49020. export var depthOfFieldMergePixelShader: {
  49021. name: string;
  49022. shader: string;
  49023. };
  49024. }
  49025. declare module BABYLON {
  49026. /**
  49027. * Options to be set when merging outputs from the default pipeline.
  49028. */
  49029. export class DepthOfFieldMergePostProcessOptions {
  49030. /**
  49031. * The original image to merge on top of
  49032. */
  49033. originalFromInput: PostProcess;
  49034. /**
  49035. * Parameters to perform the merge of the depth of field effect
  49036. */
  49037. depthOfField?: {
  49038. circleOfConfusion: PostProcess;
  49039. blurSteps: Array<PostProcess>;
  49040. };
  49041. /**
  49042. * Parameters to perform the merge of bloom effect
  49043. */
  49044. bloom?: {
  49045. blurred: PostProcess;
  49046. weight: number;
  49047. };
  49048. }
  49049. /**
  49050. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  49051. */
  49052. export class DepthOfFieldMergePostProcess extends PostProcess {
  49053. private blurSteps;
  49054. /**
  49055. * Creates a new instance of DepthOfFieldMergePostProcess
  49056. * @param name The name of the effect.
  49057. * @param originalFromInput Post process which's input will be used for the merge.
  49058. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  49059. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  49060. * @param options The required width/height ratio to downsize to before computing the render pass.
  49061. * @param camera The camera to apply the render pass to.
  49062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49063. * @param engine The engine which the post process will be applied. (default: current engine)
  49064. * @param reusable If the post process can be reused on the same frame. (default: false)
  49065. * @param textureType Type of textures used when performing the post process. (default: 0)
  49066. * @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)
  49067. */
  49068. 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);
  49069. /**
  49070. * Updates the effect with the current post process compile time values and recompiles the shader.
  49071. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  49072. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  49073. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  49074. * @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
  49075. * @param onCompiled Called when the shader has been compiled.
  49076. * @param onError Called if there is an error when compiling a shader.
  49077. */
  49078. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  49079. }
  49080. }
  49081. declare module BABYLON {
  49082. /**
  49083. * Specifies the level of max blur that should be applied when using the depth of field effect
  49084. */
  49085. export enum DepthOfFieldEffectBlurLevel {
  49086. /**
  49087. * Subtle blur
  49088. */
  49089. Low = 0,
  49090. /**
  49091. * Medium blur
  49092. */
  49093. Medium = 1,
  49094. /**
  49095. * Large blur
  49096. */
  49097. High = 2
  49098. }
  49099. /**
  49100. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  49101. */
  49102. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  49103. private _circleOfConfusion;
  49104. /**
  49105. * @hidden Internal, blurs from high to low
  49106. */ depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  49107. private _depthOfFieldBlurY;
  49108. private _dofMerge;
  49109. /**
  49110. * @hidden Internal post processes in depth of field effect
  49111. */ effects: Array<PostProcess>;
  49112. /**
  49113. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  49114. */
  49115. focalLength: number;
  49116. /**
  49117. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  49118. */
  49119. fStop: number;
  49120. /**
  49121. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  49122. */
  49123. focusDistance: number;
  49124. /**
  49125. * 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.
  49126. */
  49127. lensSize: number;
  49128. /**
  49129. * Creates a new instance DepthOfFieldEffect
  49130. * @param scene The scene the effect belongs to.
  49131. * @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.
  49132. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  49133. * @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)
  49134. */
  49135. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  49136. /**
  49137. * 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.
  49138. */
  49139. depthTexture: RenderTargetTexture;
  49140. /**
  49141. * Disposes each of the internal effects for a given camera.
  49142. * @param camera The camera to dispose the effect on.
  49143. */
  49144. disposeEffects(camera: Camera): void;
  49145. /**
  49146. * @hidden Internal
  49147. */ updateEffects(): void;
  49148. /**
  49149. * Internal
  49150. * @returns if all the contained post processes are ready.
  49151. * @hidden
  49152. */ isReady(): boolean;
  49153. }
  49154. }
  49155. declare module BABYLON {
  49156. /** @hidden */
  49157. export var displayPassPixelShader: {
  49158. name: string;
  49159. shader: string;
  49160. };
  49161. }
  49162. declare module BABYLON {
  49163. /**
  49164. * DisplayPassPostProcess which produces an output the same as it's input
  49165. */
  49166. export class DisplayPassPostProcess extends PostProcess {
  49167. /**
  49168. * Creates the DisplayPassPostProcess
  49169. * @param name The name of the effect.
  49170. * @param options The required width/height ratio to downsize to before computing the render pass.
  49171. * @param camera The camera to apply the render pass to.
  49172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49173. * @param engine The engine which the post process will be applied. (default: current engine)
  49174. * @param reusable If the post process can be reused on the same frame. (default: false)
  49175. */
  49176. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49177. }
  49178. }
  49179. declare module BABYLON {
  49180. /** @hidden */
  49181. export var filterPixelShader: {
  49182. name: string;
  49183. shader: string;
  49184. };
  49185. }
  49186. declare module BABYLON {
  49187. /**
  49188. * Applies a kernel filter to the image
  49189. */
  49190. export class FilterPostProcess extends PostProcess {
  49191. /** The matrix to be applied to the image */
  49192. kernelMatrix: Matrix;
  49193. /**
  49194. *
  49195. * @param name The name of the effect.
  49196. * @param kernelMatrix The matrix to be applied to the image
  49197. * @param options The required width/height ratio to downsize to before computing the render pass.
  49198. * @param camera The camera to apply the render pass to.
  49199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49200. * @param engine The engine which the post process will be applied. (default: current engine)
  49201. * @param reusable If the post process can be reused on the same frame. (default: false)
  49202. */
  49203. constructor(name: string,
  49204. /** The matrix to be applied to the image */
  49205. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49206. }
  49207. }
  49208. declare module BABYLON {
  49209. /** @hidden */
  49210. export var fxaaPixelShader: {
  49211. name: string;
  49212. shader: string;
  49213. };
  49214. }
  49215. declare module BABYLON {
  49216. /** @hidden */
  49217. export var fxaaVertexShader: {
  49218. name: string;
  49219. shader: string;
  49220. };
  49221. }
  49222. declare module BABYLON {
  49223. /**
  49224. * Fxaa post process
  49225. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  49226. */
  49227. export class FxaaPostProcess extends PostProcess {
  49228. /** @hidden */
  49229. texelWidth: number;
  49230. /** @hidden */
  49231. texelHeight: number;
  49232. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49233. private _getDefines;
  49234. }
  49235. }
  49236. declare module BABYLON {
  49237. /** @hidden */
  49238. export var grainPixelShader: {
  49239. name: string;
  49240. shader: string;
  49241. };
  49242. }
  49243. declare module BABYLON {
  49244. /**
  49245. * The GrainPostProcess adds noise to the image at mid luminance levels
  49246. */
  49247. export class GrainPostProcess extends PostProcess {
  49248. /**
  49249. * The intensity of the grain added (default: 30)
  49250. */
  49251. intensity: number;
  49252. /**
  49253. * If the grain should be randomized on every frame
  49254. */
  49255. animated: boolean;
  49256. /**
  49257. * Creates a new instance of @see GrainPostProcess
  49258. * @param name The name of the effect.
  49259. * @param options The required width/height ratio to downsize to before computing the render pass.
  49260. * @param camera The camera to apply the render pass to.
  49261. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49262. * @param engine The engine which the post process will be applied. (default: current engine)
  49263. * @param reusable If the post process can be reused on the same frame. (default: false)
  49264. * @param textureType Type of textures used when performing the post process. (default: 0)
  49265. * @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)
  49266. */
  49267. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49268. }
  49269. }
  49270. declare module BABYLON {
  49271. /** @hidden */
  49272. export var highlightsPixelShader: {
  49273. name: string;
  49274. shader: string;
  49275. };
  49276. }
  49277. declare module BABYLON {
  49278. /**
  49279. * Extracts highlights from the image
  49280. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49281. */
  49282. export class HighlightsPostProcess extends PostProcess {
  49283. /**
  49284. * Extracts highlights from the image
  49285. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49286. * @param name The name of the effect.
  49287. * @param options The required width/height ratio to downsize to before computing the render pass.
  49288. * @param camera The camera to apply the render pass to.
  49289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49290. * @param engine The engine which the post process will be applied. (default: current engine)
  49291. * @param reusable If the post process can be reused on the same frame. (default: false)
  49292. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  49293. */
  49294. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49295. }
  49296. }
  49297. declare module BABYLON {
  49298. /** @hidden */
  49299. export var mrtFragmentDeclaration: {
  49300. name: string;
  49301. shader: string;
  49302. };
  49303. }
  49304. declare module BABYLON {
  49305. /** @hidden */
  49306. export var geometryPixelShader: {
  49307. name: string;
  49308. shader: string;
  49309. };
  49310. }
  49311. declare module BABYLON {
  49312. /** @hidden */
  49313. export var geometryVertexShader: {
  49314. name: string;
  49315. shader: string;
  49316. };
  49317. }
  49318. declare module BABYLON {
  49319. /**
  49320. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  49321. */
  49322. export class GeometryBufferRenderer {
  49323. /**
  49324. * Constant used to retrieve the position texture index in the G-Buffer textures array
  49325. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  49326. */
  49327. static readonly POSITION_TEXTURE_TYPE: number;
  49328. /**
  49329. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  49330. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  49331. */
  49332. static readonly VELOCITY_TEXTURE_TYPE: number;
  49333. /**
  49334. * Dictionary used to store the previous transformation matrices of each rendered mesh
  49335. * in order to compute objects velocities when enableVelocity is set to "true"
  49336. * @hidden
  49337. */ previousTransformationMatrices: {
  49338. [index: number]: Matrix;
  49339. };
  49340. private _scene;
  49341. private _multiRenderTarget;
  49342. private _ratio;
  49343. private _enablePosition;
  49344. private _enableVelocity;
  49345. private _positionIndex;
  49346. private _velocityIndex;
  49347. protected _effect: Effect;
  49348. protected _cachedDefines: string;
  49349. /**
  49350. * Set the render list (meshes to be rendered) used in the G buffer.
  49351. */
  49352. renderList: Mesh[];
  49353. /**
  49354. * Gets wether or not G buffer are supported by the running hardware.
  49355. * This requires draw buffer supports
  49356. */
  49357. readonly isSupported: boolean;
  49358. /**
  49359. * Returns the index of the given texture type in the G-Buffer textures array
  49360. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  49361. * @returns the index of the given texture type in the G-Buffer textures array
  49362. */
  49363. getTextureIndex(textureType: number): number;
  49364. /**
  49365. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  49366. */
  49367. /**
  49368. * Sets whether or not objects positions are enabled for the G buffer.
  49369. */
  49370. enablePosition: boolean;
  49371. /**
  49372. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  49373. */
  49374. /**
  49375. * Sets wether or not objects velocities are enabled for the G buffer.
  49376. */
  49377. enableVelocity: boolean;
  49378. /**
  49379. * Gets the scene associated with the buffer.
  49380. */
  49381. readonly scene: Scene;
  49382. /**
  49383. * Gets the ratio used by the buffer during its creation.
  49384. * How big is the buffer related to the main canvas.
  49385. */
  49386. readonly ratio: number;
  49387. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  49388. /**
  49389. * Creates a new G Buffer for the scene
  49390. * @param scene The scene the buffer belongs to
  49391. * @param ratio How big is the buffer related to the main canvas.
  49392. */
  49393. constructor(scene: Scene, ratio?: number);
  49394. /**
  49395. * Checks wether everything is ready to render a submesh to the G buffer.
  49396. * @param subMesh the submesh to check readiness for
  49397. * @param useInstances is the mesh drawn using instance or not
  49398. * @returns true if ready otherwise false
  49399. */
  49400. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49401. /**
  49402. * Gets the current underlying G Buffer.
  49403. * @returns the buffer
  49404. */
  49405. getGBuffer(): MultiRenderTarget;
  49406. /**
  49407. * Gets the number of samples used to render the buffer (anti aliasing).
  49408. */
  49409. /**
  49410. * Sets the number of samples used to render the buffer (anti aliasing).
  49411. */
  49412. samples: number;
  49413. /**
  49414. * Disposes the renderer and frees up associated resources.
  49415. */
  49416. dispose(): void;
  49417. protected _createRenderTargets(): void;
  49418. }
  49419. }
  49420. declare module BABYLON {
  49421. /** @hidden */
  49422. export var motionBlurPixelShader: {
  49423. name: string;
  49424. shader: string;
  49425. };
  49426. }
  49427. declare module BABYLON {
  49428. /**
  49429. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  49430. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  49431. * As an example, all you have to do is to create the post-process:
  49432. * var mb = new BABYLON.MotionBlurPostProcess(
  49433. * 'mb', // The name of the effect.
  49434. * scene, // The scene containing the objects to blur according to their velocity.
  49435. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  49436. * camera // The camera to apply the render pass to.
  49437. * );
  49438. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  49439. */
  49440. export class MotionBlurPostProcess extends PostProcess {
  49441. /**
  49442. * Defines how much the image is blurred by the movement. Default value is equal to 1
  49443. */
  49444. motionStrength: number;
  49445. /**
  49446. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  49447. */
  49448. /**
  49449. * Sets the number of iterations to be used for motion blur quality
  49450. */
  49451. motionBlurSamples: number;
  49452. private _motionBlurSamples;
  49453. private _geometryBufferRenderer;
  49454. /**
  49455. * Creates a new instance MotionBlurPostProcess
  49456. * @param name The name of the effect.
  49457. * @param scene The scene containing the objects to blur according to their velocity.
  49458. * @param options The required width/height ratio to downsize to before computing the render pass.
  49459. * @param camera The camera to apply the render pass to.
  49460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49461. * @param engine The engine which the post process will be applied. (default: current engine)
  49462. * @param reusable If the post process can be reused on the same frame. (default: false)
  49463. * @param textureType Type of textures used when performing the post process. (default: 0)
  49464. * @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)
  49465. */
  49466. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49467. /**
  49468. * Disposes the post process.
  49469. * @param camera The camera to dispose the post process on.
  49470. */
  49471. dispose(camera?: Camera): void;
  49472. }
  49473. }
  49474. declare module BABYLON {
  49475. /** @hidden */
  49476. export var refractionPixelShader: {
  49477. name: string;
  49478. shader: string;
  49479. };
  49480. }
  49481. declare module BABYLON {
  49482. /**
  49483. * Post process which applies a refractin texture
  49484. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  49485. */
  49486. export class RefractionPostProcess extends PostProcess {
  49487. /** the base color of the refraction (used to taint the rendering) */
  49488. color: Color3;
  49489. /** simulated refraction depth */
  49490. depth: number;
  49491. /** the coefficient of the base color (0 to remove base color tainting) */
  49492. colorLevel: number;
  49493. private _refTexture;
  49494. private _ownRefractionTexture;
  49495. /**
  49496. * Gets or sets the refraction texture
  49497. * Please note that you are responsible for disposing the texture if you set it manually
  49498. */
  49499. refractionTexture: Texture;
  49500. /**
  49501. * Initializes the RefractionPostProcess
  49502. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  49503. * @param name The name of the effect.
  49504. * @param refractionTextureUrl Url of the refraction texture to use
  49505. * @param color the base color of the refraction (used to taint the rendering)
  49506. * @param depth simulated refraction depth
  49507. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  49508. * @param camera The camera to apply the render pass to.
  49509. * @param options The required width/height ratio to downsize to before computing the render pass.
  49510. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49511. * @param engine The engine which the post process will be applied. (default: current engine)
  49512. * @param reusable If the post process can be reused on the same frame. (default: false)
  49513. */
  49514. constructor(name: string, refractionTextureUrl: string,
  49515. /** the base color of the refraction (used to taint the rendering) */
  49516. color: Color3,
  49517. /** simulated refraction depth */
  49518. depth: number,
  49519. /** the coefficient of the base color (0 to remove base color tainting) */
  49520. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49521. /**
  49522. * Disposes of the post process
  49523. * @param camera Camera to dispose post process on
  49524. */
  49525. dispose(camera: Camera): void;
  49526. }
  49527. }
  49528. declare module BABYLON {
  49529. /** @hidden */
  49530. export var sharpenPixelShader: {
  49531. name: string;
  49532. shader: string;
  49533. };
  49534. }
  49535. declare module BABYLON {
  49536. /**
  49537. * The SharpenPostProcess applies a sharpen kernel to every pixel
  49538. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  49539. */
  49540. export class SharpenPostProcess extends PostProcess {
  49541. /**
  49542. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  49543. */
  49544. colorAmount: number;
  49545. /**
  49546. * How much sharpness should be applied (default: 0.3)
  49547. */
  49548. edgeAmount: number;
  49549. /**
  49550. * Creates a new instance ConvolutionPostProcess
  49551. * @param name The name of the effect.
  49552. * @param options The required width/height ratio to downsize to before computing the render pass.
  49553. * @param camera The camera to apply the render pass to.
  49554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49555. * @param engine The engine which the post process will be applied. (default: current engine)
  49556. * @param reusable If the post process can be reused on the same frame. (default: false)
  49557. * @param textureType Type of textures used when performing the post process. (default: 0)
  49558. * @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)
  49559. */
  49560. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49561. }
  49562. }
  49563. declare module BABYLON {
  49564. /**
  49565. * PostProcessRenderPipeline
  49566. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49567. */
  49568. export class PostProcessRenderPipeline {
  49569. private engine;
  49570. private _renderEffects;
  49571. private _renderEffectsForIsolatedPass;
  49572. /**
  49573. * @hidden
  49574. */
  49575. protected _cameras: Camera[];
  49576. /** @hidden */ name: string;
  49577. /**
  49578. * Initializes a PostProcessRenderPipeline
  49579. * @param engine engine to add the pipeline to
  49580. * @param name name of the pipeline
  49581. */
  49582. constructor(engine: Engine, name: string);
  49583. /**
  49584. * "PostProcessRenderPipeline"
  49585. * @returns "PostProcessRenderPipeline"
  49586. */
  49587. getClassName(): string;
  49588. /**
  49589. * If all the render effects in the pipeline are support
  49590. */
  49591. readonly isSupported: boolean;
  49592. /**
  49593. * Adds an effect to the pipeline
  49594. * @param renderEffect the effect to add
  49595. */
  49596. addEffect(renderEffect: PostProcessRenderEffect): void;
  49597. /** @hidden */ rebuild(): void;
  49598. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera): void;
  49599. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49600. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49601. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49602. /** @hidden */ attachCameras(cameras: Camera, unique: boolean): void;
  49603. /** @hidden */ attachCameras(cameras: Camera[], unique: boolean): void;
  49604. /** @hidden */ detachCameras(cameras: Camera): void;
  49605. /** @hidden */ detachCameras(cameras: Nullable<Camera[]>): void;
  49606. /** @hidden */ update(): void;
  49607. /** @hidden */ reset(): void;
  49608. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49609. /**
  49610. * Disposes of the pipeline
  49611. */
  49612. dispose(): void;
  49613. }
  49614. }
  49615. declare module BABYLON {
  49616. /**
  49617. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49618. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49619. */
  49620. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49621. private _scene;
  49622. private _camerasToBeAttached;
  49623. /**
  49624. * ID of the sharpen post process,
  49625. */
  49626. private readonly SharpenPostProcessId;
  49627. /**
  49628. * @ignore
  49629. * ID of the image processing post process;
  49630. */
  49631. readonly ImageProcessingPostProcessId: string;
  49632. /**
  49633. * @ignore
  49634. * ID of the Fast Approximate Anti-Aliasing post process;
  49635. */
  49636. readonly FxaaPostProcessId: string;
  49637. /**
  49638. * ID of the chromatic aberration post process,
  49639. */
  49640. private readonly ChromaticAberrationPostProcessId;
  49641. /**
  49642. * ID of the grain post process
  49643. */
  49644. private readonly GrainPostProcessId;
  49645. /**
  49646. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49647. */
  49648. sharpen: SharpenPostProcess;
  49649. private _sharpenEffect;
  49650. private bloom;
  49651. /**
  49652. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49653. */
  49654. depthOfField: DepthOfFieldEffect;
  49655. /**
  49656. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49657. */
  49658. fxaa: FxaaPostProcess;
  49659. /**
  49660. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49661. */
  49662. imageProcessing: ImageProcessingPostProcess;
  49663. /**
  49664. * Chromatic aberration post process which will shift rgb colors in the image
  49665. */
  49666. chromaticAberration: ChromaticAberrationPostProcess;
  49667. private _chromaticAberrationEffect;
  49668. /**
  49669. * Grain post process which add noise to the image
  49670. */
  49671. grain: GrainPostProcess;
  49672. private _grainEffect;
  49673. /**
  49674. * Glow post process which adds a glow to emmisive areas of the image
  49675. */
  49676. private _glowLayer;
  49677. /**
  49678. * Animations which can be used to tweak settings over a period of time
  49679. */
  49680. animations: Animation[];
  49681. private _imageProcessingConfigurationObserver;
  49682. private _sharpenEnabled;
  49683. private _bloomEnabled;
  49684. private _depthOfFieldEnabled;
  49685. private _depthOfFieldBlurLevel;
  49686. private _fxaaEnabled;
  49687. private _imageProcessingEnabled;
  49688. private _defaultPipelineTextureType;
  49689. private _bloomScale;
  49690. private _chromaticAberrationEnabled;
  49691. private _grainEnabled;
  49692. private _buildAllowed;
  49693. /**
  49694. * Enable or disable the sharpen process from the pipeline
  49695. */
  49696. sharpenEnabled: boolean;
  49697. private _resizeObserver;
  49698. private _hardwareScaleLevel;
  49699. private _bloomKernel;
  49700. /**
  49701. * Specifies the size of the bloom blur kernel, relative to the final output size
  49702. */
  49703. bloomKernel: number;
  49704. /**
  49705. * Specifies the weight of the bloom in the final rendering
  49706. */
  49707. private _bloomWeight;
  49708. /**
  49709. * Specifies the luma threshold for the area that will be blurred by the bloom
  49710. */
  49711. private _bloomThreshold;
  49712. private _hdr;
  49713. /**
  49714. * The strength of the bloom.
  49715. */
  49716. bloomWeight: number;
  49717. /**
  49718. * The strength of the bloom.
  49719. */
  49720. bloomThreshold: number;
  49721. /**
  49722. * The scale of the bloom, lower value will provide better performance.
  49723. */
  49724. bloomScale: number;
  49725. /**
  49726. * Enable or disable the bloom from the pipeline
  49727. */
  49728. bloomEnabled: boolean;
  49729. private _rebuildBloom;
  49730. /**
  49731. * If the depth of field is enabled.
  49732. */
  49733. depthOfFieldEnabled: boolean;
  49734. /**
  49735. * Blur level of the depth of field effect. (Higher blur will effect performance)
  49736. */
  49737. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  49738. /**
  49739. * If the anti aliasing is enabled.
  49740. */
  49741. fxaaEnabled: boolean;
  49742. private _samples;
  49743. /**
  49744. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49745. */
  49746. samples: number;
  49747. /**
  49748. * If image processing is enabled.
  49749. */
  49750. imageProcessingEnabled: boolean;
  49751. /**
  49752. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  49753. */
  49754. glowLayerEnabled: boolean;
  49755. /**
  49756. * Enable or disable the chromaticAberration process from the pipeline
  49757. */
  49758. chromaticAberrationEnabled: boolean;
  49759. /**
  49760. * Enable or disable the grain process from the pipeline
  49761. */
  49762. grainEnabled: boolean;
  49763. /**
  49764. * @constructor
  49765. * @param name - The rendering pipeline name (default: "")
  49766. * @param hdr - If high dynamic range textures should be used (default: true)
  49767. * @param scene - The scene linked to this pipeline (default: the last created scene)
  49768. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  49769. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  49770. */
  49771. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  49772. /**
  49773. * Force the compilation of the entire pipeline.
  49774. */
  49775. prepare(): void;
  49776. private _hasCleared;
  49777. private _prevPostProcess;
  49778. private _prevPrevPostProcess;
  49779. private _setAutoClearAndTextureSharing;
  49780. private _depthOfFieldSceneObserver;
  49781. private _buildPipeline;
  49782. private _disposePostProcesses;
  49783. /**
  49784. * Adds a camera to the pipeline
  49785. * @param camera the camera to be added
  49786. */
  49787. addCamera(camera: Camera): void;
  49788. /**
  49789. * Removes a camera from the pipeline
  49790. * @param camera the camera to remove
  49791. */
  49792. removeCamera(camera: Camera): void;
  49793. /**
  49794. * Dispose of the pipeline and stop all post processes
  49795. */
  49796. dispose(): void;
  49797. /**
  49798. * Serialize the rendering pipeline (Used when exporting)
  49799. * @returns the serialized object
  49800. */
  49801. serialize(): any;
  49802. /**
  49803. * Parse the serialized pipeline
  49804. * @param source Source pipeline.
  49805. * @param scene The scene to load the pipeline to.
  49806. * @param rootUrl The URL of the serialized pipeline.
  49807. * @returns An instantiated pipeline from the serialized object.
  49808. */
  49809. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  49810. }
  49811. }
  49812. declare module BABYLON {
  49813. /** @hidden */
  49814. export var lensHighlightsPixelShader: {
  49815. name: string;
  49816. shader: string;
  49817. };
  49818. }
  49819. declare module BABYLON {
  49820. /** @hidden */
  49821. export var depthOfFieldPixelShader: {
  49822. name: string;
  49823. shader: string;
  49824. };
  49825. }
  49826. declare module BABYLON {
  49827. /**
  49828. * BABYLON.JS Chromatic Aberration GLSL Shader
  49829. * Author: Olivier Guyot
  49830. * Separates very slightly R, G and B colors on the edges of the screen
  49831. * Inspired by Francois Tarlier & Martins Upitis
  49832. */
  49833. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  49834. /**
  49835. * @ignore
  49836. * The chromatic aberration PostProcess id in the pipeline
  49837. */
  49838. LensChromaticAberrationEffect: string;
  49839. /**
  49840. * @ignore
  49841. * The highlights enhancing PostProcess id in the pipeline
  49842. */
  49843. HighlightsEnhancingEffect: string;
  49844. /**
  49845. * @ignore
  49846. * The depth-of-field PostProcess id in the pipeline
  49847. */
  49848. LensDepthOfFieldEffect: string;
  49849. private _scene;
  49850. private _depthTexture;
  49851. private _grainTexture;
  49852. private _chromaticAberrationPostProcess;
  49853. private _highlightsPostProcess;
  49854. private _depthOfFieldPostProcess;
  49855. private _edgeBlur;
  49856. private _grainAmount;
  49857. private _chromaticAberration;
  49858. private _distortion;
  49859. private _highlightsGain;
  49860. private _highlightsThreshold;
  49861. private _dofDistance;
  49862. private _dofAperture;
  49863. private _dofDarken;
  49864. private _dofPentagon;
  49865. private _blurNoise;
  49866. /**
  49867. * @constructor
  49868. *
  49869. * Effect parameters are as follow:
  49870. * {
  49871. * chromatic_aberration: number; // from 0 to x (1 for realism)
  49872. * edge_blur: number; // from 0 to x (1 for realism)
  49873. * distortion: number; // from 0 to x (1 for realism)
  49874. * grain_amount: number; // from 0 to 1
  49875. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  49876. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  49877. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  49878. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  49879. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  49880. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  49881. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  49882. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  49883. * }
  49884. * Note: if an effect parameter is unset, effect is disabled
  49885. *
  49886. * @param name The rendering pipeline name
  49887. * @param parameters - An object containing all parameters (see above)
  49888. * @param scene The scene linked to this pipeline
  49889. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  49890. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49891. */
  49892. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  49893. /**
  49894. * Sets the amount of blur at the edges
  49895. * @param amount blur amount
  49896. */
  49897. setEdgeBlur(amount: number): void;
  49898. /**
  49899. * Sets edge blur to 0
  49900. */
  49901. disableEdgeBlur(): void;
  49902. /**
  49903. * Sets the amout of grain
  49904. * @param amount Amount of grain
  49905. */
  49906. setGrainAmount(amount: number): void;
  49907. /**
  49908. * Set grain amount to 0
  49909. */
  49910. disableGrain(): void;
  49911. /**
  49912. * Sets the chromatic aberration amount
  49913. * @param amount amount of chromatic aberration
  49914. */
  49915. setChromaticAberration(amount: number): void;
  49916. /**
  49917. * Sets chromatic aberration amount to 0
  49918. */
  49919. disableChromaticAberration(): void;
  49920. /**
  49921. * Sets the EdgeDistortion amount
  49922. * @param amount amount of EdgeDistortion
  49923. */
  49924. setEdgeDistortion(amount: number): void;
  49925. /**
  49926. * Sets edge distortion to 0
  49927. */
  49928. disableEdgeDistortion(): void;
  49929. /**
  49930. * Sets the FocusDistance amount
  49931. * @param amount amount of FocusDistance
  49932. */
  49933. setFocusDistance(amount: number): void;
  49934. /**
  49935. * Disables depth of field
  49936. */
  49937. disableDepthOfField(): void;
  49938. /**
  49939. * Sets the Aperture amount
  49940. * @param amount amount of Aperture
  49941. */
  49942. setAperture(amount: number): void;
  49943. /**
  49944. * Sets the DarkenOutOfFocus amount
  49945. * @param amount amount of DarkenOutOfFocus
  49946. */
  49947. setDarkenOutOfFocus(amount: number): void;
  49948. /**
  49949. * Creates a pentagon bokeh effect
  49950. */
  49951. enablePentagonBokeh(): void;
  49952. /**
  49953. * Disables the pentagon bokeh effect
  49954. */
  49955. disablePentagonBokeh(): void;
  49956. /**
  49957. * Enables noise blur
  49958. */
  49959. enableNoiseBlur(): void;
  49960. /**
  49961. * Disables noise blur
  49962. */
  49963. disableNoiseBlur(): void;
  49964. /**
  49965. * Sets the HighlightsGain amount
  49966. * @param amount amount of HighlightsGain
  49967. */
  49968. setHighlightsGain(amount: number): void;
  49969. /**
  49970. * Sets the HighlightsThreshold amount
  49971. * @param amount amount of HighlightsThreshold
  49972. */
  49973. setHighlightsThreshold(amount: number): void;
  49974. /**
  49975. * Disables highlights
  49976. */
  49977. disableHighlights(): void;
  49978. /**
  49979. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  49980. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  49981. */
  49982. dispose(disableDepthRender?: boolean): void;
  49983. private _createChromaticAberrationPostProcess;
  49984. private _createHighlightsPostProcess;
  49985. private _createDepthOfFieldPostProcess;
  49986. private _createGrainTexture;
  49987. }
  49988. }
  49989. declare module BABYLON {
  49990. /** @hidden */
  49991. export var ssao2PixelShader: {
  49992. name: string;
  49993. shader: string;
  49994. };
  49995. }
  49996. declare module BABYLON {
  49997. /** @hidden */
  49998. export var ssaoCombinePixelShader: {
  49999. name: string;
  50000. shader: string;
  50001. };
  50002. }
  50003. declare module BABYLON {
  50004. /**
  50005. * Render pipeline to produce ssao effect
  50006. */
  50007. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50008. /**
  50009. * @ignore
  50010. * The PassPostProcess id in the pipeline that contains the original scene color
  50011. */
  50012. SSAOOriginalSceneColorEffect: string;
  50013. /**
  50014. * @ignore
  50015. * The SSAO PostProcess id in the pipeline
  50016. */
  50017. SSAORenderEffect: string;
  50018. /**
  50019. * @ignore
  50020. * The horizontal blur PostProcess id in the pipeline
  50021. */
  50022. SSAOBlurHRenderEffect: string;
  50023. /**
  50024. * @ignore
  50025. * The vertical blur PostProcess id in the pipeline
  50026. */
  50027. SSAOBlurVRenderEffect: string;
  50028. /**
  50029. * @ignore
  50030. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50031. */
  50032. SSAOCombineRenderEffect: string;
  50033. /**
  50034. * The output strength of the SSAO post-process. Default value is 1.0.
  50035. */
  50036. totalStrength: number;
  50037. /**
  50038. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50039. */
  50040. maxZ: number;
  50041. /**
  50042. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50043. */
  50044. minZAspect: number;
  50045. private _samples;
  50046. /**
  50047. * Number of samples used for the SSAO calculations. Default value is 8
  50048. */
  50049. samples: number;
  50050. private _textureSamples;
  50051. /**
  50052. * Number of samples to use for antialiasing
  50053. */
  50054. textureSamples: number;
  50055. /**
  50056. * Ratio object used for SSAO ratio and blur ratio
  50057. */
  50058. private _ratio;
  50059. /**
  50060. * Dynamically generated sphere sampler.
  50061. */
  50062. private _sampleSphere;
  50063. /**
  50064. * Blur filter offsets
  50065. */
  50066. private _samplerOffsets;
  50067. private _expensiveBlur;
  50068. /**
  50069. * If bilateral blur should be used
  50070. */
  50071. expensiveBlur: boolean;
  50072. /**
  50073. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50074. */
  50075. radius: number;
  50076. /**
  50077. * The base color of the SSAO post-process
  50078. * The final result is "base + ssao" between [0, 1]
  50079. */
  50080. base: number;
  50081. /**
  50082. * Support test.
  50083. */
  50084. static readonly IsSupported: boolean;
  50085. private _scene;
  50086. private _depthTexture;
  50087. private _normalTexture;
  50088. private _randomTexture;
  50089. private _originalColorPostProcess;
  50090. private _ssaoPostProcess;
  50091. private _blurHPostProcess;
  50092. private _blurVPostProcess;
  50093. private _ssaoCombinePostProcess;
  50094. private _firstUpdate;
  50095. /**
  50096. * @constructor
  50097. * @param name The rendering pipeline name
  50098. * @param scene The scene linked to this pipeline
  50099. * @param ratio The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, blurRatio: 1.0 }
  50100. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50101. */
  50102. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50103. /**
  50104. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50105. */
  50106. dispose(disableGeometryBufferRenderer?: boolean): void;
  50107. private _createBlurPostProcess;
  50108. /** @hidden */ rebuild(): void;
  50109. private _bits;
  50110. private _radicalInverse_VdC;
  50111. private _hammersley;
  50112. private _hemisphereSample_uniform;
  50113. private _generateHemisphere;
  50114. private _createSSAOPostProcess;
  50115. private _createSSAOCombinePostProcess;
  50116. private _createRandomTexture;
  50117. /**
  50118. * Serialize the rendering pipeline (Used when exporting)
  50119. * @returns the serialized object
  50120. */
  50121. serialize(): any;
  50122. /**
  50123. * Parse the serialized pipeline
  50124. * @param source Source pipeline.
  50125. * @param scene The scene to load the pipeline to.
  50126. * @param rootUrl The URL of the serialized pipeline.
  50127. * @returns An instantiated pipeline from the serialized object.
  50128. */
  50129. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50130. }
  50131. }
  50132. declare module BABYLON {
  50133. /** @hidden */
  50134. export var ssaoPixelShader: {
  50135. name: string;
  50136. shader: string;
  50137. };
  50138. }
  50139. declare module BABYLON {
  50140. /**
  50141. * Render pipeline to produce ssao effect
  50142. */
  50143. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50144. /**
  50145. * @ignore
  50146. * The PassPostProcess id in the pipeline that contains the original scene color
  50147. */
  50148. SSAOOriginalSceneColorEffect: string;
  50149. /**
  50150. * @ignore
  50151. * The SSAO PostProcess id in the pipeline
  50152. */
  50153. SSAORenderEffect: string;
  50154. /**
  50155. * @ignore
  50156. * The horizontal blur PostProcess id in the pipeline
  50157. */
  50158. SSAOBlurHRenderEffect: string;
  50159. /**
  50160. * @ignore
  50161. * The vertical blur PostProcess id in the pipeline
  50162. */
  50163. SSAOBlurVRenderEffect: string;
  50164. /**
  50165. * @ignore
  50166. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50167. */
  50168. SSAOCombineRenderEffect: string;
  50169. /**
  50170. * The output strength of the SSAO post-process. Default value is 1.0.
  50171. */
  50172. totalStrength: number;
  50173. /**
  50174. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50175. */
  50176. radius: number;
  50177. /**
  50178. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50179. * Must not be equal to fallOff and superior to fallOff.
  50180. * Default value is 0.975
  50181. */
  50182. area: number;
  50183. /**
  50184. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50185. * Must not be equal to area and inferior to area.
  50186. * Default value is 0.0
  50187. */
  50188. fallOff: number;
  50189. /**
  50190. * The base color of the SSAO post-process
  50191. * The final result is "base + ssao" between [0, 1]
  50192. */
  50193. base: number;
  50194. private _scene;
  50195. private _depthTexture;
  50196. private _randomTexture;
  50197. private _originalColorPostProcess;
  50198. private _ssaoPostProcess;
  50199. private _blurHPostProcess;
  50200. private _blurVPostProcess;
  50201. private _ssaoCombinePostProcess;
  50202. private _firstUpdate;
  50203. /**
  50204. * @constructor
  50205. * @param name - The rendering pipeline name
  50206. * @param scene - The scene linked to this pipeline
  50207. * @param ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }
  50208. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50209. */
  50210. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50211. /**
  50212. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50213. */
  50214. dispose(disableDepthRender?: boolean): void;
  50215. private _createBlurPostProcess;
  50216. /** @hidden */ rebuild(): void;
  50217. private _createSSAOPostProcess;
  50218. private _createSSAOCombinePostProcess;
  50219. private _createRandomTexture;
  50220. }
  50221. }
  50222. declare module BABYLON {
  50223. /** @hidden */
  50224. export var standardPixelShader: {
  50225. name: string;
  50226. shader: string;
  50227. };
  50228. }
  50229. declare module BABYLON {
  50230. /**
  50231. * Standard rendering pipeline
  50232. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50233. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50234. */
  50235. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50236. /**
  50237. * Public members
  50238. */
  50239. /**
  50240. * Post-process which contains the original scene color before the pipeline applies all the effects
  50241. */
  50242. originalPostProcess: Nullable<PostProcess>;
  50243. /**
  50244. * Post-process used to down scale an image x4
  50245. */
  50246. downSampleX4PostProcess: Nullable<PostProcess>;
  50247. /**
  50248. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50249. */
  50250. brightPassPostProcess: Nullable<PostProcess>;
  50251. /**
  50252. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50253. */
  50254. blurHPostProcesses: PostProcess[];
  50255. /**
  50256. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50257. */
  50258. blurVPostProcesses: PostProcess[];
  50259. /**
  50260. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50261. */
  50262. textureAdderPostProcess: Nullable<PostProcess>;
  50263. /**
  50264. * Post-process used to create volumetric lighting effect
  50265. */
  50266. volumetricLightPostProcess: Nullable<PostProcess>;
  50267. /**
  50268. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50269. */
  50270. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50271. /**
  50272. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50273. */
  50274. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50275. /**
  50276. * Post-process used to merge the volumetric light effect and the real scene color
  50277. */
  50278. volumetricLightMergePostProces: Nullable<PostProcess>;
  50279. /**
  50280. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50281. */
  50282. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50283. /**
  50284. * Base post-process used to calculate the average luminance of the final image for HDR
  50285. */
  50286. luminancePostProcess: Nullable<PostProcess>;
  50287. /**
  50288. * Post-processes used to create down sample post-processes in order to get
  50289. * the average luminance of the final image for HDR
  50290. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50291. */
  50292. luminanceDownSamplePostProcesses: PostProcess[];
  50293. /**
  50294. * Post-process used to create a HDR effect (light adaptation)
  50295. */
  50296. hdrPostProcess: Nullable<PostProcess>;
  50297. /**
  50298. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50299. */
  50300. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50301. /**
  50302. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50303. */
  50304. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50305. /**
  50306. * Post-process used to merge the final HDR post-process and the real scene color
  50307. */
  50308. hdrFinalPostProcess: Nullable<PostProcess>;
  50309. /**
  50310. * Post-process used to create a lens flare effect
  50311. */
  50312. lensFlarePostProcess: Nullable<PostProcess>;
  50313. /**
  50314. * Post-process that merges the result of the lens flare post-process and the real scene color
  50315. */
  50316. lensFlareComposePostProcess: Nullable<PostProcess>;
  50317. /**
  50318. * Post-process used to create a motion blur effect
  50319. */
  50320. motionBlurPostProcess: Nullable<PostProcess>;
  50321. /**
  50322. * Post-process used to create a depth of field effect
  50323. */
  50324. depthOfFieldPostProcess: Nullable<PostProcess>;
  50325. /**
  50326. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50327. */
  50328. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50329. /**
  50330. * Represents the brightness threshold in order to configure the illuminated surfaces
  50331. */
  50332. brightThreshold: number;
  50333. /**
  50334. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50335. */
  50336. blurWidth: number;
  50337. /**
  50338. * Sets if the blur for highlighted surfaces must be only horizontal
  50339. */
  50340. horizontalBlur: boolean;
  50341. /**
  50342. * Sets the overall exposure used by the pipeline
  50343. */
  50344. exposure: number;
  50345. /**
  50346. * Texture used typically to simulate "dirty" on camera lens
  50347. */
  50348. lensTexture: Nullable<Texture>;
  50349. /**
  50350. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50351. */
  50352. volumetricLightCoefficient: number;
  50353. /**
  50354. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50355. */
  50356. volumetricLightPower: number;
  50357. /**
  50358. * Used the set the blur intensity to smooth the volumetric lights
  50359. */
  50360. volumetricLightBlurScale: number;
  50361. /**
  50362. * Light (spot or directional) used to generate the volumetric lights rays
  50363. * The source light must have a shadow generate so the pipeline can get its
  50364. * depth map
  50365. */
  50366. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50367. /**
  50368. * For eye adaptation, represents the minimum luminance the eye can see
  50369. */
  50370. hdrMinimumLuminance: number;
  50371. /**
  50372. * For eye adaptation, represents the decrease luminance speed
  50373. */
  50374. hdrDecreaseRate: number;
  50375. /**
  50376. * For eye adaptation, represents the increase luminance speed
  50377. */
  50378. hdrIncreaseRate: number;
  50379. /**
  50380. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50381. */
  50382. lensColorTexture: Nullable<Texture>;
  50383. /**
  50384. * The overall strengh for the lens flare effect
  50385. */
  50386. lensFlareStrength: number;
  50387. /**
  50388. * Dispersion coefficient for lens flare ghosts
  50389. */
  50390. lensFlareGhostDispersal: number;
  50391. /**
  50392. * Main lens flare halo width
  50393. */
  50394. lensFlareHaloWidth: number;
  50395. /**
  50396. * Based on the lens distortion effect, defines how much the lens flare result
  50397. * is distorted
  50398. */
  50399. lensFlareDistortionStrength: number;
  50400. /**
  50401. * Lens star texture must be used to simulate rays on the flares and is available
  50402. * in the documentation
  50403. */
  50404. lensStarTexture: Nullable<Texture>;
  50405. /**
  50406. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50407. * flare effect by taking account of the dirt texture
  50408. */
  50409. lensFlareDirtTexture: Nullable<Texture>;
  50410. /**
  50411. * Represents the focal length for the depth of field effect
  50412. */
  50413. depthOfFieldDistance: number;
  50414. /**
  50415. * Represents the blur intensity for the blurred part of the depth of field effect
  50416. */
  50417. depthOfFieldBlurWidth: number;
  50418. /**
  50419. * For motion blur, defines how much the image is blurred by the movement
  50420. */
  50421. motionStrength: number;
  50422. /**
  50423. * List of animations for the pipeline (IAnimatable implementation)
  50424. */
  50425. animations: Animation[];
  50426. /**
  50427. * Private members
  50428. */
  50429. private _scene;
  50430. private _currentDepthOfFieldSource;
  50431. private _basePostProcess;
  50432. private _hdrCurrentLuminance;
  50433. private _floatTextureType;
  50434. private _ratio;
  50435. private _bloomEnabled;
  50436. private _depthOfFieldEnabled;
  50437. private _vlsEnabled;
  50438. private _lensFlareEnabled;
  50439. private _hdrEnabled;
  50440. private _motionBlurEnabled;
  50441. private _fxaaEnabled;
  50442. private _motionBlurSamples;
  50443. private _volumetricLightStepsCount;
  50444. private _samples;
  50445. /**
  50446. * @ignore
  50447. * Specifies if the bloom pipeline is enabled
  50448. */
  50449. BloomEnabled: boolean;
  50450. /**
  50451. * @ignore
  50452. * Specifies if the depth of field pipeline is enabed
  50453. */
  50454. DepthOfFieldEnabled: boolean;
  50455. /**
  50456. * @ignore
  50457. * Specifies if the lens flare pipeline is enabed
  50458. */
  50459. LensFlareEnabled: boolean;
  50460. /**
  50461. * @ignore
  50462. * Specifies if the HDR pipeline is enabled
  50463. */
  50464. HDREnabled: boolean;
  50465. /**
  50466. * @ignore
  50467. * Specifies if the volumetric lights scattering effect is enabled
  50468. */
  50469. VLSEnabled: boolean;
  50470. /**
  50471. * @ignore
  50472. * Specifies if the motion blur effect is enabled
  50473. */
  50474. MotionBlurEnabled: boolean;
  50475. /**
  50476. * Specifies if anti-aliasing is enabled
  50477. */
  50478. fxaaEnabled: boolean;
  50479. /**
  50480. * Specifies the number of steps used to calculate the volumetric lights
  50481. * Typically in interval [50, 200]
  50482. */
  50483. volumetricLightStepsCount: number;
  50484. /**
  50485. * Specifies the number of samples used for the motion blur effect
  50486. * Typically in interval [16, 64]
  50487. */
  50488. motionBlurSamples: number;
  50489. /**
  50490. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50491. */
  50492. samples: number;
  50493. /**
  50494. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50495. * @constructor
  50496. * @param name The rendering pipeline name
  50497. * @param scene The scene linked to this pipeline
  50498. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  50499. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50500. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50501. */
  50502. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50503. private _buildPipeline;
  50504. private _createDownSampleX4PostProcess;
  50505. private _createBrightPassPostProcess;
  50506. private _createBlurPostProcesses;
  50507. private _createTextureAdderPostProcess;
  50508. private _createVolumetricLightPostProcess;
  50509. private _createLuminancePostProcesses;
  50510. private _createHdrPostProcess;
  50511. private _createLensFlarePostProcess;
  50512. private _createDepthOfFieldPostProcess;
  50513. private _createMotionBlurPostProcess;
  50514. private _getDepthTexture;
  50515. private _disposePostProcesses;
  50516. /**
  50517. * Dispose of the pipeline and stop all post processes
  50518. */
  50519. dispose(): void;
  50520. /**
  50521. * Serialize the rendering pipeline (Used when exporting)
  50522. * @returns the serialized object
  50523. */
  50524. serialize(): any;
  50525. /**
  50526. * Parse the serialized pipeline
  50527. * @param source Source pipeline.
  50528. * @param scene The scene to load the pipeline to.
  50529. * @param rootUrl The URL of the serialized pipeline.
  50530. * @returns An instantiated pipeline from the serialized object.
  50531. */
  50532. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50533. /**
  50534. * Luminance steps
  50535. */
  50536. static LuminanceSteps: number;
  50537. }
  50538. }
  50539. declare module BABYLON {
  50540. /**
  50541. * PostProcessRenderPipelineManager class
  50542. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50543. */
  50544. export class PostProcessRenderPipelineManager {
  50545. private _renderPipelines;
  50546. /**
  50547. * Initializes a PostProcessRenderPipelineManager
  50548. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50549. */
  50550. constructor();
  50551. /**
  50552. * Adds a pipeline to the manager
  50553. * @param renderPipeline The pipeline to add
  50554. */
  50555. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  50556. /**
  50557. * Attaches a camera to the pipeline
  50558. * @param renderPipelineName The name of the pipeline to attach to
  50559. * @param cameras the camera to attach
  50560. * @param unique if the camera can be attached multiple times to the pipeline
  50561. */
  50562. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  50563. /**
  50564. * Detaches a camera from the pipeline
  50565. * @param renderPipelineName The name of the pipeline to detach from
  50566. * @param cameras the camera to detach
  50567. */
  50568. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  50569. /**
  50570. * Enables an effect by name on a pipeline
  50571. * @param renderPipelineName the name of the pipeline to enable the effect in
  50572. * @param renderEffectName the name of the effect to enable
  50573. * @param cameras the cameras that the effect should be enabled on
  50574. */
  50575. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  50576. /**
  50577. * Disables an effect by name on a pipeline
  50578. * @param renderPipelineName the name of the pipeline to disable the effect in
  50579. * @param renderEffectName the name of the effect to disable
  50580. * @param cameras the cameras that the effect should be disabled on
  50581. */
  50582. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  50583. /**
  50584. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  50585. */
  50586. update(): void;
  50587. /** @hidden */ rebuild(): void;
  50588. /**
  50589. * Disposes of the manager and pipelines
  50590. */
  50591. dispose(): void;
  50592. }
  50593. }
  50594. declare module BABYLON {
  50595. interface Scene {
  50596. /** @hidden (Backing field) */ postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  50597. /**
  50598. * Gets the postprocess render pipeline manager
  50599. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50600. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50601. */
  50602. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  50603. }
  50604. /**
  50605. * Defines the Render Pipeline scene component responsible to rendering pipelines
  50606. */
  50607. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  50608. /**
  50609. * The component name helpfull to identify the component in the list of scene components.
  50610. */
  50611. readonly name: string;
  50612. /**
  50613. * The scene the component belongs to.
  50614. */
  50615. scene: Scene;
  50616. /**
  50617. * Creates a new instance of the component for the given scene
  50618. * @param scene Defines the scene to register the component in
  50619. */
  50620. constructor(scene: Scene);
  50621. /**
  50622. * Registers the component in a given scene
  50623. */
  50624. register(): void;
  50625. /**
  50626. * Rebuilds the elements related to this component in case of
  50627. * context lost for instance.
  50628. */
  50629. rebuild(): void;
  50630. /**
  50631. * Disposes the component and the associated ressources
  50632. */
  50633. dispose(): void;
  50634. private _gatherRenderTargets;
  50635. }
  50636. }
  50637. declare module BABYLON {
  50638. /** @hidden */
  50639. export var tonemapPixelShader: {
  50640. name: string;
  50641. shader: string;
  50642. };
  50643. }
  50644. declare module BABYLON {
  50645. /** Defines operator used for tonemapping */
  50646. export enum TonemappingOperator {
  50647. /** Hable */
  50648. Hable = 0,
  50649. /** Reinhard */
  50650. Reinhard = 1,
  50651. /** HejiDawson */
  50652. HejiDawson = 2,
  50653. /** Photographic */
  50654. Photographic = 3
  50655. }
  50656. /**
  50657. * Defines a post process to apply tone mapping
  50658. */
  50659. export class TonemapPostProcess extends PostProcess {
  50660. private _operator;
  50661. /** Defines the required exposure adjustement */
  50662. exposureAdjustment: number;
  50663. /**
  50664. * Creates a new TonemapPostProcess
  50665. * @param name defines the name of the postprocess
  50666. * @param _operator defines the operator to use
  50667. * @param exposureAdjustment defines the required exposure adjustement
  50668. * @param camera defines the camera to use (can be null)
  50669. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  50670. * @param engine defines the hosting engine (can be ignore if camera is set)
  50671. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50672. */
  50673. constructor(name: string, _operator: TonemappingOperator,
  50674. /** Defines the required exposure adjustement */
  50675. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  50676. }
  50677. }
  50678. declare module BABYLON {
  50679. /** @hidden */
  50680. export var depthVertexShader: {
  50681. name: string;
  50682. shader: string;
  50683. };
  50684. }
  50685. declare module BABYLON {
  50686. /** @hidden */
  50687. export var volumetricLightScatteringPixelShader: {
  50688. name: string;
  50689. shader: string;
  50690. };
  50691. }
  50692. declare module BABYLON {
  50693. /** @hidden */
  50694. export var volumetricLightScatteringPassPixelShader: {
  50695. name: string;
  50696. shader: string;
  50697. };
  50698. }
  50699. declare module BABYLON {
  50700. /**
  50701. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  50702. */
  50703. export class VolumetricLightScatteringPostProcess extends PostProcess {
  50704. private _volumetricLightScatteringPass;
  50705. private _volumetricLightScatteringRTT;
  50706. private _viewPort;
  50707. private _screenCoordinates;
  50708. private _cachedDefines;
  50709. /**
  50710. * If not undefined, the mesh position is computed from the attached node position
  50711. */
  50712. attachedNode: {
  50713. position: Vector3;
  50714. };
  50715. /**
  50716. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  50717. */
  50718. customMeshPosition: Vector3;
  50719. /**
  50720. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  50721. */
  50722. useCustomMeshPosition: boolean;
  50723. /**
  50724. * If the post-process should inverse the light scattering direction
  50725. */
  50726. invert: boolean;
  50727. /**
  50728. * The internal mesh used by the post-process
  50729. */
  50730. mesh: Mesh;
  50731. /**
  50732. * @hidden
  50733. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  50734. */
  50735. useDiffuseColor: boolean;
  50736. /**
  50737. * Array containing the excluded meshes not rendered in the internal pass
  50738. */
  50739. excludedMeshes: AbstractMesh[];
  50740. /**
  50741. * Controls the overall intensity of the post-process
  50742. */
  50743. exposure: number;
  50744. /**
  50745. * Dissipates each sample's contribution in range [0, 1]
  50746. */
  50747. decay: number;
  50748. /**
  50749. * Controls the overall intensity of each sample
  50750. */
  50751. weight: number;
  50752. /**
  50753. * Controls the density of each sample
  50754. */
  50755. density: number;
  50756. /**
  50757. * @constructor
  50758. * @param name The post-process name
  50759. * @param ratio The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  50760. * @param camera The camera that the post-process will be attached to
  50761. * @param mesh The mesh used to create the light scattering
  50762. * @param samples The post-process quality, default 100
  50763. * @param samplingModeThe post-process filtering mode
  50764. * @param engine The babylon engine
  50765. * @param reusable If the post-process is reusable
  50766. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  50767. */
  50768. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  50769. /**
  50770. * Returns the string "VolumetricLightScatteringPostProcess"
  50771. * @returns "VolumetricLightScatteringPostProcess"
  50772. */
  50773. getClassName(): string;
  50774. private _isReady;
  50775. /**
  50776. * Sets the new light position for light scattering effect
  50777. * @param position The new custom light position
  50778. */
  50779. setCustomMeshPosition(position: Vector3): void;
  50780. /**
  50781. * Returns the light position for light scattering effect
  50782. * @return Vector3 The custom light position
  50783. */
  50784. getCustomMeshPosition(): Vector3;
  50785. /**
  50786. * Disposes the internal assets and detaches the post-process from the camera
  50787. */
  50788. dispose(camera: Camera): void;
  50789. /**
  50790. * Returns the render target texture used by the post-process
  50791. * @return the render target texture used by the post-process
  50792. */
  50793. getPass(): RenderTargetTexture;
  50794. private _meshExcluded;
  50795. private _createPass;
  50796. private _updateMeshScreenCoordinates;
  50797. /**
  50798. * Creates a default mesh for the Volumeric Light Scattering post-process
  50799. * @param name The mesh name
  50800. * @param scene The scene where to create the mesh
  50801. * @return the default mesh
  50802. */
  50803. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  50804. }
  50805. }
  50806. declare module BABYLON {
  50807. interface Scene {
  50808. /** @hidden (Backing field) */ boundingBoxRenderer: BoundingBoxRenderer;
  50809. /** @hidden (Backing field) */ forceShowBoundingBoxes: boolean;
  50810. /**
  50811. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  50812. */
  50813. forceShowBoundingBoxes: boolean;
  50814. /**
  50815. * Gets the bounding box renderer associated with the scene
  50816. * @returns a BoundingBoxRenderer
  50817. */
  50818. getBoundingBoxRenderer(): BoundingBoxRenderer;
  50819. }
  50820. interface AbstractMesh {
  50821. /** @hidden (Backing field) */ showBoundingBox: boolean;
  50822. /**
  50823. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  50824. */
  50825. showBoundingBox: boolean;
  50826. }
  50827. /**
  50828. * Component responsible of rendering the bounding box of the meshes in a scene.
  50829. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  50830. */
  50831. export class BoundingBoxRenderer implements ISceneComponent {
  50832. /**
  50833. * The component name helpfull to identify the component in the list of scene components.
  50834. */
  50835. readonly name: string;
  50836. /**
  50837. * The scene the component belongs to.
  50838. */
  50839. scene: Scene;
  50840. /**
  50841. * Color of the bounding box lines placed in front of an object
  50842. */
  50843. frontColor: Color3;
  50844. /**
  50845. * Color of the bounding box lines placed behind an object
  50846. */
  50847. backColor: Color3;
  50848. /**
  50849. * Defines if the renderer should show the back lines or not
  50850. */
  50851. showBackLines: boolean;
  50852. /**
  50853. * @hidden
  50854. */
  50855. renderList: SmartArray<BoundingBox>;
  50856. private _colorShader;
  50857. private _vertexBuffers;
  50858. private _indexBuffer;
  50859. /**
  50860. * Instantiates a new bounding box renderer in a scene.
  50861. * @param scene the scene the renderer renders in
  50862. */
  50863. constructor(scene: Scene);
  50864. /**
  50865. * Registers the component in a given scene
  50866. */
  50867. register(): void;
  50868. private _evaluateSubMesh;
  50869. private _activeMesh;
  50870. private _prepareRessources;
  50871. private _createIndexBuffer;
  50872. /**
  50873. * Rebuilds the elements related to this component in case of
  50874. * context lost for instance.
  50875. */
  50876. rebuild(): void;
  50877. /**
  50878. * @hidden
  50879. */
  50880. reset(): void;
  50881. /**
  50882. * Render the bounding boxes of a specific rendering group
  50883. * @param renderingGroupId defines the rendering group to render
  50884. */
  50885. render(renderingGroupId: number): void;
  50886. /**
  50887. * In case of occlusion queries, we can render the occlusion bounding box through this method
  50888. * @param mesh Define the mesh to render the occlusion bounding box for
  50889. */
  50890. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  50891. /**
  50892. * Dispose and release the resources attached to this renderer.
  50893. */
  50894. dispose(): void;
  50895. }
  50896. }
  50897. declare module BABYLON {
  50898. /** @hidden */
  50899. export var depthPixelShader: {
  50900. name: string;
  50901. shader: string;
  50902. };
  50903. }
  50904. declare module BABYLON {
  50905. /**
  50906. * This represents a depth renderer in Babylon.
  50907. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  50908. */
  50909. export class DepthRenderer {
  50910. private _scene;
  50911. private _depthMap;
  50912. private _effect;
  50913. private _cachedDefines;
  50914. private _camera;
  50915. /**
  50916. * Specifiess that the depth renderer will only be used within
  50917. * the camera it is created for.
  50918. * This can help forcing its rendering during the camera processing.
  50919. */
  50920. useOnlyInActiveCamera: boolean;
  50921. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  50922. /**
  50923. * Instantiates a depth renderer
  50924. * @param scene The scene the renderer belongs to
  50925. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  50926. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  50927. */
  50928. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  50929. /**
  50930. * Creates the depth rendering effect and checks if the effect is ready.
  50931. * @param subMesh The submesh to be used to render the depth map of
  50932. * @param useInstances If multiple world instances should be used
  50933. * @returns if the depth renderer is ready to render the depth map
  50934. */
  50935. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50936. /**
  50937. * Gets the texture which the depth map will be written to.
  50938. * @returns The depth map texture
  50939. */
  50940. getDepthMap(): RenderTargetTexture;
  50941. /**
  50942. * Disposes of the depth renderer.
  50943. */
  50944. dispose(): void;
  50945. }
  50946. }
  50947. declare module BABYLON {
  50948. interface Scene {
  50949. /** @hidden (Backing field) */ depthRenderer: {
  50950. [id: string]: DepthRenderer;
  50951. };
  50952. /**
  50953. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  50954. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  50955. * @returns the created depth renderer
  50956. */
  50957. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  50958. /**
  50959. * Disables a depth renderer for a given camera
  50960. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  50961. */
  50962. disableDepthRenderer(camera?: Nullable<Camera>): void;
  50963. }
  50964. /**
  50965. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  50966. * in several rendering techniques.
  50967. */
  50968. export class DepthRendererSceneComponent implements ISceneComponent {
  50969. /**
  50970. * The component name helpfull to identify the component in the list of scene components.
  50971. */
  50972. readonly name: string;
  50973. /**
  50974. * The scene the component belongs to.
  50975. */
  50976. scene: Scene;
  50977. /**
  50978. * Creates a new instance of the component for the given scene
  50979. * @param scene Defines the scene to register the component in
  50980. */
  50981. constructor(scene: Scene);
  50982. /**
  50983. * Registers the component in a given scene
  50984. */
  50985. register(): void;
  50986. /**
  50987. * Rebuilds the elements related to this component in case of
  50988. * context lost for instance.
  50989. */
  50990. rebuild(): void;
  50991. /**
  50992. * Disposes the component and the associated ressources
  50993. */
  50994. dispose(): void;
  50995. private _gatherRenderTargets;
  50996. private _gatherActiveCameraRenderTargets;
  50997. }
  50998. }
  50999. declare module BABYLON {
  51000. interface Scene {
  51001. /** @hidden (Backing field) */ geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51002. /**
  51003. * Gets or Sets the current geometry buffer associated to the scene.
  51004. */
  51005. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51006. /**
  51007. * Enables a GeometryBufferRender and associates it with the scene
  51008. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  51009. * @returns the GeometryBufferRenderer
  51010. */
  51011. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  51012. /**
  51013. * Disables the GeometryBufferRender associated with the scene
  51014. */
  51015. disableGeometryBufferRenderer(): void;
  51016. }
  51017. /**
  51018. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  51019. * in several rendering techniques.
  51020. */
  51021. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  51022. /**
  51023. * The component name helpful to identify the component in the list of scene components.
  51024. */
  51025. readonly name: string;
  51026. /**
  51027. * The scene the component belongs to.
  51028. */
  51029. scene: Scene;
  51030. /**
  51031. * Creates a new instance of the component for the given scene
  51032. * @param scene Defines the scene to register the component in
  51033. */
  51034. constructor(scene: Scene);
  51035. /**
  51036. * Registers the component in a given scene
  51037. */
  51038. register(): void;
  51039. /**
  51040. * Rebuilds the elements related to this component in case of
  51041. * context lost for instance.
  51042. */
  51043. rebuild(): void;
  51044. /**
  51045. * Disposes the component and the associated ressources
  51046. */
  51047. dispose(): void;
  51048. private _gatherRenderTargets;
  51049. }
  51050. }
  51051. declare module BABYLON {
  51052. /** @hidden */
  51053. export var outlinePixelShader: {
  51054. name: string;
  51055. shader: string;
  51056. };
  51057. }
  51058. declare module BABYLON {
  51059. /** @hidden */
  51060. export var outlineVertexShader: {
  51061. name: string;
  51062. shader: string;
  51063. };
  51064. }
  51065. declare module BABYLON {
  51066. interface Scene {
  51067. /** @hidden */ outlineRenderer: OutlineRenderer;
  51068. /**
  51069. * Gets the outline renderer associated with the scene
  51070. * @returns a OutlineRenderer
  51071. */
  51072. getOutlineRenderer(): OutlineRenderer;
  51073. }
  51074. interface AbstractMesh {
  51075. /** @hidden (Backing field) */ renderOutline: boolean;
  51076. /**
  51077. * Gets or sets a boolean indicating if the outline must be rendered as well
  51078. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  51079. */
  51080. renderOutline: boolean;
  51081. /** @hidden (Backing field) */ renderOverlay: boolean;
  51082. /**
  51083. * Gets or sets a boolean indicating if the overlay must be rendered as well
  51084. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  51085. */
  51086. renderOverlay: boolean;
  51087. }
  51088. /**
  51089. * This class is responsible to draw bothe outline/overlay of meshes.
  51090. * It should not be used directly but through the available method on mesh.
  51091. */
  51092. export class OutlineRenderer implements ISceneComponent {
  51093. /**
  51094. * The name of the component. Each component must have a unique name.
  51095. */
  51096. name: string;
  51097. /**
  51098. * The scene the component belongs to.
  51099. */
  51100. scene: Scene;
  51101. /**
  51102. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  51103. */
  51104. zOffset: number;
  51105. private _engine;
  51106. private _effect;
  51107. private _cachedDefines;
  51108. private _savedDepthWrite;
  51109. /**
  51110. * Instantiates a new outline renderer. (There could be only one per scene).
  51111. * @param scene Defines the scene it belongs to
  51112. */
  51113. constructor(scene: Scene);
  51114. /**
  51115. * Register the component to one instance of a scene.
  51116. */
  51117. register(): void;
  51118. /**
  51119. * Rebuilds the elements related to this component in case of
  51120. * context lost for instance.
  51121. */
  51122. rebuild(): void;
  51123. /**
  51124. * Disposes the component and the associated ressources.
  51125. */
  51126. dispose(): void;
  51127. /**
  51128. * Renders the outline in the canvas.
  51129. * @param subMesh Defines the sumesh to render
  51130. * @param batch Defines the batch of meshes in case of instances
  51131. * @param useOverlay Defines if the rendering is for the overlay or the outline
  51132. */
  51133. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  51134. /**
  51135. * Returns whether or not the outline renderer is ready for a given submesh.
  51136. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  51137. * @param subMesh Defines the submesh to check readyness for
  51138. * @param useInstances Defines wheter wee are trying to render instances or not
  51139. * @returns true if ready otherwise false
  51140. */
  51141. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51142. private _beforeRenderingMesh;
  51143. private _afterRenderingMesh;
  51144. }
  51145. }
  51146. declare module BABYLON {
  51147. /**
  51148. * Defines the list of states available for a task inside a AssetsManager
  51149. */
  51150. export enum AssetTaskState {
  51151. /**
  51152. * Initialization
  51153. */
  51154. INIT = 0,
  51155. /**
  51156. * Running
  51157. */
  51158. RUNNING = 1,
  51159. /**
  51160. * Done
  51161. */
  51162. DONE = 2,
  51163. /**
  51164. * Error
  51165. */
  51166. ERROR = 3
  51167. }
  51168. /**
  51169. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  51170. */
  51171. export abstract class AbstractAssetTask {
  51172. /**
  51173. * Task name
  51174. */ name: string;
  51175. /**
  51176. * Callback called when the task is successful
  51177. */
  51178. onSuccess: (task: any) => void;
  51179. /**
  51180. * Callback called when the task is not successful
  51181. */
  51182. onError: (task: any, message?: string, exception?: any) => void;
  51183. /**
  51184. * Creates a new AssetsManager
  51185. * @param name defines the name of the task
  51186. */
  51187. constructor(
  51188. /**
  51189. * Task name
  51190. */ name: string);
  51191. private _isCompleted;
  51192. private _taskState;
  51193. private _errorObject;
  51194. /**
  51195. * Get if the task is completed
  51196. */
  51197. readonly isCompleted: boolean;
  51198. /**
  51199. * Gets the current state of the task
  51200. */
  51201. readonly taskState: AssetTaskState;
  51202. /**
  51203. * Gets the current error object (if task is in error)
  51204. */
  51205. readonly errorObject: {
  51206. message?: string;
  51207. exception?: any;
  51208. };
  51209. /**
  51210. * Internal only
  51211. * @hidden
  51212. */ setErrorObject(message?: string, exception?: any): void;
  51213. /**
  51214. * Execute the current task
  51215. * @param scene defines the scene where you want your assets to be loaded
  51216. * @param onSuccess is a callback called when the task is successfully executed
  51217. * @param onError is a callback called if an error occurs
  51218. */
  51219. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51220. /**
  51221. * Execute the current task
  51222. * @param scene defines the scene where you want your assets to be loaded
  51223. * @param onSuccess is a callback called when the task is successfully executed
  51224. * @param onError is a callback called if an error occurs
  51225. */
  51226. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51227. /**
  51228. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  51229. * This can be used with failed tasks that have the reason for failure fixed.
  51230. */
  51231. reset(): void;
  51232. private onErrorCallback;
  51233. private onDoneCallback;
  51234. }
  51235. /**
  51236. * Define the interface used by progress events raised during assets loading
  51237. */
  51238. export interface IAssetsProgressEvent {
  51239. /**
  51240. * Defines the number of remaining tasks to process
  51241. */
  51242. remainingCount: number;
  51243. /**
  51244. * Defines the total number of tasks
  51245. */
  51246. totalCount: number;
  51247. /**
  51248. * Defines the task that was just processed
  51249. */
  51250. task: AbstractAssetTask;
  51251. }
  51252. /**
  51253. * Class used to share progress information about assets loading
  51254. */
  51255. export class AssetsProgressEvent implements IAssetsProgressEvent {
  51256. /**
  51257. * Defines the number of remaining tasks to process
  51258. */
  51259. remainingCount: number;
  51260. /**
  51261. * Defines the total number of tasks
  51262. */
  51263. totalCount: number;
  51264. /**
  51265. * Defines the task that was just processed
  51266. */
  51267. task: AbstractAssetTask;
  51268. /**
  51269. * Creates a AssetsProgressEvent
  51270. * @param remainingCount defines the number of remaining tasks to process
  51271. * @param totalCount defines the total number of tasks
  51272. * @param task defines the task that was just processed
  51273. */
  51274. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  51275. }
  51276. /**
  51277. * Define a task used by AssetsManager to load meshes
  51278. */
  51279. export class MeshAssetTask extends AbstractAssetTask {
  51280. /**
  51281. * Defines the name of the task
  51282. */
  51283. name: string;
  51284. /**
  51285. * Defines the list of mesh's names you want to load
  51286. */
  51287. meshesNames: any;
  51288. /**
  51289. * Defines the root url to use as a base to load your meshes and associated resources
  51290. */
  51291. rootUrl: string;
  51292. /**
  51293. * Defines the filename of the scene to load from
  51294. */
  51295. sceneFilename: string;
  51296. /**
  51297. * Gets the list of loaded meshes
  51298. */
  51299. loadedMeshes: Array<AbstractMesh>;
  51300. /**
  51301. * Gets the list of loaded particle systems
  51302. */
  51303. loadedParticleSystems: Array<IParticleSystem>;
  51304. /**
  51305. * Gets the list of loaded skeletons
  51306. */
  51307. loadedSkeletons: Array<Skeleton>;
  51308. /**
  51309. * Gets the list of loaded animation groups
  51310. */
  51311. loadedAnimationGroups: Array<AnimationGroup>;
  51312. /**
  51313. * Callback called when the task is successful
  51314. */
  51315. onSuccess: (task: MeshAssetTask) => void;
  51316. /**
  51317. * Callback called when the task is successful
  51318. */
  51319. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  51320. /**
  51321. * Creates a new MeshAssetTask
  51322. * @param name defines the name of the task
  51323. * @param meshesNames defines the list of mesh's names you want to load
  51324. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  51325. * @param sceneFilename defines the filename of the scene to load from
  51326. */
  51327. constructor(
  51328. /**
  51329. * Defines the name of the task
  51330. */
  51331. name: string,
  51332. /**
  51333. * Defines the list of mesh's names you want to load
  51334. */
  51335. meshesNames: any,
  51336. /**
  51337. * Defines the root url to use as a base to load your meshes and associated resources
  51338. */
  51339. rootUrl: string,
  51340. /**
  51341. * Defines the filename of the scene to load from
  51342. */
  51343. sceneFilename: string);
  51344. /**
  51345. * Execute the current task
  51346. * @param scene defines the scene where you want your assets to be loaded
  51347. * @param onSuccess is a callback called when the task is successfully executed
  51348. * @param onError is a callback called if an error occurs
  51349. */
  51350. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51351. }
  51352. /**
  51353. * Define a task used by AssetsManager to load text content
  51354. */
  51355. export class TextFileAssetTask extends AbstractAssetTask {
  51356. /**
  51357. * Defines the name of the task
  51358. */
  51359. name: string;
  51360. /**
  51361. * Defines the location of the file to load
  51362. */
  51363. url: string;
  51364. /**
  51365. * Gets the loaded text string
  51366. */
  51367. text: string;
  51368. /**
  51369. * Callback called when the task is successful
  51370. */
  51371. onSuccess: (task: TextFileAssetTask) => void;
  51372. /**
  51373. * Callback called when the task is successful
  51374. */
  51375. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  51376. /**
  51377. * Creates a new TextFileAssetTask object
  51378. * @param name defines the name of the task
  51379. * @param url defines the location of the file to load
  51380. */
  51381. constructor(
  51382. /**
  51383. * Defines the name of the task
  51384. */
  51385. name: string,
  51386. /**
  51387. * Defines the location of the file to load
  51388. */
  51389. url: string);
  51390. /**
  51391. * Execute the current task
  51392. * @param scene defines the scene where you want your assets to be loaded
  51393. * @param onSuccess is a callback called when the task is successfully executed
  51394. * @param onError is a callback called if an error occurs
  51395. */
  51396. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51397. }
  51398. /**
  51399. * Define a task used by AssetsManager to load binary data
  51400. */
  51401. export class BinaryFileAssetTask extends AbstractAssetTask {
  51402. /**
  51403. * Defines the name of the task
  51404. */
  51405. name: string;
  51406. /**
  51407. * Defines the location of the file to load
  51408. */
  51409. url: string;
  51410. /**
  51411. * Gets the lodaded data (as an array buffer)
  51412. */
  51413. data: ArrayBuffer;
  51414. /**
  51415. * Callback called when the task is successful
  51416. */
  51417. onSuccess: (task: BinaryFileAssetTask) => void;
  51418. /**
  51419. * Callback called when the task is successful
  51420. */
  51421. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  51422. /**
  51423. * Creates a new BinaryFileAssetTask object
  51424. * @param name defines the name of the new task
  51425. * @param url defines the location of the file to load
  51426. */
  51427. constructor(
  51428. /**
  51429. * Defines the name of the task
  51430. */
  51431. name: string,
  51432. /**
  51433. * Defines the location of the file to load
  51434. */
  51435. url: string);
  51436. /**
  51437. * Execute the current task
  51438. * @param scene defines the scene where you want your assets to be loaded
  51439. * @param onSuccess is a callback called when the task is successfully executed
  51440. * @param onError is a callback called if an error occurs
  51441. */
  51442. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51443. }
  51444. /**
  51445. * Define a task used by AssetsManager to load images
  51446. */
  51447. export class ImageAssetTask extends AbstractAssetTask {
  51448. /**
  51449. * Defines the name of the task
  51450. */
  51451. name: string;
  51452. /**
  51453. * Defines the location of the image to load
  51454. */
  51455. url: string;
  51456. /**
  51457. * Gets the loaded images
  51458. */
  51459. image: HTMLImageElement;
  51460. /**
  51461. * Callback called when the task is successful
  51462. */
  51463. onSuccess: (task: ImageAssetTask) => void;
  51464. /**
  51465. * Callback called when the task is successful
  51466. */
  51467. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  51468. /**
  51469. * Creates a new ImageAssetTask
  51470. * @param name defines the name of the task
  51471. * @param url defines the location of the image to load
  51472. */
  51473. constructor(
  51474. /**
  51475. * Defines the name of the task
  51476. */
  51477. name: string,
  51478. /**
  51479. * Defines the location of the image to load
  51480. */
  51481. url: string);
  51482. /**
  51483. * Execute the current task
  51484. * @param scene defines the scene where you want your assets to be loaded
  51485. * @param onSuccess is a callback called when the task is successfully executed
  51486. * @param onError is a callback called if an error occurs
  51487. */
  51488. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51489. }
  51490. /**
  51491. * Defines the interface used by texture loading tasks
  51492. */
  51493. export interface ITextureAssetTask<TEX extends BaseTexture> {
  51494. /**
  51495. * Gets the loaded texture
  51496. */
  51497. texture: TEX;
  51498. }
  51499. /**
  51500. * Define a task used by AssetsManager to load 2D textures
  51501. */
  51502. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  51503. /**
  51504. * Defines the name of the task
  51505. */
  51506. name: string;
  51507. /**
  51508. * Defines the location of the file to load
  51509. */
  51510. url: string;
  51511. /**
  51512. * Defines if mipmap should not be generated (default is false)
  51513. */
  51514. noMipmap?: boolean | undefined;
  51515. /**
  51516. * Defines if texture must be inverted on Y axis (default is false)
  51517. */
  51518. invertY?: boolean | undefined;
  51519. /**
  51520. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51521. */
  51522. samplingMode: number;
  51523. /**
  51524. * Gets the loaded texture
  51525. */
  51526. texture: Texture;
  51527. /**
  51528. * Callback called when the task is successful
  51529. */
  51530. onSuccess: (task: TextureAssetTask) => void;
  51531. /**
  51532. * Callback called when the task is successful
  51533. */
  51534. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  51535. /**
  51536. * Creates a new TextureAssetTask object
  51537. * @param name defines the name of the task
  51538. * @param url defines the location of the file to load
  51539. * @param noMipmap defines if mipmap should not be generated (default is false)
  51540. * @param invertY defines if texture must be inverted on Y axis (default is false)
  51541. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51542. */
  51543. constructor(
  51544. /**
  51545. * Defines the name of the task
  51546. */
  51547. name: string,
  51548. /**
  51549. * Defines the location of the file to load
  51550. */
  51551. url: string,
  51552. /**
  51553. * Defines if mipmap should not be generated (default is false)
  51554. */
  51555. noMipmap?: boolean | undefined,
  51556. /**
  51557. * Defines if texture must be inverted on Y axis (default is false)
  51558. */
  51559. invertY?: boolean | undefined,
  51560. /**
  51561. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51562. */
  51563. samplingMode?: number);
  51564. /**
  51565. * Execute the current task
  51566. * @param scene defines the scene where you want your assets to be loaded
  51567. * @param onSuccess is a callback called when the task is successfully executed
  51568. * @param onError is a callback called if an error occurs
  51569. */
  51570. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51571. }
  51572. /**
  51573. * Define a task used by AssetsManager to load cube textures
  51574. */
  51575. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  51576. /**
  51577. * Defines the name of the task
  51578. */
  51579. name: string;
  51580. /**
  51581. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51582. */
  51583. url: string;
  51584. /**
  51585. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51586. */
  51587. extensions?: string[] | undefined;
  51588. /**
  51589. * Defines if mipmaps should not be generated (default is false)
  51590. */
  51591. noMipmap?: boolean | undefined;
  51592. /**
  51593. * Defines the explicit list of files (undefined by default)
  51594. */
  51595. files?: string[] | undefined;
  51596. /**
  51597. * Gets the loaded texture
  51598. */
  51599. texture: CubeTexture;
  51600. /**
  51601. * Callback called when the task is successful
  51602. */
  51603. onSuccess: (task: CubeTextureAssetTask) => void;
  51604. /**
  51605. * Callback called when the task is successful
  51606. */
  51607. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  51608. /**
  51609. * Creates a new CubeTextureAssetTask
  51610. * @param name defines the name of the task
  51611. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51612. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51613. * @param noMipmap defines if mipmaps should not be generated (default is false)
  51614. * @param files defines the explicit list of files (undefined by default)
  51615. */
  51616. constructor(
  51617. /**
  51618. * Defines the name of the task
  51619. */
  51620. name: string,
  51621. /**
  51622. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51623. */
  51624. url: string,
  51625. /**
  51626. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51627. */
  51628. extensions?: string[] | undefined,
  51629. /**
  51630. * Defines if mipmaps should not be generated (default is false)
  51631. */
  51632. noMipmap?: boolean | undefined,
  51633. /**
  51634. * Defines the explicit list of files (undefined by default)
  51635. */
  51636. files?: string[] | undefined);
  51637. /**
  51638. * Execute the current task
  51639. * @param scene defines the scene where you want your assets to be loaded
  51640. * @param onSuccess is a callback called when the task is successfully executed
  51641. * @param onError is a callback called if an error occurs
  51642. */
  51643. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51644. }
  51645. /**
  51646. * Define a task used by AssetsManager to load HDR cube textures
  51647. */
  51648. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  51649. /**
  51650. * Defines the name of the task
  51651. */
  51652. name: string;
  51653. /**
  51654. * Defines the location of the file to load
  51655. */
  51656. url: string;
  51657. /**
  51658. * Defines the desired size (the more it increases the longer the generation will be)
  51659. */
  51660. size: number;
  51661. /**
  51662. * Defines if mipmaps should not be generated (default is false)
  51663. */
  51664. noMipmap: boolean;
  51665. /**
  51666. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  51667. */
  51668. generateHarmonics: boolean;
  51669. /**
  51670. * 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)
  51671. */
  51672. gammaSpace: boolean;
  51673. /**
  51674. * Internal Use Only
  51675. */
  51676. reserved: boolean;
  51677. /**
  51678. * Gets the loaded texture
  51679. */
  51680. texture: HDRCubeTexture;
  51681. /**
  51682. * Callback called when the task is successful
  51683. */
  51684. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  51685. /**
  51686. * Callback called when the task is successful
  51687. */
  51688. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  51689. /**
  51690. * Creates a new HDRCubeTextureAssetTask object
  51691. * @param name defines the name of the task
  51692. * @param url defines the location of the file to load
  51693. * @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.
  51694. * @param noMipmap defines if mipmaps should not be generated (default is false)
  51695. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  51696. * @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)
  51697. * @param reserved Internal use only
  51698. */
  51699. constructor(
  51700. /**
  51701. * Defines the name of the task
  51702. */
  51703. name: string,
  51704. /**
  51705. * Defines the location of the file to load
  51706. */
  51707. url: string,
  51708. /**
  51709. * Defines the desired size (the more it increases the longer the generation will be)
  51710. */
  51711. size: number,
  51712. /**
  51713. * Defines if mipmaps should not be generated (default is false)
  51714. */
  51715. noMipmap?: boolean,
  51716. /**
  51717. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  51718. */
  51719. generateHarmonics?: boolean,
  51720. /**
  51721. * 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)
  51722. */
  51723. gammaSpace?: boolean,
  51724. /**
  51725. * Internal Use Only
  51726. */
  51727. reserved?: boolean);
  51728. /**
  51729. * Execute the current task
  51730. * @param scene defines the scene where you want your assets to be loaded
  51731. * @param onSuccess is a callback called when the task is successfully executed
  51732. * @param onError is a callback called if an error occurs
  51733. */
  51734. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51735. }
  51736. /**
  51737. * This class can be used to easily import assets into a scene
  51738. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  51739. */
  51740. export class AssetsManager {
  51741. private _scene;
  51742. private _isLoading;
  51743. protected _tasks: AbstractAssetTask[];
  51744. protected _waitingTasksCount: number;
  51745. protected _totalTasksCount: number;
  51746. /**
  51747. * Callback called when all tasks are processed
  51748. */
  51749. onFinish: (tasks: AbstractAssetTask[]) => void;
  51750. /**
  51751. * Callback called when a task is successful
  51752. */
  51753. onTaskSuccess: (task: AbstractAssetTask) => void;
  51754. /**
  51755. * Callback called when a task had an error
  51756. */
  51757. onTaskError: (task: AbstractAssetTask) => void;
  51758. /**
  51759. * Callback called when a task is done (whatever the result is)
  51760. */
  51761. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  51762. /**
  51763. * Observable called when all tasks are processed
  51764. */
  51765. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  51766. /**
  51767. * Observable called when a task had an error
  51768. */
  51769. onTaskErrorObservable: Observable<AbstractAssetTask>;
  51770. /**
  51771. * Observable called when a task is successful
  51772. */
  51773. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  51774. /**
  51775. * Observable called when a task is done (whatever the result is)
  51776. */
  51777. onProgressObservable: Observable<IAssetsProgressEvent>;
  51778. /**
  51779. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  51780. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  51781. */
  51782. useDefaultLoadingScreen: boolean;
  51783. /**
  51784. * Creates a new AssetsManager
  51785. * @param scene defines the scene to work on
  51786. */
  51787. constructor(scene: Scene);
  51788. /**
  51789. * Add a MeshAssetTask to the list of active tasks
  51790. * @param taskName defines the name of the new task
  51791. * @param meshesNames defines the name of meshes to load
  51792. * @param rootUrl defines the root url to use to locate files
  51793. * @param sceneFilename defines the filename of the scene file
  51794. * @returns a new MeshAssetTask object
  51795. */
  51796. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  51797. /**
  51798. * Add a TextFileAssetTask to the list of active tasks
  51799. * @param taskName defines the name of the new task
  51800. * @param url defines the url of the file to load
  51801. * @returns a new TextFileAssetTask object
  51802. */
  51803. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  51804. /**
  51805. * Add a BinaryFileAssetTask to the list of active tasks
  51806. * @param taskName defines the name of the new task
  51807. * @param url defines the url of the file to load
  51808. * @returns a new BinaryFileAssetTask object
  51809. */
  51810. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  51811. /**
  51812. * Add a ImageAssetTask to the list of active tasks
  51813. * @param taskName defines the name of the new task
  51814. * @param url defines the url of the file to load
  51815. * @returns a new ImageAssetTask object
  51816. */
  51817. addImageTask(taskName: string, url: string): ImageAssetTask;
  51818. /**
  51819. * Add a TextureAssetTask to the list of active tasks
  51820. * @param taskName defines the name of the new task
  51821. * @param url defines the url of the file to load
  51822. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  51823. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  51824. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51825. * @returns a new TextureAssetTask object
  51826. */
  51827. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  51828. /**
  51829. * Add a CubeTextureAssetTask to the list of active tasks
  51830. * @param taskName defines the name of the new task
  51831. * @param url defines the url of the file to load
  51832. * @param extensions defines the extension to use to load the cube map (can be null)
  51833. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  51834. * @param files defines the list of files to load (can be null)
  51835. * @returns a new CubeTextureAssetTask object
  51836. */
  51837. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  51838. /**
  51839. *
  51840. * Add a HDRCubeTextureAssetTask to the list of active tasks
  51841. * @param taskName defines the name of the new task
  51842. * @param url defines the url of the file to load
  51843. * @param size defines the size you want for the cubemap (can be null)
  51844. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  51845. * @param generateHarmonics defines if you want to automatically generate (true by default)
  51846. * @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)
  51847. * @param reserved Internal use only
  51848. * @returns a new HDRCubeTextureAssetTask object
  51849. */
  51850. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  51851. /**
  51852. * Remove a task from the assets manager.
  51853. * @param task the task to remove
  51854. */
  51855. removeTask(task: AbstractAssetTask): void;
  51856. private _decreaseWaitingTasksCount;
  51857. private _runTask;
  51858. /**
  51859. * Reset the AssetsManager and remove all tasks
  51860. * @return the current instance of the AssetsManager
  51861. */
  51862. reset(): AssetsManager;
  51863. /**
  51864. * Start the loading process
  51865. * @return the current instance of the AssetsManager
  51866. */
  51867. load(): AssetsManager;
  51868. }
  51869. }
  51870. declare module BABYLON {
  51871. /**
  51872. * Wrapper class for promise with external resolve and reject.
  51873. */
  51874. export class Deferred<T> {
  51875. /**
  51876. * The promise associated with this deferred object.
  51877. */
  51878. readonly promise: Promise<T>;
  51879. private _resolve;
  51880. private _reject;
  51881. /**
  51882. * The resolve method of the promise associated with this deferred object.
  51883. */
  51884. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  51885. /**
  51886. * The reject method of the promise associated with this deferred object.
  51887. */
  51888. readonly reject: (reason?: any) => void;
  51889. /**
  51890. * Constructor for this deferred object.
  51891. */
  51892. constructor();
  51893. }
  51894. }
  51895. declare module BABYLON {
  51896. /**
  51897. * Class used to help managing file picking and drag'n'drop
  51898. */
  51899. export class FilesInput {
  51900. /**
  51901. * List of files ready to be loaded
  51902. */
  51903. static readonly FilesToLoad: {
  51904. [key: string]: File;
  51905. };
  51906. /**
  51907. * Callback called when a file is processed
  51908. */
  51909. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  51910. private _engine;
  51911. private _currentScene;
  51912. private _sceneLoadedCallback;
  51913. private _progressCallback;
  51914. private _additionalRenderLoopLogicCallback;
  51915. private _textureLoadingCallback;
  51916. private _startingProcessingFilesCallback;
  51917. private _onReloadCallback;
  51918. private _errorCallback;
  51919. private _elementToMonitor;
  51920. private _sceneFileToLoad;
  51921. private _filesToLoad;
  51922. /**
  51923. * Creates a new FilesInput
  51924. * @param engine defines the rendering engine
  51925. * @param scene defines the hosting scene
  51926. * @param sceneLoadedCallback callback called when scene is loaded
  51927. * @param progressCallback callback called to track progress
  51928. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  51929. * @param textureLoadingCallback callback called when a texture is loading
  51930. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  51931. * @param onReloadCallback callback called when a reload is requested
  51932. * @param errorCallback callback call if an error occurs
  51933. */
  51934. 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);
  51935. private _dragEnterHandler;
  51936. private _dragOverHandler;
  51937. private _dropHandler;
  51938. /**
  51939. * Calls this function to listen to drag'n'drop events on a specific DOM element
  51940. * @param elementToMonitor defines the DOM element to track
  51941. */
  51942. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  51943. /**
  51944. * Release all associated resources
  51945. */
  51946. dispose(): void;
  51947. private renderFunction;
  51948. private drag;
  51949. private drop;
  51950. private _traverseFolder;
  51951. private _processFiles;
  51952. /**
  51953. * Load files from a drop event
  51954. * @param event defines the drop event to use as source
  51955. */
  51956. loadFiles(event: any): void;
  51957. private _processReload;
  51958. /**
  51959. * Reload the current scene from the loaded files
  51960. */
  51961. reload(): void;
  51962. }
  51963. }
  51964. declare module BABYLON {
  51965. /**
  51966. * Defines the root class used to create scene optimization to use with SceneOptimizer
  51967. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  51968. */
  51969. export class SceneOptimization {
  51970. /**
  51971. * Defines the priority of this optimization (0 by default which means first in the list)
  51972. */
  51973. priority: number;
  51974. /**
  51975. * Gets a string describing the action executed by the current optimization
  51976. * @returns description string
  51977. */
  51978. getDescription(): string;
  51979. /**
  51980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  51981. * @param scene defines the current scene where to apply this optimization
  51982. * @param optimizer defines the current optimizer
  51983. * @returns true if everything that can be done was applied
  51984. */
  51985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  51986. /**
  51987. * Creates the SceneOptimization object
  51988. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  51989. * @param desc defines the description associated with the optimization
  51990. */
  51991. constructor(
  51992. /**
  51993. * Defines the priority of this optimization (0 by default which means first in the list)
  51994. */
  51995. priority?: number);
  51996. }
  51997. /**
  51998. * Defines an optimization used to reduce the size of render target textures
  51999. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52000. */
  52001. export class TextureOptimization extends SceneOptimization {
  52002. /**
  52003. * Defines the priority of this optimization (0 by default which means first in the list)
  52004. */
  52005. priority: number;
  52006. /**
  52007. * 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
  52008. */
  52009. maximumSize: number;
  52010. /**
  52011. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52012. */
  52013. step: number;
  52014. /**
  52015. * Gets a string describing the action executed by the current optimization
  52016. * @returns description string
  52017. */
  52018. getDescription(): string;
  52019. /**
  52020. * Creates the TextureOptimization object
  52021. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52022. * @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
  52023. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52024. */
  52025. constructor(
  52026. /**
  52027. * Defines the priority of this optimization (0 by default which means first in the list)
  52028. */
  52029. priority?: number,
  52030. /**
  52031. * 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
  52032. */
  52033. maximumSize?: number,
  52034. /**
  52035. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52036. */
  52037. step?: number);
  52038. /**
  52039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52040. * @param scene defines the current scene where to apply this optimization
  52041. * @param optimizer defines the current optimizer
  52042. * @returns true if everything that can be done was applied
  52043. */
  52044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52045. }
  52046. /**
  52047. * Defines an optimization used to increase or decrease the rendering resolution
  52048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52049. */
  52050. export class HardwareScalingOptimization extends SceneOptimization {
  52051. /**
  52052. * Defines the priority of this optimization (0 by default which means first in the list)
  52053. */
  52054. priority: number;
  52055. /**
  52056. * Defines the maximum scale to use (2 by default)
  52057. */
  52058. maximumScale: number;
  52059. /**
  52060. * Defines the step to use between two passes (0.5 by default)
  52061. */
  52062. step: number;
  52063. private _currentScale;
  52064. private _directionOffset;
  52065. /**
  52066. * Gets a string describing the action executed by the current optimization
  52067. * @return description string
  52068. */
  52069. getDescription(): string;
  52070. /**
  52071. * Creates the HardwareScalingOptimization object
  52072. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52073. * @param maximumScale defines the maximum scale to use (2 by default)
  52074. * @param step defines the step to use between two passes (0.5 by default)
  52075. */
  52076. constructor(
  52077. /**
  52078. * Defines the priority of this optimization (0 by default which means first in the list)
  52079. */
  52080. priority?: number,
  52081. /**
  52082. * Defines the maximum scale to use (2 by default)
  52083. */
  52084. maximumScale?: number,
  52085. /**
  52086. * Defines the step to use between two passes (0.5 by default)
  52087. */
  52088. step?: number);
  52089. /**
  52090. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52091. * @param scene defines the current scene where to apply this optimization
  52092. * @param optimizer defines the current optimizer
  52093. * @returns true if everything that can be done was applied
  52094. */
  52095. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52096. }
  52097. /**
  52098. * Defines an optimization used to remove shadows
  52099. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52100. */
  52101. export class ShadowsOptimization extends SceneOptimization {
  52102. /**
  52103. * Gets a string describing the action executed by the current optimization
  52104. * @return description string
  52105. */
  52106. getDescription(): string;
  52107. /**
  52108. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52109. * @param scene defines the current scene where to apply this optimization
  52110. * @param optimizer defines the current optimizer
  52111. * @returns true if everything that can be done was applied
  52112. */
  52113. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52114. }
  52115. /**
  52116. * Defines an optimization used to turn post-processes off
  52117. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52118. */
  52119. export class PostProcessesOptimization extends SceneOptimization {
  52120. /**
  52121. * Gets a string describing the action executed by the current optimization
  52122. * @return description string
  52123. */
  52124. getDescription(): string;
  52125. /**
  52126. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52127. * @param scene defines the current scene where to apply this optimization
  52128. * @param optimizer defines the current optimizer
  52129. * @returns true if everything that can be done was applied
  52130. */
  52131. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52132. }
  52133. /**
  52134. * Defines an optimization used to turn lens flares off
  52135. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52136. */
  52137. export class LensFlaresOptimization extends SceneOptimization {
  52138. /**
  52139. * Gets a string describing the action executed by the current optimization
  52140. * @return description string
  52141. */
  52142. getDescription(): string;
  52143. /**
  52144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52145. * @param scene defines the current scene where to apply this optimization
  52146. * @param optimizer defines the current optimizer
  52147. * @returns true if everything that can be done was applied
  52148. */
  52149. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52150. }
  52151. /**
  52152. * Defines an optimization based on user defined callback.
  52153. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52154. */
  52155. export class CustomOptimization extends SceneOptimization {
  52156. /**
  52157. * Callback called to apply the custom optimization.
  52158. */
  52159. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  52160. /**
  52161. * Callback called to get custom description
  52162. */
  52163. onGetDescription: () => string;
  52164. /**
  52165. * Gets a string describing the action executed by the current optimization
  52166. * @returns description string
  52167. */
  52168. getDescription(): string;
  52169. /**
  52170. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52171. * @param scene defines the current scene where to apply this optimization
  52172. * @param optimizer defines the current optimizer
  52173. * @returns true if everything that can be done was applied
  52174. */
  52175. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52176. }
  52177. /**
  52178. * Defines an optimization used to turn particles off
  52179. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52180. */
  52181. export class ParticlesOptimization extends SceneOptimization {
  52182. /**
  52183. * Gets a string describing the action executed by the current optimization
  52184. * @return description string
  52185. */
  52186. getDescription(): string;
  52187. /**
  52188. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52189. * @param scene defines the current scene where to apply this optimization
  52190. * @param optimizer defines the current optimizer
  52191. * @returns true if everything that can be done was applied
  52192. */
  52193. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52194. }
  52195. /**
  52196. * Defines an optimization used to turn render targets off
  52197. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52198. */
  52199. export class RenderTargetsOptimization extends SceneOptimization {
  52200. /**
  52201. * Gets a string describing the action executed by the current optimization
  52202. * @return description string
  52203. */
  52204. getDescription(): string;
  52205. /**
  52206. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52207. * @param scene defines the current scene where to apply this optimization
  52208. * @param optimizer defines the current optimizer
  52209. * @returns true if everything that can be done was applied
  52210. */
  52211. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52212. }
  52213. /**
  52214. * Defines an optimization used to merge meshes with compatible materials
  52215. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52216. */
  52217. export class MergeMeshesOptimization extends SceneOptimization {
  52218. private static _UpdateSelectionTree;
  52219. /**
  52220. * Gets or sets a boolean which defines if optimization octree has to be updated
  52221. */
  52222. /**
  52223. * Gets or sets a boolean which defines if optimization octree has to be updated
  52224. */
  52225. static UpdateSelectionTree: boolean;
  52226. /**
  52227. * Gets a string describing the action executed by the current optimization
  52228. * @return description string
  52229. */
  52230. getDescription(): string;
  52231. private _canBeMerged;
  52232. /**
  52233. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52234. * @param scene defines the current scene where to apply this optimization
  52235. * @param optimizer defines the current optimizer
  52236. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  52237. * @returns true if everything that can be done was applied
  52238. */
  52239. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  52240. }
  52241. /**
  52242. * Defines a list of options used by SceneOptimizer
  52243. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52244. */
  52245. export class SceneOptimizerOptions {
  52246. /**
  52247. * Defines the target frame rate to reach (60 by default)
  52248. */
  52249. targetFrameRate: number;
  52250. /**
  52251. * Defines the interval between two checkes (2000ms by default)
  52252. */
  52253. trackerDuration: number;
  52254. /**
  52255. * Gets the list of optimizations to apply
  52256. */
  52257. optimizations: SceneOptimization[];
  52258. /**
  52259. * Creates a new list of options used by SceneOptimizer
  52260. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  52261. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  52262. */
  52263. constructor(
  52264. /**
  52265. * Defines the target frame rate to reach (60 by default)
  52266. */
  52267. targetFrameRate?: number,
  52268. /**
  52269. * Defines the interval between two checkes (2000ms by default)
  52270. */
  52271. trackerDuration?: number);
  52272. /**
  52273. * Add a new optimization
  52274. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  52275. * @returns the current SceneOptimizerOptions
  52276. */
  52277. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  52278. /**
  52279. * Add a new custom optimization
  52280. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  52281. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  52282. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52283. * @returns the current SceneOptimizerOptions
  52284. */
  52285. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  52286. /**
  52287. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  52288. * @param targetFrameRate defines the target frame rate (60 by default)
  52289. * @returns a SceneOptimizerOptions object
  52290. */
  52291. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52292. /**
  52293. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  52294. * @param targetFrameRate defines the target frame rate (60 by default)
  52295. * @returns a SceneOptimizerOptions object
  52296. */
  52297. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52298. /**
  52299. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  52300. * @param targetFrameRate defines the target frame rate (60 by default)
  52301. * @returns a SceneOptimizerOptions object
  52302. */
  52303. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52304. }
  52305. /**
  52306. * Class used to run optimizations in order to reach a target frame rate
  52307. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52308. */
  52309. export class SceneOptimizer implements IDisposable {
  52310. private _isRunning;
  52311. private _options;
  52312. private _scene;
  52313. private _currentPriorityLevel;
  52314. private _targetFrameRate;
  52315. private _trackerDuration;
  52316. private _currentFrameRate;
  52317. private _sceneDisposeObserver;
  52318. private _improvementMode;
  52319. /**
  52320. * Defines an observable called when the optimizer reaches the target frame rate
  52321. */
  52322. onSuccessObservable: Observable<SceneOptimizer>;
  52323. /**
  52324. * Defines an observable called when the optimizer enables an optimization
  52325. */
  52326. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  52327. /**
  52328. * Defines an observable called when the optimizer is not able to reach the target frame rate
  52329. */
  52330. onFailureObservable: Observable<SceneOptimizer>;
  52331. /**
  52332. * Gets a boolean indicating if the optimizer is in improvement mode
  52333. */
  52334. readonly isInImprovementMode: boolean;
  52335. /**
  52336. * Gets the current priority level (0 at start)
  52337. */
  52338. readonly currentPriorityLevel: number;
  52339. /**
  52340. * Gets the current frame rate checked by the SceneOptimizer
  52341. */
  52342. readonly currentFrameRate: number;
  52343. /**
  52344. * Gets or sets the current target frame rate (60 by default)
  52345. */
  52346. /**
  52347. * Gets or sets the current target frame rate (60 by default)
  52348. */
  52349. targetFrameRate: number;
  52350. /**
  52351. * Gets or sets the current interval between two checks (every 2000ms by default)
  52352. */
  52353. /**
  52354. * Gets or sets the current interval between two checks (every 2000ms by default)
  52355. */
  52356. trackerDuration: number;
  52357. /**
  52358. * Gets the list of active optimizations
  52359. */
  52360. readonly optimizations: SceneOptimization[];
  52361. /**
  52362. * Creates a new SceneOptimizer
  52363. * @param scene defines the scene to work on
  52364. * @param options defines the options to use with the SceneOptimizer
  52365. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  52366. * @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)
  52367. */
  52368. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  52369. /**
  52370. * Stops the current optimizer
  52371. */
  52372. stop(): void;
  52373. /**
  52374. * Reset the optimizer to initial step (current priority level = 0)
  52375. */
  52376. reset(): void;
  52377. /**
  52378. * Start the optimizer. By default it will try to reach a specific framerate
  52379. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  52380. */
  52381. start(): void;
  52382. private _checkCurrentState;
  52383. /**
  52384. * Release all resources
  52385. */
  52386. dispose(): void;
  52387. /**
  52388. * Helper function to create a SceneOptimizer with one single line of code
  52389. * @param scene defines the scene to work on
  52390. * @param options defines the options to use with the SceneOptimizer
  52391. * @param onSuccess defines a callback to call on success
  52392. * @param onFailure defines a callback to call on failure
  52393. * @returns the new SceneOptimizer object
  52394. */
  52395. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  52396. }
  52397. }
  52398. declare module BABYLON {
  52399. /**
  52400. * Class used to serialize a scene into a string
  52401. */
  52402. export class SceneSerializer {
  52403. /**
  52404. * Clear cache used by a previous serialization
  52405. */
  52406. static ClearCache(): void;
  52407. /**
  52408. * Serialize a scene into a JSON compatible object
  52409. * @param scene defines the scene to serialize
  52410. * @returns a JSON compatible object
  52411. */
  52412. static Serialize(scene: Scene): any;
  52413. /**
  52414. * Serialize a mesh into a JSON compatible object
  52415. * @param toSerialize defines the mesh to serialize
  52416. * @param withParents defines if parents must be serialized as well
  52417. * @param withChildren defines if children must be serialized as well
  52418. * @returns a JSON compatible object
  52419. */
  52420. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  52421. }
  52422. }
  52423. declare module BABYLON {
  52424. /**
  52425. * This represents the different options avilable for the video capture.
  52426. */
  52427. export interface VideoRecorderOptions {
  52428. /** Defines the mime type of the video */
  52429. mimeType: string;
  52430. /** Defines the video the video should be recorded at */
  52431. fps: number;
  52432. /** Defines the chunk size for the recording data */
  52433. recordChunckSize: number;
  52434. }
  52435. /**
  52436. * This can helps recording videos from BabylonJS.
  52437. * This is based on the available WebRTC functionalities of the browser.
  52438. *
  52439. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  52440. */
  52441. export class VideoRecorder {
  52442. private static readonly _defaultOptions;
  52443. /**
  52444. * Returns wehther or not the VideoRecorder is available in your browser.
  52445. * @param engine Defines the Babylon Engine to check the support for
  52446. * @returns true if supported otherwise false
  52447. */
  52448. static IsSupported(engine: Engine): boolean;
  52449. private readonly _options;
  52450. private _canvas;
  52451. private _mediaRecorder;
  52452. private _recordedChunks;
  52453. private _fileName;
  52454. private _resolve;
  52455. private _reject;
  52456. /**
  52457. * True wether a recording is already in progress.
  52458. */
  52459. readonly isRecording: boolean;
  52460. /**
  52461. * Create a new VideoCapture object which can help converting what you see in Babylon to
  52462. * a video file.
  52463. * @param engine Defines the BabylonJS Engine you wish to record
  52464. * @param options Defines options that can be used to customized the capture
  52465. */
  52466. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  52467. /**
  52468. * Stops the current recording before the default capture timeout passed in the startRecording
  52469. * functions.
  52470. */
  52471. stopRecording(): void;
  52472. /**
  52473. * Starts recording the canvas for a max duration specified in parameters.
  52474. * @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.
  52475. * @param maxDuration Defines the maximum recording time in seconds.
  52476. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  52477. * @return a promise callback at the end of the recording with the video data in Blob.
  52478. */
  52479. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  52480. /**
  52481. * Releases internal resources used during the recording.
  52482. */
  52483. dispose(): void;
  52484. private _handleDataAvailable;
  52485. private _handleError;
  52486. private _handleStop;
  52487. }
  52488. }
  52489. declare module BABYLON {
  52490. /**
  52491. * Helper class to push actions to a pool of workers.
  52492. */
  52493. export class WorkerPool implements IDisposable {
  52494. private _workerInfos;
  52495. private _pendingActions;
  52496. /**
  52497. * Constructor
  52498. * @param workers Array of workers to use for actions
  52499. */
  52500. constructor(workers: Array<Worker>);
  52501. /**
  52502. * Terminates all workers and clears any pending actions.
  52503. */
  52504. dispose(): void;
  52505. /**
  52506. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52507. * pended until a worker has completed its action.
  52508. * @param action The action to perform. Call onComplete when the action is complete.
  52509. */
  52510. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52511. private _execute;
  52512. }
  52513. }
  52514. declare module BABYLON {
  52515. /**
  52516. * Class containing a set of static utilities functions for screenshots
  52517. */
  52518. export class ScreenshotTools {
  52519. /**
  52520. * Captures a screenshot of the current rendering
  52521. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  52522. * @param engine defines the rendering engine
  52523. * @param camera defines the source camera
  52524. * @param size This parameter can be set to a single number or to an object with the
  52525. * following (optional) properties: precision, width, height. If a single number is passed,
  52526. * it will be used for both width and height. If an object is passed, the screenshot size
  52527. * will be derived from the parameters. The precision property is a multiplier allowing
  52528. * rendering at a higher or lower resolution
  52529. * @param successCallback defines the callback receives a single parameter which contains the
  52530. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  52531. * src parameter of an <img> to display it
  52532. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  52533. * Check your browser for supported MIME types
  52534. */
  52535. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  52536. /**
  52537. * Generates an image screenshot from the specified camera.
  52538. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  52539. * @param engine The engine to use for rendering
  52540. * @param camera The camera to use for rendering
  52541. * @param size This parameter can be set to a single number or to an object with the
  52542. * following (optional) properties: precision, width, height. If a single number is passed,
  52543. * it will be used for both width and height. If an object is passed, the screenshot size
  52544. * will be derived from the parameters. The precision property is a multiplier allowing
  52545. * rendering at a higher or lower resolution
  52546. * @param successCallback The callback receives a single parameter which contains the
  52547. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  52548. * src parameter of an <img> to display it
  52549. * @param mimeType The MIME type of the screenshot image (default: image/png).
  52550. * Check your browser for supported MIME types
  52551. * @param samples Texture samples (default: 1)
  52552. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  52553. * @param fileName A name for for the downloaded file.
  52554. */
  52555. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  52556. }
  52557. }
  52558. declare module BABYLON {
  52559. /** @hidden */
  52560. export var blurPixelShader: {
  52561. name: string;
  52562. shader: string;
  52563. };
  52564. }
  52565. declare module BABYLON {
  52566. /** @hidden */
  52567. export var bones300Declaration: {
  52568. name: string;
  52569. shader: string;
  52570. };
  52571. }
  52572. declare module BABYLON {
  52573. /** @hidden */
  52574. export var instances300Declaration: {
  52575. name: string;
  52576. shader: string;
  52577. };
  52578. }
  52579. declare module BABYLON {
  52580. /** @hidden */
  52581. export var pointCloudVertexDeclaration: {
  52582. name: string;
  52583. shader: string;
  52584. };
  52585. }
  52586. // Mixins
  52587. interface Window {
  52588. mozIndexedDB: IDBFactory;
  52589. webkitIndexedDB: IDBFactory;
  52590. msIndexedDB: IDBFactory;
  52591. webkitURL: typeof URL;
  52592. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  52593. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  52594. WebGLRenderingContext: WebGLRenderingContext;
  52595. MSGesture: MSGesture;
  52596. CANNON: any;
  52597. AudioContext: AudioContext;
  52598. webkitAudioContext: AudioContext;
  52599. PointerEvent: any;
  52600. Math: Math;
  52601. Uint8Array: Uint8ArrayConstructor;
  52602. Float32Array: Float32ArrayConstructor;
  52603. mozURL: typeof URL;
  52604. msURL: typeof URL;
  52605. VRFrameData: any; // WebVR, from specs 1.1
  52606. DracoDecoderModule: any;
  52607. setImmediate(handler: (...args: any[]) => void): number;
  52608. }
  52609. interface Document {
  52610. mozCancelFullScreen(): void;
  52611. msCancelFullScreen(): void;
  52612. webkitCancelFullScreen(): void;
  52613. requestPointerLock(): void;
  52614. exitPointerLock(): void;
  52615. mozFullScreen: boolean;
  52616. msIsFullScreen: boolean;
  52617. readonly webkitIsFullScreen: boolean;
  52618. readonly pointerLockElement: Element;
  52619. mozPointerLockElement: HTMLElement;
  52620. msPointerLockElement: HTMLElement;
  52621. webkitPointerLockElement: HTMLElement;
  52622. }
  52623. interface HTMLCanvasElement {
  52624. requestPointerLock(): void;
  52625. msRequestPointerLock?(): void;
  52626. mozRequestPointerLock?(): void;
  52627. webkitRequestPointerLock?(): void;
  52628. /** Track wether a record is in progress */
  52629. isRecording: boolean;
  52630. /** Capture Stream method defined by some browsers */
  52631. captureStream(fps?: number): MediaStream;
  52632. }
  52633. interface CanvasRenderingContext2D {
  52634. msImageSmoothingEnabled: boolean;
  52635. }
  52636. interface MouseEvent {
  52637. mozMovementX: number;
  52638. mozMovementY: number;
  52639. webkitMovementX: number;
  52640. webkitMovementY: number;
  52641. msMovementX: number;
  52642. msMovementY: number;
  52643. }
  52644. interface Navigator {
  52645. mozGetVRDevices: (any: any) => any;
  52646. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52647. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52648. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52649. webkitGetGamepads(): Gamepad[];
  52650. msGetGamepads(): Gamepad[];
  52651. webkitGamepads(): Gamepad[];
  52652. }
  52653. interface HTMLVideoElement {
  52654. mozSrcObject: any;
  52655. }
  52656. interface Math {
  52657. fround(x: number): number;
  52658. imul(a: number, b: number): number;
  52659. }
  52660. interface WebGLProgram {
  52661. context?: WebGLRenderingContext;
  52662. vertexShader?: WebGLShader;
  52663. fragmentShader?: WebGLShader;
  52664. isParallelCompiled: boolean;
  52665. onCompiled?: () => void;
  52666. }
  52667. interface WebGLRenderingContext {
  52668. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  52669. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  52670. vertexAttribDivisor(index: number, divisor: number): void;
  52671. createVertexArray(): any;
  52672. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  52673. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  52674. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  52675. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  52676. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  52677. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  52678. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  52679. // Queries
  52680. createQuery(): WebGLQuery;
  52681. deleteQuery(query: WebGLQuery): void;
  52682. beginQuery(target: number, query: WebGLQuery): void;
  52683. endQuery(target: number): void;
  52684. getQueryParameter(query: WebGLQuery, pname: number): any;
  52685. getQuery(target: number, pname: number): any;
  52686. MAX_SAMPLES: number;
  52687. RGBA8: number;
  52688. READ_FRAMEBUFFER: number;
  52689. DRAW_FRAMEBUFFER: number;
  52690. UNIFORM_BUFFER: number;
  52691. HALF_FLOAT_OES: number;
  52692. RGBA16F: number;
  52693. RGBA32F: number;
  52694. R32F: number;
  52695. RG32F: number;
  52696. RGB32F: number;
  52697. R16F: number;
  52698. RG16F: number;
  52699. RGB16F: number;
  52700. RED: number;
  52701. RG: number;
  52702. R8: number;
  52703. RG8: number;
  52704. UNSIGNED_INT_24_8: number;
  52705. DEPTH24_STENCIL8: number;
  52706. /* Multiple Render Targets */
  52707. drawBuffers(buffers: number[]): void;
  52708. readBuffer(src: number): void;
  52709. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  52710. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  52711. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  52712. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  52713. // Occlusion Query
  52714. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  52715. ANY_SAMPLES_PASSED: number;
  52716. QUERY_RESULT_AVAILABLE: number;
  52717. QUERY_RESULT: number;
  52718. }
  52719. interface WebGLBuffer {
  52720. references: number;
  52721. capacity: number;
  52722. is32Bits: boolean;
  52723. }
  52724. interface WebGLProgram {
  52725. transformFeedback?: WebGLTransformFeedback | null; private _SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  52726. }
  52727. interface EXT_disjoint_timer_query {
  52728. QUERY_COUNTER_BITS_EXT: number;
  52729. TIME_ELAPSED_EXT: number;
  52730. TIMESTAMP_EXT: number;
  52731. GPU_DISJOINT_EXT: number;
  52732. QUERY_RESULT_EXT: number;
  52733. QUERY_RESULT_AVAILABLE_EXT: number;
  52734. queryCounterEXT(query: WebGLQuery, target: number): void;
  52735. createQueryEXT(): WebGLQuery;
  52736. beginQueryEXT(target: number, query: WebGLQuery): void;
  52737. endQueryEXT(target: number): void;
  52738. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  52739. deleteQueryEXT(query: WebGLQuery): void;
  52740. }
  52741. interface WebGLUniformLocation { currentState: any;
  52742. }
  52743. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  52744. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  52745. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  52746. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  52747. interface WebGLRenderingContext {
  52748. readonly RASTERIZER_DISCARD: number;
  52749. readonly DEPTH_COMPONENT24: number;
  52750. readonly TEXTURE_3D: number;
  52751. readonly TEXTURE_2D_ARRAY: number;
  52752. readonly TEXTURE_COMPARE_FUNC: number;
  52753. readonly TEXTURE_COMPARE_MODE: number;
  52754. readonly COMPARE_REF_TO_TEXTURE: number;
  52755. readonly TEXTURE_WRAP_R: number;
  52756. readonly HALF_FLOAT: number;
  52757. readonly RGB8: number;
  52758. readonly RED_INTEGER: number;
  52759. readonly RG_INTEGER: number;
  52760. readonly RGB_INTEGER: number;
  52761. readonly RGBA_INTEGER: number;
  52762. readonly R8_SNORM: number;
  52763. readonly RG8_SNORM: number;
  52764. readonly RGB8_SNORM: number;
  52765. readonly RGBA8_SNORM: number;
  52766. readonly R8I: number;
  52767. readonly RG8I: number;
  52768. readonly RGB8I: number;
  52769. readonly RGBA8I: number;
  52770. readonly R8UI: number;
  52771. readonly RG8UI: number;
  52772. readonly RGB8UI: number;
  52773. readonly RGBA8UI: number;
  52774. readonly R16I: number;
  52775. readonly RG16I: number;
  52776. readonly RGB16I: number;
  52777. readonly RGBA16I: number;
  52778. readonly R16UI: number;
  52779. readonly RG16UI: number;
  52780. readonly RGB16UI: number;
  52781. readonly RGBA16UI: number;
  52782. readonly R32I: number;
  52783. readonly RG32I: number;
  52784. readonly RGB32I: number;
  52785. readonly RGBA32I: number;
  52786. readonly R32UI: number;
  52787. readonly RG32UI: number;
  52788. readonly RGB32UI: number;
  52789. readonly RGBA32UI: number;
  52790. readonly RGB10_A2UI: number;
  52791. readonly R11F_G11F_B10F: number;
  52792. readonly RGB9_E5: number;
  52793. readonly RGB10_A2: number;
  52794. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  52795. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  52796. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  52797. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  52798. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  52799. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  52800. 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;
  52801. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  52802. readonly TRANSFORM_FEEDBACK: number;
  52803. readonly INTERLEAVED_ATTRIBS: number;
  52804. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  52805. createTransformFeedback(): WebGLTransformFeedback;
  52806. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  52807. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  52808. beginTransformFeedback(primitiveMode: number): void;
  52809. endTransformFeedback(): void;
  52810. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  52811. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  52812. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  52813. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  52814. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  52815. }
  52816. interface ImageBitmap {
  52817. readonly width: number;
  52818. readonly height: number;
  52819. close(): void;
  52820. }
  52821. interface WebGLQuery extends WebGLObject {
  52822. }
  52823. declare var WebGLQuery: {
  52824. prototype: WebGLQuery;
  52825. new(): WebGLQuery;
  52826. };
  52827. interface WebGLSampler extends WebGLObject {
  52828. }
  52829. declare var WebGLSampler: {
  52830. prototype: WebGLSampler;
  52831. new(): WebGLSampler;
  52832. };
  52833. interface WebGLSync extends WebGLObject {
  52834. }
  52835. declare var WebGLSync: {
  52836. prototype: WebGLSync;
  52837. new(): WebGLSync;
  52838. };
  52839. interface WebGLTransformFeedback extends WebGLObject {
  52840. }
  52841. declare var WebGLTransformFeedback: {
  52842. prototype: WebGLTransformFeedback;
  52843. new(): WebGLTransformFeedback;
  52844. };
  52845. interface WebGLVertexArrayObject extends WebGLObject {
  52846. }
  52847. declare var WebGLVertexArrayObject: {
  52848. prototype: WebGLVertexArrayObject;
  52849. new(): WebGLVertexArrayObject;
  52850. };
  52851. // Type definitions for WebVR API
  52852. // Project: https://w3c.github.io/webvr/
  52853. // Definitions by: six a <https://github.com/lostfictions>
  52854. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  52855. interface VRDisplay extends EventTarget {
  52856. /**
  52857. * Dictionary of capabilities describing the VRDisplay.
  52858. */
  52859. readonly capabilities: VRDisplayCapabilities;
  52860. /**
  52861. * z-depth defining the far plane of the eye view frustum
  52862. * enables mapping of values in the render target depth
  52863. * attachment to scene coordinates. Initially set to 10000.0.
  52864. */
  52865. depthFar: number;
  52866. /**
  52867. * z-depth defining the near plane of the eye view frustum
  52868. * enables mapping of values in the render target depth
  52869. * attachment to scene coordinates. Initially set to 0.01.
  52870. */
  52871. depthNear: number;
  52872. /**
  52873. * An identifier for this distinct VRDisplay. Used as an
  52874. * association point in the Gamepad API.
  52875. */
  52876. readonly displayId: number;
  52877. /**
  52878. * A display name, a user-readable name identifying it.
  52879. */
  52880. readonly displayName: string;
  52881. readonly isConnected: boolean;
  52882. readonly isPresenting: boolean;
  52883. /**
  52884. * If this VRDisplay supports room-scale experiences, the optional
  52885. * stage attribute contains details on the room-scale parameters.
  52886. */
  52887. readonly stageParameters: VRStageParameters | null;
  52888. /**
  52889. * Passing the value returned by `requestAnimationFrame` to
  52890. * `cancelAnimationFrame` will unregister the callback.
  52891. * @param handle Define the hanle of the request to cancel
  52892. */
  52893. cancelAnimationFrame(handle: number): void;
  52894. /**
  52895. * Stops presenting to the VRDisplay.
  52896. * @returns a promise to know when it stopped
  52897. */
  52898. exitPresent(): Promise<void>;
  52899. /**
  52900. * Return the current VREyeParameters for the given eye.
  52901. * @param whichEye Define the eye we want the parameter for
  52902. * @returns the eye parameters
  52903. */
  52904. getEyeParameters(whichEye: string): VREyeParameters;
  52905. /**
  52906. * Populates the passed VRFrameData with the information required to render
  52907. * the current frame.
  52908. * @param frameData Define the data structure to populate
  52909. * @returns true if ok otherwise false
  52910. */
  52911. getFrameData(frameData: VRFrameData): boolean;
  52912. /**
  52913. * Get the layers currently being presented.
  52914. * @returns the list of VR layers
  52915. */
  52916. getLayers(): VRLayer[];
  52917. /**
  52918. * Return a VRPose containing the future predicted pose of the VRDisplay
  52919. * when the current frame will be presented. The value returned will not
  52920. * change until JavaScript has returned control to the browser.
  52921. *
  52922. * The VRPose will contain the position, orientation, velocity,
  52923. * and acceleration of each of these properties.
  52924. * @returns the pose object
  52925. */
  52926. getPose(): VRPose;
  52927. /**
  52928. * Return the current instantaneous pose of the VRDisplay, with no
  52929. * prediction applied.
  52930. * @returns the current instantaneous pose
  52931. */
  52932. getImmediatePose(): VRPose;
  52933. /**
  52934. * The callback passed to `requestAnimationFrame` will be called
  52935. * any time a new frame should be rendered. When the VRDisplay is
  52936. * presenting the callback will be called at the native refresh
  52937. * rate of the HMD. When not presenting this function acts
  52938. * identically to how window.requestAnimationFrame acts. Content should
  52939. * make no assumptions of frame rate or vsync behavior as the HMD runs
  52940. * asynchronously from other displays and at differing refresh rates.
  52941. * @param callback Define the eaction to run next frame
  52942. * @returns the request handle it
  52943. */
  52944. requestAnimationFrame(callback: FrameRequestCallback): number;
  52945. /**
  52946. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  52947. * Repeat calls while already presenting will update the VRLayers being displayed.
  52948. * @param layers Define the list of layer to present
  52949. * @returns a promise to know when the request has been fulfilled
  52950. */
  52951. requestPresent(layers: VRLayer[]): Promise<void>;
  52952. /**
  52953. * Reset the pose for this display, treating its current position and
  52954. * orientation as the "origin/zero" values. VRPose.position,
  52955. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  52956. * updated when calling resetPose(). This should be called in only
  52957. * sitting-space experiences.
  52958. */
  52959. resetPose(): void;
  52960. /**
  52961. * The VRLayer provided to the VRDisplay will be captured and presented
  52962. * in the HMD. Calling this function has the same effect on the source
  52963. * canvas as any other operation that uses its source image, and canvases
  52964. * created without preserveDrawingBuffer set to true will be cleared.
  52965. * @param pose Define the pose to submit
  52966. */
  52967. submitFrame(pose?: VRPose): void;
  52968. }
  52969. declare var VRDisplay: {
  52970. prototype: VRDisplay;
  52971. new(): VRDisplay;
  52972. };
  52973. interface VRLayer {
  52974. leftBounds?: number[] | Float32Array | null;
  52975. rightBounds?: number[] | Float32Array | null;
  52976. source?: HTMLCanvasElement | null;
  52977. }
  52978. interface VRDisplayCapabilities {
  52979. readonly canPresent: boolean;
  52980. readonly hasExternalDisplay: boolean;
  52981. readonly hasOrientation: boolean;
  52982. readonly hasPosition: boolean;
  52983. readonly maxLayers: number;
  52984. }
  52985. interface VREyeParameters {
  52986. /** @deprecated */
  52987. readonly fieldOfView: VRFieldOfView;
  52988. readonly offset: Float32Array;
  52989. readonly renderHeight: number;
  52990. readonly renderWidth: number;
  52991. }
  52992. interface VRFieldOfView {
  52993. readonly downDegrees: number;
  52994. readonly leftDegrees: number;
  52995. readonly rightDegrees: number;
  52996. readonly upDegrees: number;
  52997. }
  52998. interface VRFrameData {
  52999. readonly leftProjectionMatrix: Float32Array;
  53000. readonly leftViewMatrix: Float32Array;
  53001. readonly pose: VRPose;
  53002. readonly rightProjectionMatrix: Float32Array;
  53003. readonly rightViewMatrix: Float32Array;
  53004. readonly timestamp: number;
  53005. }
  53006. interface VRPose {
  53007. readonly angularAcceleration: Float32Array | null;
  53008. readonly angularVelocity: Float32Array | null;
  53009. readonly linearAcceleration: Float32Array | null;
  53010. readonly linearVelocity: Float32Array | null;
  53011. readonly orientation: Float32Array | null;
  53012. readonly position: Float32Array | null;
  53013. readonly timestamp: number;
  53014. }
  53015. interface VRStageParameters {
  53016. sittingToStandingTransform?: Float32Array;
  53017. sizeX?: number;
  53018. sizeY?: number;
  53019. }
  53020. interface Navigator {
  53021. getVRDisplays(): Promise<VRDisplay[]>;
  53022. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  53023. }
  53024. interface Window {
  53025. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  53026. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  53027. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  53028. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53029. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53030. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  53031. }
  53032. interface Gamepad {
  53033. readonly displayId: number;
  53034. }
  53035. interface XRDevice {
  53036. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  53037. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  53038. }
  53039. interface XRSession {
  53040. getInputSources(): Array<any>;
  53041. baseLayer: XRWebGLLayer;
  53042. requestFrameOfReference(type: string): Promise<void>;
  53043. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  53044. end(): Promise<void>;
  53045. requestAnimationFrame: Function;
  53046. addEventListener: Function;
  53047. }
  53048. interface XRSessionCreationOptions {
  53049. outputContext?: WebGLRenderingContext | null;
  53050. immersive?: boolean;
  53051. environmentIntegration?: boolean;
  53052. }
  53053. interface XRLayer {
  53054. getViewport: Function;
  53055. framebufferWidth: number;
  53056. framebufferHeight: number;
  53057. }
  53058. interface XRView {
  53059. projectionMatrix: Float32Array;
  53060. }
  53061. interface XRFrame {
  53062. getDevicePose: Function;
  53063. getInputPose: Function;
  53064. views: Array<XRView>;
  53065. baseLayer: XRLayer;
  53066. }
  53067. interface XRFrameOfReference {
  53068. }
  53069. interface XRWebGLLayer extends XRLayer {
  53070. framebuffer: WebGLFramebuffer;
  53071. }
  53072. declare var XRWebGLLayer: {
  53073. prototype: XRWebGLLayer;
  53074. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  53075. };
  53076. declare module BABYLON.GUI {
  53077. /**
  53078. * Class used to specific a value and its associated unit
  53079. */
  53080. export class ValueAndUnit {
  53081. /** defines the unit to store */
  53082. unit: number;
  53083. /** defines a boolean indicating if the value can be negative */
  53084. negativeValueAllowed: boolean;
  53085. private _value;
  53086. private _originalUnit;
  53087. /**
  53088. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  53089. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53090. */
  53091. ignoreAdaptiveScaling: boolean;
  53092. /**
  53093. * Creates a new ValueAndUnit
  53094. * @param value defines the value to store
  53095. * @param unit defines the unit to store
  53096. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  53097. */
  53098. constructor(value: number,
  53099. /** defines the unit to store */
  53100. unit?: number,
  53101. /** defines a boolean indicating if the value can be negative */
  53102. negativeValueAllowed?: boolean);
  53103. /** Gets a boolean indicating if the value is a percentage */
  53104. readonly isPercentage: boolean;
  53105. /** Gets a boolean indicating if the value is store as pixel */
  53106. readonly isPixel: boolean;
  53107. /** Gets direct internal value */
  53108. readonly internalValue: number;
  53109. /**
  53110. * Gets value as pixel
  53111. * @param host defines the root host
  53112. * @param refValue defines the reference value for percentages
  53113. * @returns the value as pixel
  53114. */
  53115. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  53116. /**
  53117. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  53118. * @param value defines the value to store
  53119. * @param unit defines the unit to store
  53120. * @returns the current ValueAndUnit
  53121. */
  53122. updateInPlace(value: number, unit?: number): ValueAndUnit;
  53123. /**
  53124. * Gets the value accordingly to its unit
  53125. * @param host defines the root host
  53126. * @returns the value
  53127. */
  53128. getValue(host: AdvancedDynamicTexture): number;
  53129. /**
  53130. * Gets a string representation of the value
  53131. * @param host defines the root host
  53132. * @returns a string
  53133. */
  53134. toString(host: AdvancedDynamicTexture): string;
  53135. /**
  53136. * Store a value parsed from a string
  53137. * @param source defines the source string
  53138. * @returns true if the value was successfully parsed
  53139. */
  53140. fromString(source: string | number): boolean;
  53141. private static _Regex;
  53142. private static _UNITMODE_PERCENTAGE;
  53143. private static _UNITMODE_PIXEL;
  53144. /** UNITMODE_PERCENTAGE */
  53145. static readonly UNITMODE_PERCENTAGE: number;
  53146. /** UNITMODE_PIXEL */
  53147. static readonly UNITMODE_PIXEL: number;
  53148. }
  53149. }
  53150. declare module BABYLON.GUI {
  53151. /**
  53152. * Define a style used by control to automatically setup properties based on a template.
  53153. * Only support font related properties so far
  53154. */
  53155. export class Style implements BABYLON.IDisposable {
  53156. private _fontFamily;
  53157. private _fontStyle;
  53158. private _fontWeight;
  53159. /** @hidden */ host: AdvancedDynamicTexture;
  53160. /** @hidden */ fontSize: ValueAndUnit;
  53161. /**
  53162. * BABYLON.Observable raised when the style values are changed
  53163. */
  53164. onChangedObservable: BABYLON.Observable<Style>;
  53165. /**
  53166. * Creates a new style object
  53167. * @param host defines the AdvancedDynamicTexture which hosts this style
  53168. */
  53169. constructor(host: AdvancedDynamicTexture);
  53170. /**
  53171. * Gets or sets the font size
  53172. */
  53173. fontSize: string | number;
  53174. /**
  53175. * Gets or sets the font family
  53176. */
  53177. fontFamily: string;
  53178. /**
  53179. * Gets or sets the font style
  53180. */
  53181. fontStyle: string;
  53182. /** Gets or sets font weight */
  53183. fontWeight: string;
  53184. /** Dispose all associated resources */
  53185. dispose(): void;
  53186. }
  53187. }
  53188. declare module BABYLON.GUI {
  53189. /**
  53190. * Class used to transport BABYLON.Vector2 information for pointer events
  53191. */
  53192. export class Vector2WithInfo extends BABYLON.Vector2 {
  53193. /** defines the current mouse button index */
  53194. buttonIndex: number;
  53195. /**
  53196. * Creates a new Vector2WithInfo
  53197. * @param source defines the vector2 data to transport
  53198. * @param buttonIndex defines the current mouse button index
  53199. */
  53200. constructor(source: BABYLON.Vector2,
  53201. /** defines the current mouse button index */
  53202. buttonIndex?: number);
  53203. }
  53204. /** Class used to provide 2D matrix features */
  53205. export class Matrix2D {
  53206. /** Gets the internal array of 6 floats used to store matrix data */
  53207. m: Float32Array;
  53208. /**
  53209. * Creates a new matrix
  53210. * @param m00 defines value for (0, 0)
  53211. * @param m01 defines value for (0, 1)
  53212. * @param m10 defines value for (1, 0)
  53213. * @param m11 defines value for (1, 1)
  53214. * @param m20 defines value for (2, 0)
  53215. * @param m21 defines value for (2, 1)
  53216. */
  53217. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  53218. /**
  53219. * Fills the matrix from direct values
  53220. * @param m00 defines value for (0, 0)
  53221. * @param m01 defines value for (0, 1)
  53222. * @param m10 defines value for (1, 0)
  53223. * @param m11 defines value for (1, 1)
  53224. * @param m20 defines value for (2, 0)
  53225. * @param m21 defines value for (2, 1)
  53226. * @returns the current modified matrix
  53227. */
  53228. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  53229. /**
  53230. * Gets matrix determinant
  53231. * @returns the determinant
  53232. */
  53233. determinant(): number;
  53234. /**
  53235. * Inverses the matrix and stores it in a target matrix
  53236. * @param result defines the target matrix
  53237. * @returns the current matrix
  53238. */
  53239. invertToRef(result: Matrix2D): Matrix2D;
  53240. /**
  53241. * Multiplies the current matrix with another one
  53242. * @param other defines the second operand
  53243. * @param result defines the target matrix
  53244. * @returns the current matrix
  53245. */
  53246. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  53247. /**
  53248. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  53249. * @param x defines the x coordinate to transform
  53250. * @param y defines the x coordinate to transform
  53251. * @param result defines the target vector2
  53252. * @returns the current matrix
  53253. */
  53254. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  53255. /**
  53256. * Creates an identity matrix
  53257. * @returns a new matrix
  53258. */
  53259. static Identity(): Matrix2D;
  53260. /**
  53261. * Creates a translation matrix and stores it in a target matrix
  53262. * @param x defines the x coordinate of the translation
  53263. * @param y defines the y coordinate of the translation
  53264. * @param result defines the target matrix
  53265. */
  53266. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  53267. /**
  53268. * Creates a scaling matrix and stores it in a target matrix
  53269. * @param x defines the x coordinate of the scaling
  53270. * @param y defines the y coordinate of the scaling
  53271. * @param result defines the target matrix
  53272. */
  53273. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  53274. /**
  53275. * Creates a rotation matrix and stores it in a target matrix
  53276. * @param angle defines the rotation angle
  53277. * @param result defines the target matrix
  53278. */
  53279. static RotationToRef(angle: number, result: Matrix2D): void;
  53280. private static _TempPreTranslationMatrix;
  53281. private static _TempPostTranslationMatrix;
  53282. private static _TempRotationMatrix;
  53283. private static _TempScalingMatrix;
  53284. private static _TempCompose0;
  53285. private static _TempCompose1;
  53286. private static _TempCompose2;
  53287. /**
  53288. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  53289. * @param tx defines the x coordinate of the translation
  53290. * @param ty defines the y coordinate of the translation
  53291. * @param angle defines the rotation angle
  53292. * @param scaleX defines the x coordinate of the scaling
  53293. * @param scaleY defines the y coordinate of the scaling
  53294. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  53295. * @param result defines the target matrix
  53296. */
  53297. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  53298. }
  53299. }
  53300. declare module BABYLON.GUI {
  53301. /**
  53302. * Class used to store 2D control sizes
  53303. */
  53304. export class Measure {
  53305. /** defines left coordinate */
  53306. left: number;
  53307. /** defines top coordinate */
  53308. top: number;
  53309. /** defines width dimension */
  53310. width: number;
  53311. /** defines height dimension */
  53312. height: number;
  53313. /**
  53314. * Creates a new measure
  53315. * @param left defines left coordinate
  53316. * @param top defines top coordinate
  53317. * @param width defines width dimension
  53318. * @param height defines height dimension
  53319. */
  53320. constructor(
  53321. /** defines left coordinate */
  53322. left: number,
  53323. /** defines top coordinate */
  53324. top: number,
  53325. /** defines width dimension */
  53326. width: number,
  53327. /** defines height dimension */
  53328. height: number);
  53329. /**
  53330. * Copy from another measure
  53331. * @param other defines the other measure to copy from
  53332. */
  53333. copyFrom(other: Measure): void;
  53334. /**
  53335. * Copy from a group of 4 floats
  53336. * @param left defines left coordinate
  53337. * @param top defines top coordinate
  53338. * @param width defines width dimension
  53339. * @param height defines height dimension
  53340. */
  53341. copyFromFloats(left: number, top: number, width: number, height: number): void;
  53342. /**
  53343. * Computes the axis aligned bounding box measure for two given measures
  53344. * @param a Input measure
  53345. * @param b Input measure
  53346. * @param result the resulting bounding measure
  53347. */
  53348. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  53349. /**
  53350. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  53351. * @param transform the matrix to transform the measure before computing the AABB
  53352. * @param result the resulting AABB
  53353. */
  53354. transformToRef(transform: Matrix2D, result: Measure): void;
  53355. /**
  53356. * Check equality between this measure and another one
  53357. * @param other defines the other measures
  53358. * @returns true if both measures are equals
  53359. */
  53360. isEqualsTo(other: Measure): boolean;
  53361. /**
  53362. * Creates an empty measure
  53363. * @returns a new measure
  53364. */
  53365. static Empty(): Measure;
  53366. }
  53367. }
  53368. declare module BABYLON.GUI {
  53369. /**
  53370. * Interface used to define a control that can receive focus
  53371. */
  53372. export interface IFocusableControl {
  53373. /**
  53374. * Function called when the control receives the focus
  53375. */
  53376. onFocus(): void;
  53377. /**
  53378. * Function called when the control loses the focus
  53379. */
  53380. onBlur(): void;
  53381. /**
  53382. * Function called to let the control handle keyboard events
  53383. * @param evt defines the current keyboard event
  53384. */
  53385. processKeyboard(evt: KeyboardEvent): void;
  53386. /**
  53387. * Function called to get the list of controls that should not steal the focus from this control
  53388. * @returns an array of controls
  53389. */
  53390. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  53391. }
  53392. /**
  53393. * Class used to create texture to support 2D GUI elements
  53394. * @see http://doc.babylonjs.com/how_to/gui
  53395. */
  53396. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  53397. private _isDirty;
  53398. private _renderObserver;
  53399. private _resizeObserver;
  53400. private _preKeyboardObserver;
  53401. private _pointerMoveObserver;
  53402. private _pointerObserver;
  53403. private _canvasPointerOutObserver;
  53404. private _background;
  53405. /** @hidden */ rootContainer: Container;
  53406. /** @hidden */ lastPickedControl: Control;
  53407. /** @hidden */ lastControlOver: {
  53408. [pointerId: number]: Control;
  53409. };
  53410. /** @hidden */ lastControlDown: {
  53411. [pointerId: number]: Control;
  53412. };
  53413. /** @hidden */ capturingControl: {
  53414. [pointerId: number]: Control;
  53415. };
  53416. /** @hidden */ shouldBlockPointer: boolean;
  53417. /** @hidden */ layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  53418. /** @hidden */ linkedControls: Control[];
  53419. private _isFullscreen;
  53420. private _fullscreenViewport;
  53421. private _idealWidth;
  53422. private _idealHeight;
  53423. private _useSmallestIdeal;
  53424. private _renderAtIdealSize;
  53425. private _focusedControl;
  53426. private _blockNextFocusCheck;
  53427. private _renderScale;
  53428. private _rootCanvas;
  53429. /**
  53430. * Define type to string to ensure compatibility across browsers
  53431. * Safari doesn't support DataTransfer constructor
  53432. */
  53433. private _clipboardData;
  53434. /**
  53435. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  53436. */
  53437. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  53438. /**
  53439. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  53440. */
  53441. onControlPickedObservable: BABYLON.Observable<Control>;
  53442. /**
  53443. * BABYLON.Observable event triggered before layout is evaluated
  53444. */
  53445. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  53446. /**
  53447. * BABYLON.Observable event triggered after the layout was evaluated
  53448. */
  53449. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  53450. /**
  53451. * BABYLON.Observable event triggered before the texture is rendered
  53452. */
  53453. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  53454. /**
  53455. * BABYLON.Observable event triggered after the texture was rendered
  53456. */
  53457. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  53458. /**
  53459. * Gets or sets a boolean defining if alpha is stored as premultiplied
  53460. */
  53461. premulAlpha: boolean;
  53462. /**
  53463. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  53464. * Useful when you want more antialiasing
  53465. */
  53466. renderScale: number;
  53467. /** Gets or sets the background color */
  53468. background: string;
  53469. /**
  53470. * Gets or sets the ideal width used to design controls.
  53471. * The GUI will then rescale everything accordingly
  53472. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53473. */
  53474. idealWidth: number;
  53475. /**
  53476. * Gets or sets the ideal height used to design controls.
  53477. * The GUI will then rescale everything accordingly
  53478. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53479. */
  53480. idealHeight: number;
  53481. /**
  53482. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  53483. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53484. */
  53485. useSmallestIdeal: boolean;
  53486. /**
  53487. * Gets or sets a boolean indicating if adaptive scaling must be used
  53488. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53489. */
  53490. renderAtIdealSize: boolean;
  53491. /**
  53492. * Gets the underlying layer used to render the texture when in fullscreen mode
  53493. */
  53494. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  53495. /**
  53496. * Gets the root container control
  53497. */
  53498. readonly rootContainer: Container;
  53499. /**
  53500. * Returns an array containing the root container.
  53501. * This is mostly used to let the Inspector introspects the ADT
  53502. * @returns an array containing the rootContainer
  53503. */
  53504. getChildren(): Array<Container>;
  53505. /**
  53506. * Will return all controls that are inside this texture
  53507. * @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
  53508. * @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
  53509. * @return all child controls
  53510. */
  53511. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  53512. /**
  53513. * Gets or sets the current focused control
  53514. */
  53515. focusedControl: BABYLON.Nullable<IFocusableControl>;
  53516. /**
  53517. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  53518. */
  53519. isForeground: boolean;
  53520. /**
  53521. * Gets or set information about clipboardData
  53522. */
  53523. clipboardData: string;
  53524. /**
  53525. * Creates a new AdvancedDynamicTexture
  53526. * @param name defines the name of the texture
  53527. * @param width defines the width of the texture
  53528. * @param height defines the height of the texture
  53529. * @param scene defines the hosting scene
  53530. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  53531. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  53532. */
  53533. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  53534. /**
  53535. * Get the current class name of the texture useful for serialization or dynamic coding.
  53536. * @returns "AdvancedDynamicTexture"
  53537. */
  53538. getClassName(): string;
  53539. /**
  53540. * Function used to execute a function on all controls
  53541. * @param func defines the function to execute
  53542. * @param container defines the container where controls belong. If null the root container will be used
  53543. */
  53544. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  53545. private _useInvalidateRectOptimization;
  53546. /**
  53547. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  53548. */
  53549. useInvalidateRectOptimization: boolean;
  53550. private _invalidatedRectangle;
  53551. /**
  53552. * Invalidates a rectangle area on the gui texture
  53553. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  53554. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  53555. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  53556. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  53557. */
  53558. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  53559. /**
  53560. * Marks the texture as dirty forcing a complete update
  53561. */
  53562. markAsDirty(): void;
  53563. /**
  53564. * Helper function used to create a new style
  53565. * @returns a new style
  53566. * @see http://doc.babylonjs.com/how_to/gui#styles
  53567. */
  53568. createStyle(): Style;
  53569. /**
  53570. * Adds a new control to the root container
  53571. * @param control defines the control to add
  53572. * @returns the current texture
  53573. */
  53574. addControl(control: Control): AdvancedDynamicTexture;
  53575. /**
  53576. * Removes a control from the root container
  53577. * @param control defines the control to remove
  53578. * @returns the current texture
  53579. */
  53580. removeControl(control: Control): AdvancedDynamicTexture;
  53581. /**
  53582. * Release all resources
  53583. */
  53584. dispose(): void;
  53585. private _onResize;
  53586. /** @hidden */ getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  53587. /**
  53588. * Get screen coordinates for a vector3
  53589. * @param position defines the position to project
  53590. * @param worldMatrix defines the world matrix to use
  53591. * @returns the projected position
  53592. */
  53593. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  53594. private _checkUpdate;
  53595. private _clearMeasure;
  53596. private _render;
  53597. /** @hidden */ changeCursor(cursor: string): void;
  53598. /** @hidden */ registerLastControlDown(control: Control, pointerId: number): void;
  53599. private _doPicking;
  53600. /** @hidden */ cleanControlAfterRemovalFromList(list: {
  53601. [pointerId: number]: Control;
  53602. }, control: Control): void;
  53603. /** @hidden */ cleanControlAfterRemoval(control: Control): void;
  53604. /** Attach to all scene events required to support pointer events */
  53605. attach(): void;
  53606. /** @hidden */
  53607. private onClipboardCopy;
  53608. /** @hidden */
  53609. private onClipboardCut;
  53610. /** @hidden */
  53611. private onClipboardPaste;
  53612. /**
  53613. * Register the clipboard Events onto the canvas
  53614. */
  53615. registerClipboardEvents(): void;
  53616. /**
  53617. * Unregister the clipboard Events from the canvas
  53618. */
  53619. unRegisterClipboardEvents(): void;
  53620. /**
  53621. * Connect the texture to a hosting mesh to enable interactions
  53622. * @param mesh defines the mesh to attach to
  53623. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  53624. */
  53625. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  53626. /**
  53627. * Move the focus to a specific control
  53628. * @param control defines the control which will receive the focus
  53629. */
  53630. moveFocusToControl(control: IFocusableControl): void;
  53631. private _manageFocus;
  53632. private _attachToOnPointerOut;
  53633. /**
  53634. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  53635. * @param mesh defines the mesh which will receive the texture
  53636. * @param width defines the texture width (1024 by default)
  53637. * @param height defines the texture height (1024 by default)
  53638. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  53639. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  53640. * @returns a new AdvancedDynamicTexture
  53641. */
  53642. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  53643. /**
  53644. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  53645. * In this mode the texture will rely on a layer for its rendering.
  53646. * This allows it to be treated like any other layer.
  53647. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  53648. * LayerMask is set through advancedTexture.layer.layerMask
  53649. * @param name defines name for the texture
  53650. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  53651. * @param scene defines the hsoting scene
  53652. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  53653. * @returns a new AdvancedDynamicTexture
  53654. */
  53655. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  53656. }
  53657. }
  53658. declare module BABYLON.GUI {
  53659. /**
  53660. * Root class used for all 2D controls
  53661. * @see http://doc.babylonjs.com/how_to/gui#controls
  53662. */
  53663. export class Control {
  53664. /** defines the name of the control */
  53665. name?: string | undefined;
  53666. /**
  53667. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  53668. */
  53669. static AllowAlphaInheritance: boolean;
  53670. private _alpha;
  53671. private _alphaSet;
  53672. private _zIndex;
  53673. /** @hidden */ host: AdvancedDynamicTexture;
  53674. /** Gets or sets the control parent */
  53675. parent: BABYLON.Nullable<Container>;
  53676. /** @hidden */ currentMeasure: Measure;
  53677. private _fontFamily;
  53678. private _fontStyle;
  53679. private _fontWeight;
  53680. private _fontSize;
  53681. private _font;
  53682. /** @hidden */ width: ValueAndUnit;
  53683. /** @hidden */ height: ValueAndUnit;
  53684. /** @hidden */
  53685. protected _fontOffset: {
  53686. ascent: number;
  53687. height: number;
  53688. descent: number;
  53689. };
  53690. private _color;
  53691. private _style;
  53692. private _styleObserver;
  53693. /** @hidden */
  53694. protected _horizontalAlignment: number;
  53695. /** @hidden */
  53696. protected _verticalAlignment: number;
  53697. /** @hidden */
  53698. protected _isDirty: boolean;
  53699. /** @hidden */
  53700. protected _wasDirty: boolean;
  53701. /** @hidden */ tempParentMeasure: Measure;
  53702. /** @hidden */ prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  53703. /** @hidden */
  53704. protected _cachedParentMeasure: Measure;
  53705. private _paddingLeft;
  53706. private _paddingRight;
  53707. private _paddingTop;
  53708. private _paddingBottom;
  53709. /** @hidden */ left: ValueAndUnit;
  53710. /** @hidden */ top: ValueAndUnit;
  53711. private _scaleX;
  53712. private _scaleY;
  53713. private _rotation;
  53714. private _transformCenterX;
  53715. private _transformCenterY;
  53716. /** @hidden */ transformMatrix: Matrix2D;
  53717. /** @hidden */
  53718. protected _invertTransformMatrix: Matrix2D;
  53719. /** @hidden */
  53720. protected _transformedPosition: BABYLON.Vector2;
  53721. private _isMatrixDirty;
  53722. private _cachedOffsetX;
  53723. private _cachedOffsetY;
  53724. private _isVisible;
  53725. private _isHighlighted;
  53726. /** @hidden */ linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  53727. private _fontSet;
  53728. private _dummyVector2;
  53729. private _downCount;
  53730. private _enterCount;
  53731. private _doNotRender;
  53732. private _downPointerIds;
  53733. protected _isEnabled: boolean;
  53734. protected _disabledColor: string;
  53735. /** @hidden */
  53736. protected _rebuildLayout: boolean;
  53737. /** @hidden */ isClipped: boolean;
  53738. /** @hidden */ tag: any;
  53739. /**
  53740. * Gets or sets the unique id of the node. Please note that this number will be updated when the control is added to a container
  53741. */
  53742. uniqueId: number;
  53743. /**
  53744. * Gets or sets an object used to store user defined information for the node
  53745. */
  53746. metadata: any;
  53747. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  53748. isHitTestVisible: boolean;
  53749. /** Gets or sets a boolean indicating if the control can block pointer events */
  53750. isPointerBlocker: boolean;
  53751. /** Gets or sets a boolean indicating if the control can be focusable */
  53752. isFocusInvisible: boolean;
  53753. /**
  53754. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  53755. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  53756. */
  53757. clipChildren: boolean;
  53758. /**
  53759. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  53760. */
  53761. useBitmapCache: boolean;
  53762. private _cacheData;
  53763. private _shadowOffsetX;
  53764. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  53765. shadowOffsetX: number;
  53766. private _shadowOffsetY;
  53767. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  53768. shadowOffsetY: number;
  53769. private _shadowBlur;
  53770. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  53771. shadowBlur: number;
  53772. private _shadowColor;
  53773. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  53774. shadowColor: string;
  53775. /** Gets or sets the cursor to use when the control is hovered */
  53776. hoverCursor: string;
  53777. /** @hidden */
  53778. protected _linkOffsetX: ValueAndUnit;
  53779. /** @hidden */
  53780. protected _linkOffsetY: ValueAndUnit;
  53781. /** Gets the control type name */
  53782. readonly typeName: string;
  53783. /**
  53784. * Get the current class name of the control.
  53785. * @returns current class name
  53786. */
  53787. getClassName(): string;
  53788. /**
  53789. * An event triggered when the pointer move over the control.
  53790. */
  53791. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  53792. /**
  53793. * An event triggered when the pointer move out of the control.
  53794. */
  53795. onPointerOutObservable: BABYLON.Observable<Control>;
  53796. /**
  53797. * An event triggered when the pointer taps the control
  53798. */
  53799. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  53800. /**
  53801. * An event triggered when pointer up
  53802. */
  53803. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  53804. /**
  53805. * An event triggered when a control is clicked on
  53806. */
  53807. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  53808. /**
  53809. * An event triggered when pointer enters the control
  53810. */
  53811. onPointerEnterObservable: BABYLON.Observable<Control>;
  53812. /**
  53813. * An event triggered when the control is marked as dirty
  53814. */
  53815. onDirtyObservable: BABYLON.Observable<Control>;
  53816. /**
  53817. * An event triggered before drawing the control
  53818. */
  53819. onBeforeDrawObservable: BABYLON.Observable<Control>;
  53820. /**
  53821. * An event triggered after the control was drawn
  53822. */
  53823. onAfterDrawObservable: BABYLON.Observable<Control>;
  53824. /**
  53825. * Get the hosting AdvancedDynamicTexture
  53826. */
  53827. readonly host: AdvancedDynamicTexture;
  53828. /** Gets or set information about font offsets (used to render and align text) */
  53829. fontOffset: {
  53830. ascent: number;
  53831. height: number;
  53832. descent: number;
  53833. };
  53834. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  53835. alpha: number;
  53836. /**
  53837. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  53838. */
  53839. isHighlighted: boolean;
  53840. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  53841. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53842. */
  53843. scaleX: number;
  53844. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  53845. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53846. */
  53847. scaleY: number;
  53848. /** Gets or sets the rotation angle (0 by default)
  53849. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53850. */
  53851. rotation: number;
  53852. /** Gets or sets the transformation center on Y axis (0 by default)
  53853. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53854. */
  53855. transformCenterY: number;
  53856. /** Gets or sets the transformation center on X axis (0 by default)
  53857. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53858. */
  53859. transformCenterX: number;
  53860. /**
  53861. * Gets or sets the horizontal alignment
  53862. * @see http://doc.babylonjs.com/how_to/gui#alignments
  53863. */
  53864. horizontalAlignment: number;
  53865. /**
  53866. * Gets or sets the vertical alignment
  53867. * @see http://doc.babylonjs.com/how_to/gui#alignments
  53868. */
  53869. verticalAlignment: number;
  53870. /**
  53871. * Gets or sets control width
  53872. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53873. */
  53874. width: string | number;
  53875. /**
  53876. * Gets control width in pixel
  53877. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53878. */
  53879. readonly widthInPixels: number;
  53880. /**
  53881. * Gets or sets control height
  53882. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53883. */
  53884. height: string | number;
  53885. /**
  53886. * Gets control height in pixel
  53887. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53888. */
  53889. readonly heightInPixels: number;
  53890. /** Gets or set font family */
  53891. fontFamily: string;
  53892. /** Gets or sets font style */
  53893. fontStyle: string;
  53894. /** Gets or sets font weight */
  53895. fontWeight: string;
  53896. /**
  53897. * Gets or sets style
  53898. * @see http://doc.babylonjs.com/how_to/gui#styles
  53899. */
  53900. style: BABYLON.Nullable<Style>;
  53901. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  53902. /** Gets font size in pixels */
  53903. readonly fontSizeInPixels: number;
  53904. /** Gets or sets font size */
  53905. fontSize: string | number;
  53906. /** Gets or sets foreground color */
  53907. color: string;
  53908. /** Gets or sets z index which is used to reorder controls on the z axis */
  53909. zIndex: number;
  53910. /** Gets or sets a boolean indicating if the control can be rendered */
  53911. notRenderable: boolean;
  53912. /** Gets or sets a boolean indicating if the control is visible */
  53913. isVisible: boolean;
  53914. /** Gets a boolean indicating that the control needs to update its rendering */
  53915. readonly isDirty: boolean;
  53916. /**
  53917. * Gets the current linked mesh (or null if none)
  53918. */
  53919. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  53920. /**
  53921. * Gets or sets a value indicating the padding to use on the left of the control
  53922. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53923. */
  53924. paddingLeft: string | number;
  53925. /**
  53926. * Gets a value indicating the padding in pixels to use on the left of the control
  53927. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53928. */
  53929. readonly paddingLeftInPixels: number;
  53930. /**
  53931. * Gets or sets a value indicating the padding to use on the right of the control
  53932. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53933. */
  53934. paddingRight: string | number;
  53935. /**
  53936. * Gets a value indicating the padding in pixels to use on the right of the control
  53937. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53938. */
  53939. readonly paddingRightInPixels: number;
  53940. /**
  53941. * Gets or sets a value indicating the padding to use on the top of the control
  53942. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53943. */
  53944. paddingTop: string | number;
  53945. /**
  53946. * Gets a value indicating the padding in pixels to use on the top of the control
  53947. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53948. */
  53949. readonly paddingTopInPixels: number;
  53950. /**
  53951. * Gets or sets a value indicating the padding to use on the bottom of the control
  53952. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53953. */
  53954. paddingBottom: string | number;
  53955. /**
  53956. * Gets a value indicating the padding in pixels to use on the bottom of the control
  53957. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53958. */
  53959. readonly paddingBottomInPixels: number;
  53960. /**
  53961. * Gets or sets a value indicating the left coordinate of the control
  53962. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53963. */
  53964. left: string | number;
  53965. /**
  53966. * Gets a value indicating the left coordinate in pixels of the control
  53967. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53968. */
  53969. readonly leftInPixels: number;
  53970. /**
  53971. * Gets or sets a value indicating the top coordinate of the control
  53972. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53973. */
  53974. top: string | number;
  53975. /**
  53976. * Gets a value indicating the top coordinate in pixels of the control
  53977. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53978. */
  53979. readonly topInPixels: number;
  53980. /**
  53981. * Gets or sets a value indicating the offset on X axis to the linked mesh
  53982. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  53983. */
  53984. linkOffsetX: string | number;
  53985. /**
  53986. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  53987. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  53988. */
  53989. readonly linkOffsetXInPixels: number;
  53990. /**
  53991. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  53992. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  53993. */
  53994. linkOffsetY: string | number;
  53995. /**
  53996. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  53997. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  53998. */
  53999. readonly linkOffsetYInPixels: number;
  54000. /** Gets the center coordinate on X axis */
  54001. readonly centerX: number;
  54002. /** Gets the center coordinate on Y axis */
  54003. readonly centerY: number;
  54004. /** Gets or sets if control is Enabled*/
  54005. isEnabled: boolean;
  54006. /** Gets or sets background color of control if it's disabled*/
  54007. disabledColor: string;
  54008. /**
  54009. * Creates a new control
  54010. * @param name defines the name of the control
  54011. */
  54012. constructor(
  54013. /** defines the name of the control */
  54014. name?: string | undefined);
  54015. /** @hidden */
  54016. protected _getTypeName(): string;
  54017. /**
  54018. * Gets the first ascendant in the hierarchy of the given type
  54019. * @param className defines the required type
  54020. * @returns the ascendant or null if not found
  54021. */
  54022. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  54023. /** @hidden */ resetFontCache(): void;
  54024. /**
  54025. * Determines if a container is an ascendant of the current control
  54026. * @param container defines the container to look for
  54027. * @returns true if the container is one of the ascendant of the control
  54028. */
  54029. isAscendant(container: Control): boolean;
  54030. /**
  54031. * Gets coordinates in local control space
  54032. * @param globalCoordinates defines the coordinates to transform
  54033. * @returns the new coordinates in local space
  54034. */
  54035. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  54036. /**
  54037. * Gets coordinates in local control space
  54038. * @param globalCoordinates defines the coordinates to transform
  54039. * @param result defines the target vector2 where to store the result
  54040. * @returns the current control
  54041. */
  54042. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  54043. /**
  54044. * Gets coordinates in parent local control space
  54045. * @param globalCoordinates defines the coordinates to transform
  54046. * @returns the new coordinates in parent local space
  54047. */
  54048. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  54049. /**
  54050. * Move the current control to a vector3 position projected onto the screen.
  54051. * @param position defines the target position
  54052. * @param scene defines the hosting scene
  54053. */
  54054. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  54055. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  54056. /**
  54057. * Will return all controls that have this control as ascendant
  54058. * @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
  54059. * @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
  54060. * @return all child controls
  54061. */
  54062. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  54063. /**
  54064. * Link current control with a target mesh
  54065. * @param mesh defines the mesh to link with
  54066. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  54067. */
  54068. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  54069. /** @hidden */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  54070. /** @hidden */ offsetLeft(offset: number): void;
  54071. /** @hidden */ offsetTop(offset: number): void;
  54072. /** @hidden */ markMatrixAsDirty(): void;
  54073. /** @hidden */ flagDescendantsAsMatrixDirty(): void;
  54074. /** @hidden */ intersectsRect(rect: Measure): boolean;
  54075. /** @hidden */
  54076. protected invalidateRect(): void;
  54077. /** @hidden */ markAsDirty(force?: boolean): void;
  54078. /** @hidden */ markAllAsDirty(): void;
  54079. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  54080. /** @hidden */
  54081. protected _transform(context?: CanvasRenderingContext2D): void;
  54082. /** @hidden */ renderHighlight(context: CanvasRenderingContext2D): void;
  54083. /** @hidden */ renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  54084. /** @hidden */
  54085. protected _applyStates(context: CanvasRenderingContext2D): void;
  54086. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  54087. /** @hidden */
  54088. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54089. protected _evaluateClippingState(parentMeasure: Measure): void;
  54090. /** @hidden */ measure(): void;
  54091. /** @hidden */
  54092. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54093. /** @hidden */
  54094. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54095. /** @hidden */
  54096. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54097. /** @hidden */
  54098. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  54099. private static _ClipMeasure;
  54100. private _tmpMeasureA;
  54101. private _clip;
  54102. /** @hidden */ render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  54103. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  54104. /**
  54105. * Tests if a given coordinates belong to the current control
  54106. * @param x defines x coordinate to test
  54107. * @param y defines y coordinate to test
  54108. * @returns true if the coordinates are inside the control
  54109. */
  54110. contains(x: number, y: number): boolean;
  54111. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  54112. /** @hidden */ onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
  54113. /** @hidden */ onPointerEnter(target: Control): boolean;
  54114. /** @hidden */ onPointerOut(target: Control): void;
  54115. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  54116. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  54117. /** @hidden */ forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  54118. /** @hidden */ processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  54119. private _prepareFont;
  54120. /** Releases associated resources */
  54121. dispose(): void;
  54122. private static _HORIZONTAL_ALIGNMENT_LEFT;
  54123. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  54124. private static _HORIZONTAL_ALIGNMENT_CENTER;
  54125. private static _VERTICAL_ALIGNMENT_TOP;
  54126. private static _VERTICAL_ALIGNMENT_BOTTOM;
  54127. private static _VERTICAL_ALIGNMENT_CENTER;
  54128. /** HORIZONTAL_ALIGNMENT_LEFT */
  54129. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  54130. /** HORIZONTAL_ALIGNMENT_RIGHT */
  54131. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  54132. /** HORIZONTAL_ALIGNMENT_CENTER */
  54133. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  54134. /** VERTICAL_ALIGNMENT_TOP */
  54135. static readonly VERTICAL_ALIGNMENT_TOP: number;
  54136. /** VERTICAL_ALIGNMENT_BOTTOM */
  54137. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  54138. /** VERTICAL_ALIGNMENT_CENTER */
  54139. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  54140. private static _FontHeightSizes;
  54141. /** @hidden */ private static _GetFontOffset(font: string): {
  54142. ascent: number;
  54143. height: number;
  54144. descent: number;
  54145. };
  54146. /**
  54147. * Creates a stack panel that can be used to render headers
  54148. * @param control defines the control to associate with the header
  54149. * @param text defines the text of the header
  54150. * @param size defines the size of the header
  54151. * @param options defines options used to configure the header
  54152. * @returns a new StackPanel
  54153. * @ignore
  54154. * @hidden
  54155. */
  54156. static AddHeader: (control: Control, text: string, size: string | number, options: {
  54157. isHorizontal: boolean;
  54158. controlFirst: boolean;
  54159. }) => any;
  54160. /** @hidden */
  54161. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  54162. }
  54163. }
  54164. declare module BABYLON.GUI {
  54165. /**
  54166. * Root class for 2D containers
  54167. * @see http://doc.babylonjs.com/how_to/gui#containers
  54168. */
  54169. export class Container extends Control {
  54170. name?: string | undefined;
  54171. /** @hidden */
  54172. protected _children: Control[];
  54173. /** @hidden */
  54174. protected _measureForChildren: Measure;
  54175. /** @hidden */
  54176. protected _background: string;
  54177. /** @hidden */
  54178. protected _adaptWidthToChildren: boolean;
  54179. /** @hidden */
  54180. protected _adaptHeightToChildren: boolean;
  54181. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  54182. adaptHeightToChildren: boolean;
  54183. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  54184. adaptWidthToChildren: boolean;
  54185. /** Gets or sets background color */
  54186. background: string;
  54187. /** Gets the list of children */
  54188. readonly children: Control[];
  54189. /**
  54190. * Creates a new Container
  54191. * @param name defines the name of the container
  54192. */
  54193. constructor(name?: string | undefined);
  54194. protected _getTypeName(): string; flagDescendantsAsMatrixDirty(): void;
  54195. /**
  54196. * Gets a child using its name
  54197. * @param name defines the child name to look for
  54198. * @returns the child control if found
  54199. */
  54200. getChildByName(name: string): BABYLON.Nullable<Control>;
  54201. /**
  54202. * Gets a child using its type and its name
  54203. * @param name defines the child name to look for
  54204. * @param type defines the child type to look for
  54205. * @returns the child control if found
  54206. */
  54207. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  54208. /**
  54209. * Search for a specific control in children
  54210. * @param control defines the control to look for
  54211. * @returns true if the control is in child list
  54212. */
  54213. containsControl(control: Control): boolean;
  54214. /**
  54215. * Adds a new control to the current container
  54216. * @param control defines the control to add
  54217. * @returns the current container
  54218. */
  54219. addControl(control: BABYLON.Nullable<Control>): Container;
  54220. /**
  54221. * Removes all controls from the current container
  54222. * @returns the current container
  54223. */
  54224. clearControls(): Container;
  54225. /**
  54226. * Removes a control from the current container
  54227. * @param control defines the control to remove
  54228. * @returns the current container
  54229. */
  54230. removeControl(control: Control): Container;
  54231. /** @hidden */ reOrderControl(control: Control): void;
  54232. /** @hidden */ offsetLeft(offset: number): void;
  54233. /** @hidden */ offsetTop(offset: number): void;
  54234. /** @hidden */ markAllAsDirty(): void;
  54235. /** @hidden */
  54236. protected _localDraw(context: CanvasRenderingContext2D): void;
  54237. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  54238. /** @hidden */
  54239. protected _beforeLayout(): void;
  54240. /** @hidden */
  54241. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54242. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  54243. protected _postMeasure(): void;
  54244. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  54245. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  54246. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  54247. /** @hidden */
  54248. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54249. /** Releases associated resources */
  54250. dispose(): void;
  54251. }
  54252. }
  54253. declare module BABYLON.GUI {
  54254. /** Class used to create rectangle container */
  54255. export class Rectangle extends Container {
  54256. name?: string | undefined;
  54257. private _thickness;
  54258. private _cornerRadius;
  54259. /** Gets or sets border thickness */
  54260. thickness: number;
  54261. /** Gets or sets the corner radius angle */
  54262. cornerRadius: number;
  54263. /**
  54264. * Creates a new Rectangle
  54265. * @param name defines the control name
  54266. */
  54267. constructor(name?: string | undefined);
  54268. protected _getTypeName(): string;
  54269. protected _localDraw(context: CanvasRenderingContext2D): void;
  54270. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54271. private _drawRoundedRect;
  54272. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  54273. }
  54274. }
  54275. declare module BABYLON.GUI {
  54276. /**
  54277. * Enum that determines the text-wrapping mode to use.
  54278. */
  54279. export enum TextWrapping {
  54280. /**
  54281. * Clip the text when it's larger than Control.width; this is the default mode.
  54282. */
  54283. Clip = 0,
  54284. /**
  54285. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  54286. */
  54287. WordWrap = 1,
  54288. /**
  54289. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  54290. */
  54291. Ellipsis = 2
  54292. }
  54293. /**
  54294. * Class used to create text block control
  54295. */
  54296. export class TextBlock extends Control {
  54297. /**
  54298. * Defines the name of the control
  54299. */
  54300. name?: string | undefined;
  54301. private _text;
  54302. private _textWrapping;
  54303. private _textHorizontalAlignment;
  54304. private _textVerticalAlignment;
  54305. private _lines;
  54306. private _resizeToFit;
  54307. private _lineSpacing;
  54308. private _outlineWidth;
  54309. private _outlineColor;
  54310. /**
  54311. * An event triggered after the text is changed
  54312. */
  54313. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  54314. /**
  54315. * An event triggered after the text was broken up into lines
  54316. */
  54317. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  54318. /**
  54319. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  54320. */
  54321. readonly lines: any[];
  54322. /**
  54323. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  54324. */
  54325. /**
  54326. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  54327. */
  54328. resizeToFit: boolean;
  54329. /**
  54330. * Gets or sets a boolean indicating if text must be wrapped
  54331. */
  54332. /**
  54333. * Gets or sets a boolean indicating if text must be wrapped
  54334. */
  54335. textWrapping: TextWrapping | boolean;
  54336. /**
  54337. * Gets or sets text to display
  54338. */
  54339. /**
  54340. * Gets or sets text to display
  54341. */
  54342. text: string;
  54343. /**
  54344. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  54345. */
  54346. /**
  54347. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  54348. */
  54349. textHorizontalAlignment: number;
  54350. /**
  54351. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  54352. */
  54353. /**
  54354. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  54355. */
  54356. textVerticalAlignment: number;
  54357. /**
  54358. * Gets or sets line spacing value
  54359. */
  54360. /**
  54361. * Gets or sets line spacing value
  54362. */
  54363. lineSpacing: string | number;
  54364. /**
  54365. * Gets or sets outlineWidth of the text to display
  54366. */
  54367. /**
  54368. * Gets or sets outlineWidth of the text to display
  54369. */
  54370. outlineWidth: number;
  54371. /**
  54372. * Gets or sets outlineColor of the text to display
  54373. */
  54374. /**
  54375. * Gets or sets outlineColor of the text to display
  54376. */
  54377. outlineColor: string;
  54378. /**
  54379. * Creates a new TextBlock object
  54380. * @param name defines the name of the control
  54381. * @param text defines the text to display (emptry string by default)
  54382. */
  54383. constructor(
  54384. /**
  54385. * Defines the name of the control
  54386. */
  54387. name?: string | undefined, text?: string);
  54388. protected _getTypeName(): string;
  54389. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54390. private _drawText;
  54391. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  54392. protected _applyStates(context: CanvasRenderingContext2D): void;
  54393. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  54394. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  54395. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  54396. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  54397. protected _renderLines(context: CanvasRenderingContext2D): void;
  54398. /**
  54399. * Given a width constraint applied on the text block, find the expected height
  54400. * @returns expected height
  54401. */
  54402. computeExpectedHeight(): number;
  54403. dispose(): void;
  54404. }
  54405. }
  54406. declare module BABYLON.GUI {
  54407. /**
  54408. * Class used to create 2D images
  54409. */
  54410. export class Image extends Control {
  54411. name?: string | undefined;
  54412. private static _WorkingCanvas;
  54413. private _domImage;
  54414. private _imageWidth;
  54415. private _imageHeight;
  54416. private _loaded;
  54417. private _stretch;
  54418. private _source;
  54419. private _autoScale;
  54420. private _sourceLeft;
  54421. private _sourceTop;
  54422. private _sourceWidth;
  54423. private _sourceHeight;
  54424. private _cellWidth;
  54425. private _cellHeight;
  54426. private _cellId;
  54427. private _populateNinePatchSlicesFromImage;
  54428. private _sliceLeft;
  54429. private _sliceRight;
  54430. private _sliceTop;
  54431. private _sliceBottom;
  54432. private _detectPointerOnOpaqueOnly;
  54433. /**
  54434. * BABYLON.Observable notified when the content is loaded
  54435. */
  54436. onImageLoadedObservable: BABYLON.Observable<Image>;
  54437. /**
  54438. * Gets a boolean indicating that the content is loaded
  54439. */
  54440. readonly isLoaded: boolean;
  54441. /**
  54442. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  54443. */
  54444. populateNinePatchSlicesFromImage: boolean;
  54445. /**
  54446. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  54447. * Beware using this as this will comsume more memory as the image has to be stored twice
  54448. */
  54449. detectPointerOnOpaqueOnly: boolean;
  54450. /**
  54451. * Gets or sets the left value for slicing (9-patch)
  54452. */
  54453. sliceLeft: number;
  54454. /**
  54455. * Gets or sets the right value for slicing (9-patch)
  54456. */
  54457. sliceRight: number;
  54458. /**
  54459. * Gets or sets the top value for slicing (9-patch)
  54460. */
  54461. sliceTop: number;
  54462. /**
  54463. * Gets or sets the bottom value for slicing (9-patch)
  54464. */
  54465. sliceBottom: number;
  54466. /**
  54467. * Gets or sets the left coordinate in the source image
  54468. */
  54469. sourceLeft: number;
  54470. /**
  54471. * Gets or sets the top coordinate in the source image
  54472. */
  54473. sourceTop: number;
  54474. /**
  54475. * Gets or sets the width to capture in the source image
  54476. */
  54477. sourceWidth: number;
  54478. /**
  54479. * Gets or sets the height to capture in the source image
  54480. */
  54481. sourceHeight: number;
  54482. /**
  54483. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  54484. * @see http://doc.babylonjs.com/how_to/gui#image
  54485. */
  54486. autoScale: boolean;
  54487. /** Gets or sets the streching mode used by the image */
  54488. stretch: number;
  54489. /**
  54490. * Gets or sets the internal DOM image used to render the control
  54491. */
  54492. domImage: HTMLImageElement;
  54493. private _onImageLoaded;
  54494. private _extractNinePatchSliceDataFromImage;
  54495. /**
  54496. * Gets or sets image source url
  54497. */
  54498. source: BABYLON.Nullable<string>;
  54499. /**
  54500. * Gets or sets the cell width to use when animation sheet is enabled
  54501. * @see http://doc.babylonjs.com/how_to/gui#image
  54502. */
  54503. cellWidth: number;
  54504. /**
  54505. * Gets or sets the cell height to use when animation sheet is enabled
  54506. * @see http://doc.babylonjs.com/how_to/gui#image
  54507. */
  54508. cellHeight: number;
  54509. /**
  54510. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  54511. * @see http://doc.babylonjs.com/how_to/gui#image
  54512. */
  54513. cellId: number;
  54514. /**
  54515. * Creates a new Image
  54516. * @param name defines the control name
  54517. * @param url defines the image url
  54518. */
  54519. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  54520. /**
  54521. * Tests if a given coordinates belong to the current control
  54522. * @param x defines x coordinate to test
  54523. * @param y defines y coordinate to test
  54524. * @returns true if the coordinates are inside the control
  54525. */
  54526. contains(x: number, y: number): boolean;
  54527. protected _getTypeName(): string;
  54528. /** Force the control to synchronize with its content */
  54529. synchronizeSizeWithContent(): void;
  54530. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54531. private _prepareWorkingCanvasForOpaqueDetection;
  54532. private _drawImage; draw(context: CanvasRenderingContext2D): void;
  54533. private _renderCornerPatch;
  54534. private _renderNinePatch;
  54535. dispose(): void;
  54536. /** STRETCH_NONE */
  54537. static readonly STRETCH_NONE: number;
  54538. /** STRETCH_FILL */
  54539. static readonly STRETCH_FILL: number;
  54540. /** STRETCH_UNIFORM */
  54541. static readonly STRETCH_UNIFORM: number;
  54542. /** STRETCH_EXTEND */
  54543. static readonly STRETCH_EXTEND: number;
  54544. /** NINE_PATCH */
  54545. static readonly STRETCH_NINE_PATCH: number;
  54546. }
  54547. }
  54548. declare module BABYLON.GUI {
  54549. /**
  54550. * Class used to create 2D buttons
  54551. */
  54552. export class Button extends Rectangle {
  54553. name?: string | undefined;
  54554. /**
  54555. * Function called to generate a pointer enter animation
  54556. */
  54557. pointerEnterAnimation: () => void;
  54558. /**
  54559. * Function called to generate a pointer out animation
  54560. */
  54561. pointerOutAnimation: () => void;
  54562. /**
  54563. * Function called to generate a pointer down animation
  54564. */
  54565. pointerDownAnimation: () => void;
  54566. /**
  54567. * Function called to generate a pointer up animation
  54568. */
  54569. pointerUpAnimation: () => void;
  54570. private _image;
  54571. /**
  54572. * Returns the image part of the button (if any)
  54573. */
  54574. readonly image: BABYLON.Nullable<Image>;
  54575. private _textBlock;
  54576. /**
  54577. * Returns the image part of the button (if any)
  54578. */
  54579. readonly textBlock: BABYLON.Nullable<TextBlock>;
  54580. /**
  54581. * Creates a new Button
  54582. * @param name defines the name of the button
  54583. */
  54584. constructor(name?: string | undefined);
  54585. protected _getTypeName(): string;
  54586. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  54587. /** @hidden */ onPointerEnter(target: Control): boolean;
  54588. /** @hidden */ onPointerOut(target: Control): void;
  54589. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  54590. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  54591. /**
  54592. * Creates a new button made with an image and a text
  54593. * @param name defines the name of the button
  54594. * @param text defines the text of the button
  54595. * @param imageUrl defines the url of the image
  54596. * @returns a new Button
  54597. */
  54598. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  54599. /**
  54600. * Creates a new button made with an image
  54601. * @param name defines the name of the button
  54602. * @param imageUrl defines the url of the image
  54603. * @returns a new Button
  54604. */
  54605. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  54606. /**
  54607. * Creates a new button made with a text
  54608. * @param name defines the name of the button
  54609. * @param text defines the text of the button
  54610. * @returns a new Button
  54611. */
  54612. static CreateSimpleButton(name: string, text: string): Button;
  54613. /**
  54614. * Creates a new button made with an image and a centered text
  54615. * @param name defines the name of the button
  54616. * @param text defines the text of the button
  54617. * @param imageUrl defines the url of the image
  54618. * @returns a new Button
  54619. */
  54620. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  54621. }
  54622. }
  54623. declare module BABYLON.GUI {
  54624. /**
  54625. * Class used to create a 2D stack panel container
  54626. */
  54627. export class StackPanel extends Container {
  54628. name?: string | undefined;
  54629. private _isVertical;
  54630. private _manualWidth;
  54631. private _manualHeight;
  54632. private _doNotTrackManualChanges;
  54633. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  54634. isVertical: boolean;
  54635. /**
  54636. * Gets or sets panel width.
  54637. * This value should not be set when in horizontal mode as it will be computed automatically
  54638. */
  54639. width: string | number;
  54640. /**
  54641. * Gets or sets panel height.
  54642. * This value should not be set when in vertical mode as it will be computed automatically
  54643. */
  54644. height: string | number;
  54645. /**
  54646. * Creates a new StackPanel
  54647. * @param name defines control name
  54648. */
  54649. constructor(name?: string | undefined);
  54650. protected _getTypeName(): string;
  54651. /** @hidden */
  54652. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54653. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54654. protected _postMeasure(): void;
  54655. }
  54656. }
  54657. declare module BABYLON.GUI {
  54658. /**
  54659. * Class used to represent a 2D checkbox
  54660. */
  54661. export class Checkbox extends Control {
  54662. name?: string | undefined;
  54663. private _isChecked;
  54664. private _background;
  54665. private _checkSizeRatio;
  54666. private _thickness;
  54667. /** Gets or sets border thickness */
  54668. thickness: number;
  54669. /**
  54670. * BABYLON.Observable raised when isChecked property changes
  54671. */
  54672. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  54673. /** Gets or sets a value indicating the ratio between overall size and check size */
  54674. checkSizeRatio: number;
  54675. /** Gets or sets background color */
  54676. background: string;
  54677. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  54678. isChecked: boolean;
  54679. /**
  54680. * Creates a new CheckBox
  54681. * @param name defines the control name
  54682. */
  54683. constructor(name?: string | undefined);
  54684. protected _getTypeName(): string;
  54685. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  54686. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  54687. /**
  54688. * Utility function to easily create a checkbox with a header
  54689. * @param title defines the label to use for the header
  54690. * @param onValueChanged defines the callback to call when value changes
  54691. * @returns a StackPanel containing the checkbox and a textBlock
  54692. */
  54693. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  54694. }
  54695. }
  54696. declare module BABYLON.GUI {
  54697. /**
  54698. * Class used to store key control properties
  54699. */
  54700. export class KeyPropertySet {
  54701. /** Width */
  54702. width?: string;
  54703. /** Height */
  54704. height?: string;
  54705. /** Left padding */
  54706. paddingLeft?: string;
  54707. /** Right padding */
  54708. paddingRight?: string;
  54709. /** Top padding */
  54710. paddingTop?: string;
  54711. /** Bottom padding */
  54712. paddingBottom?: string;
  54713. /** Foreground color */
  54714. color?: string;
  54715. /** Background color */
  54716. background?: string;
  54717. }
  54718. /**
  54719. * Class used to create virtual keyboard
  54720. */
  54721. export class VirtualKeyboard extends StackPanel {
  54722. /** BABYLON.Observable raised when a key is pressed */
  54723. onKeyPressObservable: BABYLON.Observable<string>;
  54724. /** Gets or sets default key button width */
  54725. defaultButtonWidth: string;
  54726. /** Gets or sets default key button height */
  54727. defaultButtonHeight: string;
  54728. /** Gets or sets default key button left padding */
  54729. defaultButtonPaddingLeft: string;
  54730. /** Gets or sets default key button right padding */
  54731. defaultButtonPaddingRight: string;
  54732. /** Gets or sets default key button top padding */
  54733. defaultButtonPaddingTop: string;
  54734. /** Gets or sets default key button bottom padding */
  54735. defaultButtonPaddingBottom: string;
  54736. /** Gets or sets default key button foreground color */
  54737. defaultButtonColor: string;
  54738. /** Gets or sets default key button background color */
  54739. defaultButtonBackground: string;
  54740. /** Gets or sets shift button foreground color */
  54741. shiftButtonColor: string;
  54742. /** Gets or sets shift button thickness*/
  54743. selectedShiftThickness: number;
  54744. /** Gets shift key state */
  54745. shiftState: number;
  54746. protected _getTypeName(): string;
  54747. private _createKey;
  54748. /**
  54749. * Adds a new row of keys
  54750. * @param keys defines the list of keys to add
  54751. * @param propertySets defines the associated property sets
  54752. */
  54753. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  54754. /**
  54755. * Set the shift key to a specific state
  54756. * @param shiftState defines the new shift state
  54757. */
  54758. applyShiftState(shiftState: number): void;
  54759. private _currentlyConnectedInputText;
  54760. private _connectedInputTexts;
  54761. private _onKeyPressObserver;
  54762. /** Gets the input text control currently attached to the keyboard */
  54763. readonly connectedInputText: BABYLON.Nullable<InputText>;
  54764. /**
  54765. * Connects the keyboard with an input text control
  54766. *
  54767. * @param input defines the target control
  54768. */
  54769. connect(input: InputText): void;
  54770. /**
  54771. * Disconnects the keyboard from connected InputText controls
  54772. *
  54773. * @param input optionally defines a target control, otherwise all are disconnected
  54774. */
  54775. disconnect(input?: InputText): void;
  54776. private _removeConnectedInputObservables;
  54777. /**
  54778. * Release all resources
  54779. */
  54780. dispose(): void;
  54781. /**
  54782. * Creates a new keyboard using a default layout
  54783. *
  54784. * @param name defines control name
  54785. * @returns a new VirtualKeyboard
  54786. */
  54787. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  54788. }
  54789. }
  54790. declare module BABYLON.GUI {
  54791. /**
  54792. * Class used to create input text control
  54793. */
  54794. export class InputText extends Control implements IFocusableControl {
  54795. name?: string | undefined;
  54796. private _text;
  54797. private _placeholderText;
  54798. private _background;
  54799. private _focusedBackground;
  54800. private _focusedColor;
  54801. private _placeholderColor;
  54802. private _thickness;
  54803. private _margin;
  54804. private _autoStretchWidth;
  54805. private _maxWidth;
  54806. private _isFocused;
  54807. private _blinkTimeout;
  54808. private _blinkIsEven;
  54809. private _cursorOffset;
  54810. private _scrollLeft;
  54811. private _textWidth;
  54812. private _clickedCoordinate;
  54813. private _deadKey;
  54814. private _addKey;
  54815. private _currentKey;
  54816. private _isTextHighlightOn;
  54817. private _textHighlightColor;
  54818. private _highligherOpacity;
  54819. private _highlightedText;
  54820. private _startHighlightIndex;
  54821. private _endHighlightIndex;
  54822. private _cursorIndex;
  54823. private _onFocusSelectAll;
  54824. private _isPointerDown;
  54825. private _onClipboardObserver;
  54826. private _onPointerDblTapObserver;
  54827. /** @hidden */ connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  54828. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  54829. promptMessage: string;
  54830. /** BABYLON.Observable raised when the text changes */
  54831. onTextChangedObservable: BABYLON.Observable<InputText>;
  54832. /** BABYLON.Observable raised just before an entered character is to be added */
  54833. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  54834. /** BABYLON.Observable raised when the control gets the focus */
  54835. onFocusObservable: BABYLON.Observable<InputText>;
  54836. /** BABYLON.Observable raised when the control loses the focus */
  54837. onBlurObservable: BABYLON.Observable<InputText>;
  54838. /**Observable raised when the text is highlighted */
  54839. onTextHighlightObservable: BABYLON.Observable<InputText>;
  54840. /**Observable raised when copy event is triggered */
  54841. onTextCopyObservable: BABYLON.Observable<InputText>;
  54842. /** BABYLON.Observable raised when cut event is triggered */
  54843. onTextCutObservable: BABYLON.Observable<InputText>;
  54844. /** BABYLON.Observable raised when paste event is triggered */
  54845. onTextPasteObservable: BABYLON.Observable<InputText>;
  54846. /** BABYLON.Observable raised when a key event was processed */
  54847. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  54848. /** Gets or sets the maximum width allowed by the control */
  54849. maxWidth: string | number;
  54850. /** Gets the maximum width allowed by the control in pixels */
  54851. readonly maxWidthInPixels: number;
  54852. /** Gets or sets the text highlighter transparency; default: 0.4 */
  54853. highligherOpacity: number;
  54854. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  54855. onFocusSelectAll: boolean;
  54856. /** Gets or sets the text hightlight color */
  54857. textHighlightColor: string;
  54858. /** Gets or sets control margin */
  54859. margin: string;
  54860. /** Gets control margin in pixels */
  54861. readonly marginInPixels: number;
  54862. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  54863. autoStretchWidth: boolean;
  54864. /** Gets or sets border thickness */
  54865. thickness: number;
  54866. /** Gets or sets the background color when focused */
  54867. focusedBackground: string;
  54868. /** Gets or sets the background color when focused */
  54869. focusedColor: string;
  54870. /** Gets or sets the background color */
  54871. background: string;
  54872. /** Gets or sets the placeholder color */
  54873. placeholderColor: string;
  54874. /** Gets or sets the text displayed when the control is empty */
  54875. placeholderText: string;
  54876. /** Gets or sets the dead key flag */
  54877. deadKey: boolean;
  54878. /** Gets or sets the highlight text */
  54879. highlightedText: string;
  54880. /** Gets or sets if the current key should be added */
  54881. addKey: boolean;
  54882. /** Gets or sets the value of the current key being entered */
  54883. currentKey: string;
  54884. /** Gets or sets the text displayed in the control */
  54885. text: string;
  54886. /** Gets or sets control width */
  54887. width: string | number;
  54888. /**
  54889. * Creates a new InputText
  54890. * @param name defines the control name
  54891. * @param text defines the text of the control
  54892. */
  54893. constructor(name?: string | undefined, text?: string);
  54894. /** @hidden */
  54895. onBlur(): void;
  54896. /** @hidden */
  54897. onFocus(): void;
  54898. protected _getTypeName(): string;
  54899. /**
  54900. * Function called to get the list of controls that should not steal the focus from this control
  54901. * @returns an array of controls
  54902. */
  54903. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  54904. /** @hidden */
  54905. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  54906. /** @hidden */
  54907. private _updateValueFromCursorIndex;
  54908. /** @hidden */
  54909. private _processDblClick;
  54910. /** @hidden */
  54911. private _selectAllText;
  54912. /**
  54913. * Handles the keyboard event
  54914. * @param evt Defines the KeyboardEvent
  54915. */
  54916. processKeyboard(evt: KeyboardEvent): void;
  54917. /** @hidden */
  54918. private _onCopyText;
  54919. /** @hidden */
  54920. private _onCutText;
  54921. /** @hidden */
  54922. private _onPasteText; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  54923. protected _beforeRenderText(text: string): string;
  54924. dispose(): void;
  54925. }
  54926. }
  54927. declare module BABYLON.GUI {
  54928. /**
  54929. * Class used to create a 2D grid container
  54930. */
  54931. export class Grid extends Container {
  54932. name?: string | undefined;
  54933. private _rowDefinitions;
  54934. private _columnDefinitions;
  54935. private _cells;
  54936. private _childControls;
  54937. /**
  54938. * Gets the number of columns
  54939. */
  54940. readonly columnCount: number;
  54941. /**
  54942. * Gets the number of rows
  54943. */
  54944. readonly rowCount: number;
  54945. /** Gets the list of children */
  54946. readonly children: Control[];
  54947. /**
  54948. * Gets the definition of a specific row
  54949. * @param index defines the index of the row
  54950. * @returns the row definition
  54951. */
  54952. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  54953. /**
  54954. * Gets the definition of a specific column
  54955. * @param index defines the index of the column
  54956. * @returns the column definition
  54957. */
  54958. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  54959. /**
  54960. * Adds a new row to the grid
  54961. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  54962. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  54963. * @returns the current grid
  54964. */
  54965. addRowDefinition(height: number, isPixel?: boolean): Grid;
  54966. /**
  54967. * Adds a new column to the grid
  54968. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  54969. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  54970. * @returns the current grid
  54971. */
  54972. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  54973. /**
  54974. * Update a row definition
  54975. * @param index defines the index of the row to update
  54976. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  54977. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  54978. * @returns the current grid
  54979. */
  54980. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  54981. /**
  54982. * Update a column definition
  54983. * @param index defines the index of the column to update
  54984. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  54985. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  54986. * @returns the current grid
  54987. */
  54988. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  54989. /**
  54990. * Gets the list of children stored in a specific cell
  54991. * @param row defines the row to check
  54992. * @param column defines the column to check
  54993. * @returns the list of controls
  54994. */
  54995. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  54996. /**
  54997. * Gets a string representing the child cell info (row x column)
  54998. * @param child defines the control to get info from
  54999. * @returns a string containing the child cell info (row x column)
  55000. */
  55001. getChildCellInfo(child: Control): string;
  55002. private _removeCell;
  55003. private _offsetCell;
  55004. /**
  55005. * Remove a column definition at specified index
  55006. * @param index defines the index of the column to remove
  55007. * @returns the current grid
  55008. */
  55009. removeColumnDefinition(index: number): Grid;
  55010. /**
  55011. * Remove a row definition at specified index
  55012. * @param index defines the index of the row to remove
  55013. * @returns the current grid
  55014. */
  55015. removeRowDefinition(index: number): Grid;
  55016. /**
  55017. * Adds a new control to the current grid
  55018. * @param control defines the control to add
  55019. * @param row defines the row where to add the control (0 by default)
  55020. * @param column defines the column where to add the control (0 by default)
  55021. * @returns the current grid
  55022. */
  55023. addControl(control: Control, row?: number, column?: number): Grid;
  55024. /**
  55025. * Removes a control from the current container
  55026. * @param control defines the control to remove
  55027. * @returns the current container
  55028. */
  55029. removeControl(control: Control): Container;
  55030. /**
  55031. * Creates a new Grid
  55032. * @param name defines control name
  55033. */
  55034. constructor(name?: string | undefined);
  55035. protected _getTypeName(): string;
  55036. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  55037. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; flagDescendantsAsMatrixDirty(): void; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  55038. /** Releases associated resources */
  55039. dispose(): void;
  55040. }
  55041. }
  55042. declare module BABYLON.GUI {
  55043. /** Class used to create color pickers */
  55044. export class ColorPicker extends Control {
  55045. name?: string | undefined;
  55046. private static _Epsilon;
  55047. private _colorWheelCanvas;
  55048. private _value;
  55049. private _tmpColor;
  55050. private _pointerStartedOnSquare;
  55051. private _pointerStartedOnWheel;
  55052. private _squareLeft;
  55053. private _squareTop;
  55054. private _squareSize;
  55055. private _h;
  55056. private _s;
  55057. private _v;
  55058. /**
  55059. * BABYLON.Observable raised when the value changes
  55060. */
  55061. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  55062. /** Gets or sets the color of the color picker */
  55063. value: BABYLON.Color3;
  55064. /**
  55065. * Gets or sets control width
  55066. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  55067. */
  55068. width: string | number;
  55069. /**
  55070. * Gets or sets control height
  55071. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  55072. */
  55073. /** Gets or sets control height */
  55074. height: string | number;
  55075. /** Gets or sets control size */
  55076. size: string | number;
  55077. /**
  55078. * Creates a new ColorPicker
  55079. * @param name defines the control name
  55080. */
  55081. constructor(name?: string | undefined);
  55082. protected _getTypeName(): string;
  55083. /** @hidden */
  55084. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55085. private _updateSquareProps;
  55086. private _drawGradientSquare;
  55087. private _drawCircle;
  55088. private _createColorWheelCanvas;
  55089. private _RGBtoHSV;
  55090. private _HSVtoRGB;
  55091. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  55092. private _pointerIsDown;
  55093. private _updateValueFromPointer;
  55094. private _isPointOnSquare;
  55095. private _isPointOnWheel; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  55096. /**
  55097. * This function expands the color picker by creating a color picker dialog with manual
  55098. * color value input and the ability to save colors into an array to be used later in
  55099. * subsequent launches of the dialogue.
  55100. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  55101. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  55102. * @returns picked color as a hex string and the saved colors array as hex strings.
  55103. */
  55104. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  55105. pickerWidth?: string;
  55106. pickerHeight?: string;
  55107. headerHeight?: string;
  55108. lastColor?: string;
  55109. swatchLimit?: number;
  55110. numSwatchesPerLine?: number;
  55111. savedColors?: Array<string>;
  55112. }): Promise<{
  55113. savedColors?: string[];
  55114. pickedColor: string;
  55115. }>;
  55116. }
  55117. }
  55118. declare module BABYLON.GUI {
  55119. /** Class used to create 2D ellipse containers */
  55120. export class Ellipse extends Container {
  55121. name?: string | undefined;
  55122. private _thickness;
  55123. /** Gets or sets border thickness */
  55124. thickness: number;
  55125. /**
  55126. * Creates a new Ellipse
  55127. * @param name defines the control name
  55128. */
  55129. constructor(name?: string | undefined);
  55130. protected _getTypeName(): string;
  55131. protected _localDraw(context: CanvasRenderingContext2D): void;
  55132. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55133. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  55134. }
  55135. }
  55136. declare module BABYLON.GUI {
  55137. /**
  55138. * Class used to create a password control
  55139. */
  55140. export class InputPassword extends InputText {
  55141. protected _beforeRenderText(text: string): string;
  55142. }
  55143. }
  55144. declare module BABYLON.GUI {
  55145. /** Class used to render 2D lines */
  55146. export class Line extends Control {
  55147. name?: string | undefined;
  55148. private _lineWidth;
  55149. private _x1;
  55150. private _y1;
  55151. private _x2;
  55152. private _y2;
  55153. private _dash;
  55154. private _connectedControl;
  55155. private _connectedControlDirtyObserver;
  55156. /** Gets or sets the dash pattern */
  55157. dash: Array<number>;
  55158. /** Gets or sets the control connected with the line end */
  55159. connectedControl: Control;
  55160. /** Gets or sets start coordinates on X axis */
  55161. x1: string | number;
  55162. /** Gets or sets start coordinates on Y axis */
  55163. y1: string | number;
  55164. /** Gets or sets end coordinates on X axis */
  55165. x2: string | number;
  55166. /** Gets or sets end coordinates on Y axis */
  55167. y2: string | number;
  55168. /** Gets or sets line width */
  55169. lineWidth: number;
  55170. /** Gets or sets horizontal alignment */
  55171. horizontalAlignment: number;
  55172. /** Gets or sets vertical alignment */
  55173. verticalAlignment: number;
  55174. private readonly _effectiveX2;
  55175. private readonly _effectiveY2;
  55176. /**
  55177. * Creates a new Line
  55178. * @param name defines the control name
  55179. */
  55180. constructor(name?: string | undefined);
  55181. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; measure(): void;
  55182. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55183. /**
  55184. * Move one end of the line given 3D cartesian coordinates.
  55185. * @param position Targeted world position
  55186. * @param scene BABYLON.Scene
  55187. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  55188. */
  55189. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  55190. /**
  55191. * Move one end of the line to a position in screen absolute space.
  55192. * @param projectedPosition Position in screen absolute space (X, Y)
  55193. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  55194. */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  55195. }
  55196. }
  55197. declare module BABYLON.GUI {
  55198. /**
  55199. * Class used to store a point for a MultiLine object.
  55200. * The point can be pure 2D coordinates, a mesh or a control
  55201. */
  55202. export class MultiLinePoint {
  55203. private _multiLine;
  55204. private _x;
  55205. private _y;
  55206. private _control;
  55207. private _mesh;
  55208. private _controlObserver;
  55209. private _meshObserver;
  55210. /** @hidden */ point: BABYLON.Vector2;
  55211. /**
  55212. * Creates a new MultiLinePoint
  55213. * @param multiLine defines the source MultiLine object
  55214. */
  55215. constructor(multiLine: MultiLine);
  55216. /** Gets or sets x coordinate */
  55217. x: string | number;
  55218. /** Gets or sets y coordinate */
  55219. y: string | number;
  55220. /** Gets or sets the control associated with this point */
  55221. control: BABYLON.Nullable<Control>;
  55222. /** Gets or sets the mesh associated with this point */
  55223. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  55224. /** Resets links */
  55225. resetLinks(): void;
  55226. /**
  55227. * Gets a translation vector
  55228. * @returns the translation vector
  55229. */
  55230. translate(): BABYLON.Vector2;
  55231. private _translatePoint;
  55232. /** Release associated resources */
  55233. dispose(): void;
  55234. }
  55235. }
  55236. declare module BABYLON.GUI {
  55237. /**
  55238. * Class used to create multi line control
  55239. */
  55240. export class MultiLine extends Control {
  55241. name?: string | undefined;
  55242. private _lineWidth;
  55243. private _dash;
  55244. private _points;
  55245. private _minX;
  55246. private _minY;
  55247. private _maxX;
  55248. private _maxY;
  55249. /**
  55250. * Creates a new MultiLine
  55251. * @param name defines the control name
  55252. */
  55253. constructor(name?: string | undefined);
  55254. /** Gets or sets dash pattern */
  55255. dash: Array<number>;
  55256. /**
  55257. * Gets point stored at specified index
  55258. * @param index defines the index to look for
  55259. * @returns the requested point if found
  55260. */
  55261. getAt(index: number): MultiLinePoint;
  55262. /** Function called when a point is updated */
  55263. onPointUpdate: () => void;
  55264. /**
  55265. * Adds new points to the point collection
  55266. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  55267. * @returns the list of created MultiLinePoint
  55268. */
  55269. add(...items: (AbstractMesh | Control | {
  55270. x: string | number;
  55271. y: string | number;
  55272. })[]): MultiLinePoint[];
  55273. /**
  55274. * Adds a new point to the point collection
  55275. * @param item defines the item (mesh, control or 2d coordiantes) to add
  55276. * @returns the created MultiLinePoint
  55277. */
  55278. push(item?: (AbstractMesh | Control | {
  55279. x: string | number;
  55280. y: string | number;
  55281. })): MultiLinePoint;
  55282. /**
  55283. * Remove a specific value or point from the active point collection
  55284. * @param value defines the value or point to remove
  55285. */
  55286. remove(value: number | MultiLinePoint): void;
  55287. /**
  55288. * Resets this object to initial state (no point)
  55289. */
  55290. reset(): void;
  55291. /**
  55292. * Resets all links
  55293. */
  55294. resetLinks(): void;
  55295. /** Gets or sets line width */
  55296. lineWidth: number;
  55297. horizontalAlignment: number;
  55298. verticalAlignment: number;
  55299. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  55300. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; measure(): void;
  55301. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55302. dispose(): void;
  55303. }
  55304. }
  55305. declare module BABYLON.GUI {
  55306. /**
  55307. * Class used to create radio button controls
  55308. */
  55309. export class RadioButton extends Control {
  55310. name?: string | undefined;
  55311. private _isChecked;
  55312. private _background;
  55313. private _checkSizeRatio;
  55314. private _thickness;
  55315. /** Gets or sets border thickness */
  55316. thickness: number;
  55317. /** Gets or sets group name */
  55318. group: string;
  55319. /** BABYLON.Observable raised when isChecked is changed */
  55320. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  55321. /** Gets or sets a value indicating the ratio between overall size and check size */
  55322. checkSizeRatio: number;
  55323. /** Gets or sets background color */
  55324. background: string;
  55325. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  55326. isChecked: boolean;
  55327. /**
  55328. * Creates a new RadioButton
  55329. * @param name defines the control name
  55330. */
  55331. constructor(name?: string | undefined);
  55332. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  55333. /**
  55334. * Utility function to easily create a radio button with a header
  55335. * @param title defines the label to use for the header
  55336. * @param group defines the group to use for the radio button
  55337. * @param isChecked defines the initial state of the radio button
  55338. * @param onValueChanged defines the callback to call when value changes
  55339. * @returns a StackPanel containing the radio button and a textBlock
  55340. */
  55341. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  55342. }
  55343. }
  55344. declare module BABYLON.GUI {
  55345. /**
  55346. * Class used to create slider controls
  55347. */
  55348. export class BaseSlider extends Control {
  55349. name?: string | undefined;
  55350. protected _thumbWidth: ValueAndUnit;
  55351. private _minimum;
  55352. private _maximum;
  55353. private _value;
  55354. private _isVertical;
  55355. protected _barOffset: ValueAndUnit;
  55356. private _isThumbClamped;
  55357. protected _displayThumb: boolean;
  55358. protected _effectiveBarOffset: number;
  55359. protected _renderLeft: number;
  55360. protected _renderTop: number;
  55361. protected _renderWidth: number;
  55362. protected _renderHeight: number;
  55363. protected _backgroundBoxLength: number;
  55364. protected _backgroundBoxThickness: number;
  55365. protected _effectiveThumbThickness: number;
  55366. /** BABYLON.Observable raised when the sldier value changes */
  55367. onValueChangedObservable: BABYLON.Observable<number>;
  55368. /** Gets or sets a boolean indicating if the thumb must be rendered */
  55369. displayThumb: boolean;
  55370. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  55371. barOffset: string | number;
  55372. /** Gets main bar offset in pixels*/
  55373. readonly barOffsetInPixels: number;
  55374. /** Gets or sets thumb width */
  55375. thumbWidth: string | number;
  55376. /** Gets thumb width in pixels */
  55377. readonly thumbWidthInPixels: number;
  55378. /** Gets or sets minimum value */
  55379. minimum: number;
  55380. /** Gets or sets maximum value */
  55381. maximum: number;
  55382. /** Gets or sets current value */
  55383. value: number;
  55384. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  55385. isVertical: boolean;
  55386. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  55387. isThumbClamped: boolean;
  55388. /**
  55389. * Creates a new BaseSlider
  55390. * @param name defines the control name
  55391. */
  55392. constructor(name?: string | undefined);
  55393. protected _getTypeName(): string;
  55394. protected _getThumbPosition(): number;
  55395. protected _getThumbThickness(type: string): number;
  55396. protected _prepareRenderingData(type: string): void;
  55397. private _pointerIsDown;
  55398. /** @hidden */
  55399. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  55400. }
  55401. }
  55402. declare module BABYLON.GUI {
  55403. /**
  55404. * Class used to create slider controls
  55405. */
  55406. export class Slider extends BaseSlider {
  55407. name?: string | undefined;
  55408. private _background;
  55409. private _borderColor;
  55410. private _isThumbCircle;
  55411. protected _displayValueBar: boolean;
  55412. /** Gets or sets a boolean indicating if the value bar must be rendered */
  55413. displayValueBar: boolean;
  55414. /** Gets or sets border color */
  55415. borderColor: string;
  55416. /** Gets or sets background color */
  55417. background: string;
  55418. /** Gets or sets a boolean indicating if the thumb should be round or square */
  55419. isThumbCircle: boolean;
  55420. /**
  55421. * Creates a new Slider
  55422. * @param name defines the control name
  55423. */
  55424. constructor(name?: string | undefined);
  55425. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  55426. }
  55427. }
  55428. declare module BABYLON.GUI {
  55429. /** Class used to create a RadioGroup
  55430. * which contains groups of radio buttons
  55431. */
  55432. export class SelectorGroup {
  55433. /** name of SelectorGroup */
  55434. name: string;
  55435. private _groupPanel;
  55436. private _selectors;
  55437. private _groupHeader;
  55438. /**
  55439. * Creates a new SelectorGroup
  55440. * @param name of group, used as a group heading
  55441. */
  55442. constructor(
  55443. /** name of SelectorGroup */
  55444. name: string);
  55445. /** Gets the groupPanel of the SelectorGroup */
  55446. readonly groupPanel: StackPanel;
  55447. /** Gets the selectors array */
  55448. readonly selectors: StackPanel[];
  55449. /** Gets and sets the group header */
  55450. header: string;
  55451. /** @hidden */
  55452. private _addGroupHeader;
  55453. /** @hidden*/ getSelector(selectorNb: number): StackPanel | undefined;
  55454. /** Removes the selector at the given position
  55455. * @param selectorNb the position of the selector within the group
  55456. */
  55457. removeSelector(selectorNb: number): void;
  55458. }
  55459. /** Class used to create a CheckboxGroup
  55460. * which contains groups of checkbox buttons
  55461. */
  55462. export class CheckboxGroup extends SelectorGroup {
  55463. /** Adds a checkbox as a control
  55464. * @param text is the label for the selector
  55465. * @param func is the function called when the Selector is checked
  55466. * @param checked is true when Selector is checked
  55467. */
  55468. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  55469. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  55470. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  55471. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  55472. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  55473. }
  55474. /** Class used to create a RadioGroup
  55475. * which contains groups of radio buttons
  55476. */
  55477. export class RadioGroup extends SelectorGroup {
  55478. private _selectNb;
  55479. /** Adds a radio button as a control
  55480. * @param label is the label for the selector
  55481. * @param func is the function called when the Selector is checked
  55482. * @param checked is true when Selector is checked
  55483. */
  55484. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  55485. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  55486. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  55487. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  55488. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  55489. }
  55490. /** Class used to create a SliderGroup
  55491. * which contains groups of slider buttons
  55492. */
  55493. export class SliderGroup extends SelectorGroup {
  55494. /**
  55495. * Adds a slider to the SelectorGroup
  55496. * @param label is the label for the SliderBar
  55497. * @param func is the function called when the Slider moves
  55498. * @param unit is a string describing the units used, eg degrees or metres
  55499. * @param min is the minimum value for the Slider
  55500. * @param max is the maximum value for the Slider
  55501. * @param value is the start value for the Slider between min and max
  55502. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  55503. */
  55504. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  55505. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  55506. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  55507. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  55508. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  55509. }
  55510. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  55511. * @see http://doc.babylonjs.com/how_to/selector
  55512. */
  55513. export class SelectionPanel extends Rectangle {
  55514. /** name of SelectionPanel */
  55515. name: string;
  55516. /** an array of SelectionGroups */
  55517. groups: SelectorGroup[];
  55518. private _panel;
  55519. private _buttonColor;
  55520. private _buttonBackground;
  55521. private _headerColor;
  55522. private _barColor;
  55523. private _barHeight;
  55524. private _spacerHeight;
  55525. private _labelColor;
  55526. private _groups;
  55527. private _bars;
  55528. /**
  55529. * Creates a new SelectionPanel
  55530. * @param name of SelectionPanel
  55531. * @param groups is an array of SelectionGroups
  55532. */
  55533. constructor(
  55534. /** name of SelectionPanel */
  55535. name: string,
  55536. /** an array of SelectionGroups */
  55537. groups?: SelectorGroup[]);
  55538. protected _getTypeName(): string;
  55539. /** Gets or sets the headerColor */
  55540. headerColor: string;
  55541. private _setHeaderColor;
  55542. /** Gets or sets the button color */
  55543. buttonColor: string;
  55544. private _setbuttonColor;
  55545. /** Gets or sets the label color */
  55546. labelColor: string;
  55547. private _setLabelColor;
  55548. /** Gets or sets the button background */
  55549. buttonBackground: string;
  55550. private _setButtonBackground;
  55551. /** Gets or sets the color of separator bar */
  55552. barColor: string;
  55553. private _setBarColor;
  55554. /** Gets or sets the height of separator bar */
  55555. barHeight: string;
  55556. private _setBarHeight;
  55557. /** Gets or sets the height of spacers*/
  55558. spacerHeight: string;
  55559. private _setSpacerHeight;
  55560. /** Adds a bar between groups */
  55561. private _addSpacer;
  55562. /** Add a group to the selection panel
  55563. * @param group is the selector group to add
  55564. */
  55565. addGroup(group: SelectorGroup): void;
  55566. /** Remove the group from the given position
  55567. * @param groupNb is the position of the group in the list
  55568. */
  55569. removeGroup(groupNb: number): void;
  55570. /** Change a group header label
  55571. * @param label is the new group header label
  55572. * @param groupNb is the number of the group to relabel
  55573. * */
  55574. setHeaderName(label: string, groupNb: number): void;
  55575. /** Change selector label to the one given
  55576. * @param label is the new selector label
  55577. * @param groupNb is the number of the groupcontaining the selector
  55578. * @param selectorNb is the number of the selector within a group to relabel
  55579. * */
  55580. relabel(label: string, groupNb: number, selectorNb: number): void;
  55581. /** For a given group position remove the selector at the given position
  55582. * @param groupNb is the number of the group to remove the selector from
  55583. * @param selectorNb is the number of the selector within the group
  55584. */
  55585. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  55586. /** For a given group position of correct type add a checkbox button
  55587. * @param groupNb is the number of the group to remove the selector from
  55588. * @param label is the label for the selector
  55589. * @param func is the function called when the Selector is checked
  55590. * @param checked is true when Selector is checked
  55591. */
  55592. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  55593. /** For a given group position of correct type add a radio button
  55594. * @param groupNb is the number of the group to remove the selector from
  55595. * @param label is the label for the selector
  55596. * @param func is the function called when the Selector is checked
  55597. * @param checked is true when Selector is checked
  55598. */
  55599. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  55600. /**
  55601. * For a given slider group add a slider
  55602. * @param groupNb is the number of the group to add the slider to
  55603. * @param label is the label for the Slider
  55604. * @param func is the function called when the Slider moves
  55605. * @param unit is a string describing the units used, eg degrees or metres
  55606. * @param min is the minimum value for the Slider
  55607. * @param max is the maximum value for the Slider
  55608. * @param value is the start value for the Slider between min and max
  55609. * @param onVal is the function used to format the value displayed, eg radians to degrees
  55610. */
  55611. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  55612. }
  55613. }
  55614. declare module BABYLON.GUI {
  55615. /**
  55616. * Class used to hold a the container for ScrollViewer
  55617. * @hidden
  55618. */
  55619. export class _ScrollViewerWindow extends Container {
  55620. parentClientWidth: number;
  55621. parentClientHeight: number;
  55622. /**
  55623. * Creates a new ScrollViewerWindow
  55624. * @param name of ScrollViewerWindow
  55625. */
  55626. constructor(name?: string);
  55627. protected _getTypeName(): string;
  55628. /** @hidden */
  55629. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55630. protected _postMeasure(): void;
  55631. }
  55632. }
  55633. declare module BABYLON.GUI {
  55634. /**
  55635. * Class used to create slider controls
  55636. */
  55637. export class ScrollBar extends BaseSlider {
  55638. name?: string | undefined;
  55639. private _background;
  55640. private _borderColor;
  55641. private _thumbMeasure;
  55642. /** Gets or sets border color */
  55643. borderColor: string;
  55644. /** Gets or sets background color */
  55645. background: string;
  55646. /**
  55647. * Creates a new Slider
  55648. * @param name defines the control name
  55649. */
  55650. constructor(name?: string | undefined);
  55651. protected _getTypeName(): string;
  55652. protected _getThumbThickness(): number; draw(context: CanvasRenderingContext2D): void;
  55653. private _first;
  55654. private _originX;
  55655. private _originY;
  55656. /** @hidden */
  55657. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  55658. }
  55659. }
  55660. declare module BABYLON.GUI {
  55661. /**
  55662. * Class used to hold a viewer window and sliders in a grid
  55663. */
  55664. export class ScrollViewer extends Rectangle {
  55665. private _grid;
  55666. private _horizontalBarSpace;
  55667. private _verticalBarSpace;
  55668. private _dragSpace;
  55669. private _horizontalBar;
  55670. private _verticalBar;
  55671. private _barColor;
  55672. private _barBackground;
  55673. private _barSize;
  55674. private _endLeft;
  55675. private _endTop;
  55676. private _window;
  55677. private _pointerIsOver;
  55678. private _wheelPrecision;
  55679. private _onPointerObserver;
  55680. private _clientWidth;
  55681. private _clientHeight;
  55682. /**
  55683. * Gets the horizontal scrollbar
  55684. */
  55685. readonly horizontalBar: ScrollBar;
  55686. /**
  55687. * Gets the vertical scrollbar
  55688. */
  55689. readonly verticalBar: ScrollBar;
  55690. /**
  55691. * Adds a new control to the current container
  55692. * @param control defines the control to add
  55693. * @returns the current container
  55694. */
  55695. addControl(control: BABYLON.Nullable<Control>): Container;
  55696. /**
  55697. * Removes a control from the current container
  55698. * @param control defines the control to remove
  55699. * @returns the current container
  55700. */
  55701. removeControl(control: Control): Container;
  55702. /** Gets the list of children */
  55703. readonly children: Control[]; flagDescendantsAsMatrixDirty(): void;
  55704. /**
  55705. * Creates a new ScrollViewer
  55706. * @param name of ScrollViewer
  55707. */
  55708. constructor(name?: string);
  55709. /** Reset the scroll viewer window to initial size */
  55710. resetWindow(): void;
  55711. protected _getTypeName(): string;
  55712. private _buildClientSizes;
  55713. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55714. protected _postMeasure(): void;
  55715. /**
  55716. * Gets or sets the mouse wheel precision
  55717. * from 0 to 1 with a default value of 0.05
  55718. * */
  55719. wheelPrecision: number;
  55720. /** Gets or sets the bar color */
  55721. barColor: string;
  55722. /** Gets or sets the size of the bar */
  55723. barSize: number;
  55724. /** Gets or sets the bar background */
  55725. barBackground: string;
  55726. /** @hidden */
  55727. private _updateScroller; link(host: AdvancedDynamicTexture): void;
  55728. /** @hidden */
  55729. private _attachWheel; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  55730. /** Releases associated resources */
  55731. dispose(): void;
  55732. }
  55733. }
  55734. declare module BABYLON.GUI {
  55735. /** Class used to render a grid */
  55736. export class DisplayGrid extends Control {
  55737. name?: string | undefined;
  55738. private _cellWidth;
  55739. private _cellHeight;
  55740. private _minorLineTickness;
  55741. private _minorLineColor;
  55742. private _majorLineTickness;
  55743. private _majorLineColor;
  55744. private _majorLineFrequency;
  55745. private _background;
  55746. private _displayMajorLines;
  55747. private _displayMinorLines;
  55748. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  55749. displayMinorLines: boolean;
  55750. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  55751. displayMajorLines: boolean;
  55752. /** Gets or sets background color (Black by default) */
  55753. background: string;
  55754. /** Gets or sets the width of each cell (20 by default) */
  55755. cellWidth: number;
  55756. /** Gets or sets the height of each cell (20 by default) */
  55757. cellHeight: number;
  55758. /** Gets or sets the tickness of minor lines (1 by default) */
  55759. minorLineTickness: number;
  55760. /** Gets or sets the color of minor lines (DarkGray by default) */
  55761. minorLineColor: string;
  55762. /** Gets or sets the tickness of major lines (2 by default) */
  55763. majorLineTickness: number;
  55764. /** Gets or sets the color of major lines (White by default) */
  55765. majorLineColor: string;
  55766. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  55767. majorLineFrequency: number;
  55768. /**
  55769. * Creates a new GridDisplayRectangle
  55770. * @param name defines the control name
  55771. */
  55772. constructor(name?: string | undefined); draw(context: CanvasRenderingContext2D): void;
  55773. protected _getTypeName(): string;
  55774. }
  55775. }
  55776. declare module BABYLON.GUI {
  55777. /**
  55778. * Class used to create slider controls based on images
  55779. */
  55780. export class ImageBasedSlider extends BaseSlider {
  55781. name?: string | undefined;
  55782. private _backgroundImage;
  55783. private _thumbImage;
  55784. private _valueBarImage;
  55785. private _tempMeasure;
  55786. displayThumb: boolean;
  55787. /**
  55788. * Gets or sets the image used to render the background
  55789. */
  55790. backgroundImage: Image;
  55791. /**
  55792. * Gets or sets the image used to render the value bar
  55793. */
  55794. valueBarImage: Image;
  55795. /**
  55796. * Gets or sets the image used to render the thumb
  55797. */
  55798. thumbImage: Image;
  55799. /**
  55800. * Creates a new ImageBasedSlider
  55801. * @param name defines the control name
  55802. */
  55803. constructor(name?: string | undefined);
  55804. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  55805. }
  55806. }
  55807. declare module BABYLON.GUI {
  55808. /**
  55809. * Forcing an export so that this code will execute
  55810. * @hidden
  55811. */
  55812. const name = "Statics";
  55813. }
  55814. declare module BABYLON.GUI {
  55815. /**
  55816. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  55817. */
  55818. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  55819. /**
  55820. * Define the instrumented AdvancedDynamicTexture.
  55821. */
  55822. texture: AdvancedDynamicTexture;
  55823. private _captureRenderTime;
  55824. private _renderTime;
  55825. private _captureLayoutTime;
  55826. private _layoutTime;
  55827. private _onBeginRenderObserver;
  55828. private _onEndRenderObserver;
  55829. private _onBeginLayoutObserver;
  55830. private _onEndLayoutObserver;
  55831. /**
  55832. * Gets the perf counter used to capture render time
  55833. */
  55834. readonly renderTimeCounter: BABYLON.PerfCounter;
  55835. /**
  55836. * Gets the perf counter used to capture layout time
  55837. */
  55838. readonly layoutTimeCounter: BABYLON.PerfCounter;
  55839. /**
  55840. * Enable or disable the render time capture
  55841. */
  55842. captureRenderTime: boolean;
  55843. /**
  55844. * Enable or disable the layout time capture
  55845. */
  55846. captureLayoutTime: boolean;
  55847. /**
  55848. * Instantiates a new advanced dynamic texture instrumentation.
  55849. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  55850. * @param texture Defines the AdvancedDynamicTexture to instrument
  55851. */
  55852. constructor(
  55853. /**
  55854. * Define the instrumented AdvancedDynamicTexture.
  55855. */
  55856. texture: AdvancedDynamicTexture);
  55857. /**
  55858. * Dispose and release associated resources.
  55859. */
  55860. dispose(): void;
  55861. }
  55862. }
  55863. declare module BABYLON.GUI {
  55864. /**
  55865. * Class used to create containers for controls
  55866. */
  55867. export class Container3D extends Control3D {
  55868. private _blockLayout;
  55869. /**
  55870. * Gets the list of child controls
  55871. */
  55872. protected _children: Control3D[];
  55873. /**
  55874. * Gets the list of child controls
  55875. */
  55876. readonly children: Array<Control3D>;
  55877. /**
  55878. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  55879. * This is helpful to optimize layout operation when adding multiple children in a row
  55880. */
  55881. blockLayout: boolean;
  55882. /**
  55883. * Creates a new container
  55884. * @param name defines the container name
  55885. */
  55886. constructor(name?: string);
  55887. /**
  55888. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  55889. * @returns the current container
  55890. */
  55891. updateLayout(): Container3D;
  55892. /**
  55893. * Gets a boolean indicating if the given control is in the children of this control
  55894. * @param control defines the control to check
  55895. * @returns true if the control is in the child list
  55896. */
  55897. containsControl(control: Control3D): boolean;
  55898. /**
  55899. * Adds a control to the children of this control
  55900. * @param control defines the control to add
  55901. * @returns the current container
  55902. */
  55903. addControl(control: Control3D): Container3D;
  55904. /**
  55905. * This function will be called everytime a new control is added
  55906. */
  55907. protected _arrangeChildren(): void;
  55908. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  55909. /**
  55910. * Removes a control from the children of this control
  55911. * @param control defines the control to remove
  55912. * @returns the current container
  55913. */
  55914. removeControl(control: Control3D): Container3D;
  55915. protected _getTypeName(): string;
  55916. /**
  55917. * Releases all associated resources
  55918. */
  55919. dispose(): void;
  55920. /** Control rotation will remain unchanged */
  55921. static readonly UNSET_ORIENTATION: number;
  55922. /** Control will rotate to make it look at sphere central axis */
  55923. static readonly FACEORIGIN_ORIENTATION: number;
  55924. /** Control will rotate to make it look back at sphere central axis */
  55925. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  55926. /** Control will rotate to look at z axis (0, 0, 1) */
  55927. static readonly FACEFORWARD_ORIENTATION: number;
  55928. /** Control will rotate to look at negative z axis (0, 0, -1) */
  55929. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  55930. }
  55931. }
  55932. declare module BABYLON.GUI {
  55933. /**
  55934. * Class used to manage 3D user interface
  55935. * @see http://doc.babylonjs.com/how_to/gui3d
  55936. */
  55937. export class GUI3DManager implements BABYLON.IDisposable {
  55938. private _scene;
  55939. private _sceneDisposeObserver;
  55940. private _utilityLayer;
  55941. private _rootContainer;
  55942. private _pointerObserver;
  55943. private _pointerOutObserver;
  55944. /** @hidden */ lastPickedControl: Control3D;
  55945. /** @hidden */ lastControlOver: {
  55946. [pointerId: number]: Control3D;
  55947. };
  55948. /** @hidden */ lastControlDown: {
  55949. [pointerId: number]: Control3D;
  55950. };
  55951. /**
  55952. * BABYLON.Observable raised when the point picked by the pointer events changed
  55953. */
  55954. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  55955. /** @hidden */ sharedMaterials: {
  55956. [key: string]: BABYLON.Material;
  55957. };
  55958. /** Gets the hosting scene */
  55959. readonly scene: BABYLON.Scene;
  55960. /** Gets associated utility layer */
  55961. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  55962. /**
  55963. * Creates a new GUI3DManager
  55964. * @param scene
  55965. */
  55966. constructor(scene?: BABYLON.Scene);
  55967. private _handlePointerOut;
  55968. private _doPicking;
  55969. /**
  55970. * Gets the root container
  55971. */
  55972. readonly rootContainer: Container3D;
  55973. /**
  55974. * Gets a boolean indicating if the given control is in the root child list
  55975. * @param control defines the control to check
  55976. * @returns true if the control is in the root child list
  55977. */
  55978. containsControl(control: Control3D): boolean;
  55979. /**
  55980. * Adds a control to the root child list
  55981. * @param control defines the control to add
  55982. * @returns the current manager
  55983. */
  55984. addControl(control: Control3D): GUI3DManager;
  55985. /**
  55986. * Removes a control from the root child list
  55987. * @param control defines the control to remove
  55988. * @returns the current container
  55989. */
  55990. removeControl(control: Control3D): GUI3DManager;
  55991. /**
  55992. * Releases all associated resources
  55993. */
  55994. dispose(): void;
  55995. }
  55996. }
  55997. declare module BABYLON.GUI {
  55998. /**
  55999. * Class used to transport BABYLON.Vector3 information for pointer events
  56000. */
  56001. export class Vector3WithInfo extends BABYLON.Vector3 {
  56002. /** defines the current mouse button index */
  56003. buttonIndex: number;
  56004. /**
  56005. * Creates a new Vector3WithInfo
  56006. * @param source defines the vector3 data to transport
  56007. * @param buttonIndex defines the current mouse button index
  56008. */
  56009. constructor(source: BABYLON.Vector3,
  56010. /** defines the current mouse button index */
  56011. buttonIndex?: number);
  56012. }
  56013. }
  56014. declare module BABYLON.GUI {
  56015. /**
  56016. * Class used as base class for controls
  56017. */
  56018. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  56019. /** Defines the control name */
  56020. name?: string | undefined;
  56021. /** @hidden */ host: GUI3DManager;
  56022. private _node;
  56023. private _downCount;
  56024. private _enterCount;
  56025. private _downPointerIds;
  56026. private _isVisible;
  56027. /** Gets or sets the control position in world space */
  56028. position: BABYLON.Vector3;
  56029. /** Gets or sets the control scaling in world space */
  56030. scaling: BABYLON.Vector3;
  56031. /** Callback used to start pointer enter animation */
  56032. pointerEnterAnimation: () => void;
  56033. /** Callback used to start pointer out animation */
  56034. pointerOutAnimation: () => void;
  56035. /** Callback used to start pointer down animation */
  56036. pointerDownAnimation: () => void;
  56037. /** Callback used to start pointer up animation */
  56038. pointerUpAnimation: () => void;
  56039. /**
  56040. * An event triggered when the pointer move over the control
  56041. */
  56042. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  56043. /**
  56044. * An event triggered when the pointer move out of the control
  56045. */
  56046. onPointerOutObservable: BABYLON.Observable<Control3D>;
  56047. /**
  56048. * An event triggered when the pointer taps the control
  56049. */
  56050. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  56051. /**
  56052. * An event triggered when pointer is up
  56053. */
  56054. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  56055. /**
  56056. * An event triggered when a control is clicked on (with a mouse)
  56057. */
  56058. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  56059. /**
  56060. * An event triggered when pointer enters the control
  56061. */
  56062. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  56063. /**
  56064. * Gets or sets the parent container
  56065. */
  56066. parent: BABYLON.Nullable<Container3D>;
  56067. private _behaviors;
  56068. /**
  56069. * Gets the list of attached behaviors
  56070. * @see http://doc.babylonjs.com/features/behaviour
  56071. */
  56072. readonly behaviors: BABYLON.Behavior<Control3D>[];
  56073. /**
  56074. * Attach a behavior to the control
  56075. * @see http://doc.babylonjs.com/features/behaviour
  56076. * @param behavior defines the behavior to attach
  56077. * @returns the current control
  56078. */
  56079. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  56080. /**
  56081. * Remove an attached behavior
  56082. * @see http://doc.babylonjs.com/features/behaviour
  56083. * @param behavior defines the behavior to attach
  56084. * @returns the current control
  56085. */
  56086. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  56087. /**
  56088. * Gets an attached behavior by name
  56089. * @param name defines the name of the behavior to look for
  56090. * @see http://doc.babylonjs.com/features/behaviour
  56091. * @returns null if behavior was not found else the requested behavior
  56092. */
  56093. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  56094. /** Gets or sets a boolean indicating if the control is visible */
  56095. isVisible: boolean;
  56096. /**
  56097. * Creates a new control
  56098. * @param name defines the control name
  56099. */
  56100. constructor(
  56101. /** Defines the control name */
  56102. name?: string | undefined);
  56103. /**
  56104. * Gets a string representing the class name
  56105. */
  56106. readonly typeName: string;
  56107. /**
  56108. * Get the current class name of the control.
  56109. * @returns current class name
  56110. */
  56111. getClassName(): string;
  56112. protected _getTypeName(): string;
  56113. /**
  56114. * Gets the transform node used by this control
  56115. */
  56116. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  56117. /**
  56118. * Gets the mesh used to render this control
  56119. */
  56120. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56121. /**
  56122. * Link the control as child of the given node
  56123. * @param node defines the node to link to. Use null to unlink the control
  56124. * @returns the current control
  56125. */
  56126. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  56127. /** @hidden **/ prepareNode(scene: BABYLON.Scene): void;
  56128. /**
  56129. * Node creation.
  56130. * Can be overriden by children
  56131. * @param scene defines the scene where the node must be attached
  56132. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  56133. */
  56134. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  56135. /**
  56136. * Affect a material to the given mesh
  56137. * @param mesh defines the mesh which will represent the control
  56138. */
  56139. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  56140. /** @hidden */ onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  56141. /** @hidden */ onPointerEnter(target: Control3D): boolean;
  56142. /** @hidden */ onPointerOut(target: Control3D): void;
  56143. /** @hidden */ onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  56144. /** @hidden */ onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  56145. /** @hidden */
  56146. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  56147. /** @hidden */ processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  56148. /** @hidden */ disposeNode(): void;
  56149. /**
  56150. * Releases all associated resources
  56151. */
  56152. dispose(): void;
  56153. }
  56154. }
  56155. declare module BABYLON.GUI {
  56156. /**
  56157. * Class used as a root to all buttons
  56158. */
  56159. export class AbstractButton3D extends Control3D {
  56160. /**
  56161. * Creates a new button
  56162. * @param name defines the control name
  56163. */
  56164. constructor(name?: string);
  56165. protected _getTypeName(): string;
  56166. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  56167. }
  56168. }
  56169. declare module BABYLON.GUI {
  56170. /**
  56171. * Class used to create a button in 3D
  56172. */
  56173. export class Button3D extends AbstractButton3D {
  56174. /** @hidden */
  56175. protected _currentMaterial: BABYLON.Material;
  56176. private _facadeTexture;
  56177. private _content;
  56178. private _contentResolution;
  56179. private _contentScaleRatio;
  56180. /**
  56181. * Gets or sets the texture resolution used to render content (512 by default)
  56182. */
  56183. contentResolution: BABYLON.int;
  56184. /**
  56185. * Gets or sets the texture scale ratio used to render content (2 by default)
  56186. */
  56187. contentScaleRatio: number;
  56188. protected _disposeFacadeTexture(): void;
  56189. protected _resetContent(): void;
  56190. /**
  56191. * Creates a new button
  56192. * @param name defines the control name
  56193. */
  56194. constructor(name?: string);
  56195. /**
  56196. * Gets or sets the GUI 2D content used to display the button's facade
  56197. */
  56198. content: Control;
  56199. /**
  56200. * Apply the facade texture (created from the content property).
  56201. * This function can be overloaded by child classes
  56202. * @param facadeTexture defines the AdvancedDynamicTexture to use
  56203. */
  56204. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  56205. protected _getTypeName(): string;
  56206. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  56207. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  56208. /**
  56209. * Releases all associated resources
  56210. */
  56211. dispose(): void;
  56212. }
  56213. }
  56214. declare module BABYLON.GUI {
  56215. /**
  56216. * Abstract class used to create a container panel deployed on the surface of a volume
  56217. */
  56218. export abstract class VolumeBasedPanel extends Container3D {
  56219. private _columns;
  56220. private _rows;
  56221. private _rowThenColum;
  56222. private _orientation;
  56223. protected _cellWidth: number;
  56224. protected _cellHeight: number;
  56225. /**
  56226. * Gets or sets the distance between elements
  56227. */
  56228. margin: number;
  56229. /**
  56230. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  56231. * | Value | Type | Description |
  56232. * | ----- | ----------------------------------- | ----------- |
  56233. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  56234. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  56235. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  56236. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  56237. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  56238. */
  56239. orientation: number;
  56240. /**
  56241. * Gets or sets the number of columns requested (10 by default).
  56242. * The panel will automatically compute the number of rows based on number of child controls.
  56243. */
  56244. columns: BABYLON.int;
  56245. /**
  56246. * Gets or sets a the number of rows requested.
  56247. * The panel will automatically compute the number of columns based on number of child controls.
  56248. */
  56249. rows: BABYLON.int;
  56250. /**
  56251. * Creates new VolumeBasedPanel
  56252. */
  56253. constructor();
  56254. protected _arrangeChildren(): void;
  56255. /** Child classes must implement this function to provide correct control positioning */
  56256. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56257. /** Child classes can implement this function to provide additional processing */
  56258. protected _finalProcessing(): void;
  56259. }
  56260. }
  56261. declare module BABYLON.GUI {
  56262. /**
  56263. * Class used to create a container panel deployed on the surface of a cylinder
  56264. */
  56265. export class CylinderPanel extends VolumeBasedPanel {
  56266. private _radius;
  56267. /**
  56268. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  56269. */
  56270. radius: BABYLON.float;
  56271. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56272. private _cylindricalMapping;
  56273. }
  56274. }
  56275. declare module BABYLON.GUI {
  56276. /** @hidden */
  56277. export var fluentVertexShader: {
  56278. name: string;
  56279. shader: string;
  56280. };
  56281. }
  56282. declare module BABYLON.GUI {
  56283. /** @hidden */
  56284. export var fluentPixelShader: {
  56285. name: string;
  56286. shader: string;
  56287. };
  56288. }
  56289. declare module BABYLON.GUI {
  56290. /** @hidden */
  56291. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  56292. INNERGLOW: boolean;
  56293. BORDER: boolean;
  56294. HOVERLIGHT: boolean;
  56295. TEXTURE: boolean;
  56296. constructor();
  56297. }
  56298. /**
  56299. * Class used to render controls with fluent desgin
  56300. */
  56301. export class FluentMaterial extends BABYLON.PushMaterial {
  56302. /**
  56303. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  56304. */
  56305. innerGlowColorIntensity: number;
  56306. /**
  56307. * Gets or sets the inner glow color (white by default)
  56308. */
  56309. innerGlowColor: BABYLON.Color3;
  56310. /**
  56311. * Gets or sets alpha value (default is 1.0)
  56312. */
  56313. alpha: number;
  56314. /**
  56315. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  56316. */
  56317. albedoColor: BABYLON.Color3;
  56318. /**
  56319. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  56320. */
  56321. renderBorders: boolean;
  56322. /**
  56323. * Gets or sets border width (default is 0.5)
  56324. */
  56325. borderWidth: number;
  56326. /**
  56327. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  56328. */
  56329. edgeSmoothingValue: number;
  56330. /**
  56331. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  56332. */
  56333. borderMinValue: number;
  56334. /**
  56335. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  56336. */
  56337. renderHoverLight: boolean;
  56338. /**
  56339. * Gets or sets the radius used to render the hover light (default is 1.0)
  56340. */
  56341. hoverRadius: number;
  56342. /**
  56343. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  56344. */
  56345. hoverColor: BABYLON.Color4;
  56346. /**
  56347. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  56348. */
  56349. hoverPosition: BABYLON.Vector3;
  56350. private _albedoTexture;
  56351. /** Gets or sets the texture to use for albedo color */
  56352. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  56353. /**
  56354. * Creates a new Fluent material
  56355. * @param name defines the name of the material
  56356. * @param scene defines the hosting scene
  56357. */
  56358. constructor(name: string, scene: BABYLON.Scene);
  56359. needAlphaBlending(): boolean;
  56360. needAlphaTesting(): boolean;
  56361. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  56362. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  56363. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  56364. getActiveTextures(): BABYLON.BaseTexture[];
  56365. hasTexture(texture: BABYLON.BaseTexture): boolean;
  56366. dispose(forceDisposeEffect?: boolean): void;
  56367. clone(name: string): FluentMaterial;
  56368. serialize(): any;
  56369. getClassName(): string;
  56370. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  56371. }
  56372. }
  56373. declare module BABYLON.GUI {
  56374. /**
  56375. * Class used to create a holographic button in 3D
  56376. */
  56377. export class HolographicButton extends Button3D {
  56378. private _backPlate;
  56379. private _textPlate;
  56380. private _frontPlate;
  56381. private _text;
  56382. private _imageUrl;
  56383. private _shareMaterials;
  56384. private _frontMaterial;
  56385. private _backMaterial;
  56386. private _plateMaterial;
  56387. private _pickedPointObserver;
  56388. private _tooltipFade;
  56389. private _tooltipTextBlock;
  56390. private _tooltipTexture;
  56391. private _tooltipMesh;
  56392. private _tooltipHoverObserver;
  56393. private _tooltipOutObserver;
  56394. private _disposeTooltip;
  56395. /**
  56396. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  56397. */
  56398. tooltipText: BABYLON.Nullable<string>;
  56399. /**
  56400. * Gets or sets text for the button
  56401. */
  56402. text: string;
  56403. /**
  56404. * Gets or sets the image url for the button
  56405. */
  56406. imageUrl: string;
  56407. /**
  56408. * Gets the back material used by this button
  56409. */
  56410. readonly backMaterial: FluentMaterial;
  56411. /**
  56412. * Gets the front material used by this button
  56413. */
  56414. readonly frontMaterial: FluentMaterial;
  56415. /**
  56416. * Gets the plate material used by this button
  56417. */
  56418. readonly plateMaterial: BABYLON.StandardMaterial;
  56419. /**
  56420. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  56421. */
  56422. readonly shareMaterials: boolean;
  56423. /**
  56424. * Creates a new button
  56425. * @param name defines the control name
  56426. */
  56427. constructor(name?: string, shareMaterials?: boolean);
  56428. protected _getTypeName(): string;
  56429. private _rebuildContent;
  56430. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  56431. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  56432. private _createBackMaterial;
  56433. private _createFrontMaterial;
  56434. private _createPlateMaterial;
  56435. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  56436. /**
  56437. * Releases all associated resources
  56438. */
  56439. dispose(): void;
  56440. }
  56441. }
  56442. declare module BABYLON.GUI {
  56443. /**
  56444. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  56445. */
  56446. export class MeshButton3D extends Button3D {
  56447. /** @hidden */
  56448. protected _currentMesh: BABYLON.Mesh;
  56449. /**
  56450. * Creates a new 3D button based on a mesh
  56451. * @param mesh mesh to become a 3D button
  56452. * @param name defines the control name
  56453. */
  56454. constructor(mesh: BABYLON.Mesh, name?: string);
  56455. protected _getTypeName(): string;
  56456. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  56457. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  56458. }
  56459. }
  56460. declare module BABYLON.GUI {
  56461. /**
  56462. * Class used to create a container panel deployed on the surface of a plane
  56463. */
  56464. export class PlanePanel extends VolumeBasedPanel {
  56465. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56466. }
  56467. }
  56468. declare module BABYLON.GUI {
  56469. /**
  56470. * Class used to create a container panel where items get randomized planar mapping
  56471. */
  56472. export class ScatterPanel extends VolumeBasedPanel {
  56473. private _iteration;
  56474. /**
  56475. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  56476. */
  56477. iteration: BABYLON.float;
  56478. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56479. private _scatterMapping;
  56480. protected _finalProcessing(): void;
  56481. }
  56482. }
  56483. declare module BABYLON.GUI {
  56484. /**
  56485. * Class used to create a container panel deployed on the surface of a sphere
  56486. */
  56487. export class SpherePanel extends VolumeBasedPanel {
  56488. private _radius;
  56489. /**
  56490. * Gets or sets the radius of the sphere where to project controls (5 by default)
  56491. */
  56492. radius: BABYLON.float;
  56493. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56494. private _sphericalMapping;
  56495. }
  56496. }
  56497. declare module BABYLON.GUI {
  56498. /**
  56499. * Class used to create a stack panel in 3D on XY plane
  56500. */
  56501. export class StackPanel3D extends Container3D {
  56502. private _isVertical;
  56503. /**
  56504. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  56505. */
  56506. isVertical: boolean;
  56507. /**
  56508. * Gets or sets the distance between elements
  56509. */
  56510. margin: number;
  56511. /**
  56512. * Creates new StackPanel
  56513. * @param isVertical
  56514. */
  56515. constructor(isVertical?: boolean);
  56516. protected _arrangeChildren(): void;
  56517. }
  56518. }
  56519. declare module BABYLON {
  56520. /**
  56521. * Mode that determines the coordinate system to use.
  56522. */
  56523. export enum GLTFLoaderCoordinateSystemMode {
  56524. /**
  56525. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  56526. */
  56527. AUTO = 0,
  56528. /**
  56529. * Sets the useRightHandedSystem flag on the scene.
  56530. */
  56531. FORCE_RIGHT_HANDED = 1
  56532. }
  56533. /**
  56534. * Mode that determines what animations will start.
  56535. */
  56536. export enum GLTFLoaderAnimationStartMode {
  56537. /**
  56538. * No animation will start.
  56539. */
  56540. NONE = 0,
  56541. /**
  56542. * The first animation will start.
  56543. */
  56544. FIRST = 1,
  56545. /**
  56546. * All animations will start.
  56547. */
  56548. ALL = 2
  56549. }
  56550. /**
  56551. * Interface that contains the data for the glTF asset.
  56552. */
  56553. export interface IGLTFLoaderData {
  56554. /**
  56555. * Object that represents the glTF JSON.
  56556. */
  56557. json: Object;
  56558. /**
  56559. * The BIN chunk of a binary glTF.
  56560. */
  56561. bin: Nullable<ArrayBufferView>;
  56562. }
  56563. /**
  56564. * Interface for extending the loader.
  56565. */
  56566. export interface IGLTFLoaderExtension {
  56567. /**
  56568. * The name of this extension.
  56569. */
  56570. readonly name: string;
  56571. /**
  56572. * Defines whether this extension is enabled.
  56573. */
  56574. enabled: boolean;
  56575. }
  56576. /**
  56577. * Loader state.
  56578. */
  56579. export enum GLTFLoaderState {
  56580. /**
  56581. * The asset is loading.
  56582. */
  56583. LOADING = 0,
  56584. /**
  56585. * The asset is ready for rendering.
  56586. */
  56587. READY = 1,
  56588. /**
  56589. * The asset is completely loaded.
  56590. */
  56591. COMPLETE = 2
  56592. }
  56593. /** @hidden */
  56594. export interface IGLTFLoader extends IDisposable {
  56595. readonly state: Nullable<GLTFLoaderState>;
  56596. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  56597. meshes: AbstractMesh[];
  56598. particleSystems: IParticleSystem[];
  56599. skeletons: Skeleton[];
  56600. animationGroups: AnimationGroup[];
  56601. }>;
  56602. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  56603. }
  56604. /**
  56605. * File loader for loading glTF files into a scene.
  56606. */
  56607. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  56608. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  56609. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  56610. /**
  56611. * Raised when the asset has been parsed
  56612. */
  56613. onParsedObservable: Observable<IGLTFLoaderData>;
  56614. private _onParsedObserver;
  56615. /**
  56616. * Raised when the asset has been parsed
  56617. */
  56618. onParsed: (loaderData: IGLTFLoaderData) => void;
  56619. /**
  56620. * 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.
  56621. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  56622. * Defaults to true.
  56623. * @hidden
  56624. */
  56625. static IncrementalLoading: boolean;
  56626. /**
  56627. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  56628. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  56629. * @hidden
  56630. */
  56631. static HomogeneousCoordinates: boolean;
  56632. /**
  56633. * The coordinate system mode. Defaults to AUTO.
  56634. */
  56635. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  56636. /**
  56637. * The animation start mode. Defaults to FIRST.
  56638. */
  56639. animationStartMode: GLTFLoaderAnimationStartMode;
  56640. /**
  56641. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  56642. */
  56643. compileMaterials: boolean;
  56644. /**
  56645. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  56646. */
  56647. useClipPlane: boolean;
  56648. /**
  56649. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  56650. */
  56651. compileShadowGenerators: boolean;
  56652. /**
  56653. * Defines if the Alpha blended materials are only applied as coverage.
  56654. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  56655. * If true, no extra effects are applied to transparent pixels.
  56656. */
  56657. transparencyAsCoverage: boolean;
  56658. /**
  56659. * Function called before loading a url referenced by the asset.
  56660. */
  56661. preprocessUrlAsync: (url: string) => Promise<string>;
  56662. /**
  56663. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  56664. */
  56665. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  56666. private _onMeshLoadedObserver;
  56667. /**
  56668. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  56669. */
  56670. onMeshLoaded: (mesh: AbstractMesh) => void;
  56671. /**
  56672. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  56673. */
  56674. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  56675. private _onTextureLoadedObserver;
  56676. /**
  56677. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  56678. */
  56679. onTextureLoaded: (texture: BaseTexture) => void;
  56680. /**
  56681. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  56682. */
  56683. readonly onMaterialLoadedObservable: Observable<Material>;
  56684. private _onMaterialLoadedObserver;
  56685. /**
  56686. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  56687. */
  56688. onMaterialLoaded: (material: Material) => void;
  56689. /**
  56690. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  56691. */
  56692. readonly onCameraLoadedObservable: Observable<Camera>;
  56693. private _onCameraLoadedObserver;
  56694. /**
  56695. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  56696. */
  56697. onCameraLoaded: (camera: Camera) => void;
  56698. /**
  56699. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  56700. * For assets with LODs, raised when all of the LODs are complete.
  56701. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  56702. */
  56703. readonly onCompleteObservable: Observable<void>;
  56704. private _onCompleteObserver;
  56705. /**
  56706. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  56707. * For assets with LODs, raised when all of the LODs are complete.
  56708. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  56709. */
  56710. onComplete: () => void;
  56711. /**
  56712. * Observable raised when an error occurs.
  56713. */
  56714. readonly onErrorObservable: Observable<any>;
  56715. private _onErrorObserver;
  56716. /**
  56717. * Callback raised when an error occurs.
  56718. */
  56719. onError: (reason: any) => void;
  56720. /**
  56721. * Observable raised after the loader is disposed.
  56722. */
  56723. readonly onDisposeObservable: Observable<void>;
  56724. private _onDisposeObserver;
  56725. /**
  56726. * Callback raised after the loader is disposed.
  56727. */
  56728. onDispose: () => void;
  56729. /**
  56730. * Observable raised after a loader extension is created.
  56731. * Set additional options for a loader extension in this event.
  56732. */
  56733. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  56734. private _onExtensionLoadedObserver;
  56735. /**
  56736. * Callback raised after a loader extension is created.
  56737. */
  56738. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  56739. /**
  56740. * Defines if the loader logging is enabled.
  56741. */
  56742. loggingEnabled: boolean;
  56743. /**
  56744. * Defines if the loader should capture performance counters.
  56745. */
  56746. capturePerformanceCounters: boolean;
  56747. /**
  56748. * Defines if the loader should validate the asset.
  56749. */
  56750. validate: boolean;
  56751. /**
  56752. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  56753. */
  56754. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  56755. private _onValidatedObserver;
  56756. /**
  56757. * Callback raised after a loader extension is created.
  56758. */
  56759. onValidated: (results: IGLTFValidationResults) => void;
  56760. private _loader;
  56761. /**
  56762. * Name of the loader ("gltf")
  56763. */
  56764. name: string;
  56765. /**
  56766. * Supported file extensions of the loader (.gltf, .glb)
  56767. */
  56768. extensions: ISceneLoaderPluginExtensions;
  56769. /**
  56770. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  56771. */
  56772. dispose(): void;
  56773. /** @hidden */ clear(): void;
  56774. /**
  56775. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  56776. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  56777. * @param scene the scene the meshes should be added to
  56778. * @param data the glTF data to load
  56779. * @param rootUrl root url to load from
  56780. * @param onProgress event that fires when loading progress has occured
  56781. * @param fileName Defines the name of the file to load
  56782. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  56783. */
  56784. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  56785. meshes: AbstractMesh[];
  56786. particleSystems: IParticleSystem[];
  56787. skeletons: Skeleton[];
  56788. animationGroups: AnimationGroup[];
  56789. }>;
  56790. /**
  56791. * Imports all objects from the loaded glTF data and adds them to the scene
  56792. * @param scene the scene the objects should be added to
  56793. * @param data the glTF data to load
  56794. * @param rootUrl root url to load from
  56795. * @param onProgress event that fires when loading progress has occured
  56796. * @param fileName Defines the name of the file to load
  56797. * @returns a promise which completes when objects have been loaded to the scene
  56798. */
  56799. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  56800. /**
  56801. * Load into an asset container.
  56802. * @param scene The scene to load into
  56803. * @param data The data to import
  56804. * @param rootUrl The root url for scene and resources
  56805. * @param onProgress The callback when the load progresses
  56806. * @param fileName Defines the name of the file to load
  56807. * @returns The loaded asset container
  56808. */
  56809. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  56810. /**
  56811. * If the data string can be loaded directly.
  56812. * @param data string contianing the file data
  56813. * @returns if the data can be loaded directly
  56814. */
  56815. canDirectLoad(data: string): boolean;
  56816. /**
  56817. * Rewrites a url by combining a root url and response url.
  56818. */
  56819. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  56820. /**
  56821. * Instantiates a glTF file loader plugin.
  56822. * @returns the created plugin
  56823. */
  56824. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  56825. /**
  56826. * The loader state or null if the loader is not active.
  56827. */
  56828. readonly loaderState: Nullable<GLTFLoaderState>;
  56829. /**
  56830. * Returns a promise that resolves when the asset is completely loaded.
  56831. * @returns a promise that resolves when the asset is completely loaded.
  56832. */
  56833. whenCompleteAsync(): Promise<void>;
  56834. private _parseAsync;
  56835. private _validateAsync;
  56836. private _getLoader;
  56837. private _unpackBinary;
  56838. private _unpackBinaryV1;
  56839. private _unpackBinaryV2;
  56840. private static _parseVersion;
  56841. private static _compareVersion;
  56842. private static _decodeBufferToText;
  56843. private static readonly _logSpaces;
  56844. private _logIndentLevel;
  56845. private _loggingEnabled;
  56846. /** @hidden */ log: (message: string) => void;
  56847. /** @hidden */ logOpen(message: string): void;
  56848. /** @hidden */ logClose(): void;
  56849. private _logEnabled;
  56850. private _logDisabled;
  56851. private _capturePerformanceCounters;
  56852. /** @hidden */ startPerformanceCounter: (counterName: string) => void;
  56853. /** @hidden */ endPerformanceCounter: (counterName: string) => void;
  56854. private _startPerformanceCounterEnabled;
  56855. private _startPerformanceCounterDisabled;
  56856. private _endPerformanceCounterEnabled;
  56857. private _endPerformanceCounterDisabled;
  56858. }
  56859. }
  56860. declare module BABYLON.GLTF1 {
  56861. /**
  56862. * Enums
  56863. * @hidden
  56864. */
  56865. export enum EComponentType {
  56866. BYTE = 5120,
  56867. UNSIGNED_BYTE = 5121,
  56868. SHORT = 5122,
  56869. UNSIGNED_SHORT = 5123,
  56870. FLOAT = 5126
  56871. }
  56872. /** @hidden */
  56873. export enum EShaderType {
  56874. FRAGMENT = 35632,
  56875. VERTEX = 35633
  56876. }
  56877. /** @hidden */
  56878. export enum EParameterType {
  56879. BYTE = 5120,
  56880. UNSIGNED_BYTE = 5121,
  56881. SHORT = 5122,
  56882. UNSIGNED_SHORT = 5123,
  56883. INT = 5124,
  56884. UNSIGNED_INT = 5125,
  56885. FLOAT = 5126,
  56886. FLOAT_VEC2 = 35664,
  56887. FLOAT_VEC3 = 35665,
  56888. FLOAT_VEC4 = 35666,
  56889. INT_VEC2 = 35667,
  56890. INT_VEC3 = 35668,
  56891. INT_VEC4 = 35669,
  56892. BOOL = 35670,
  56893. BOOL_VEC2 = 35671,
  56894. BOOL_VEC3 = 35672,
  56895. BOOL_VEC4 = 35673,
  56896. FLOAT_MAT2 = 35674,
  56897. FLOAT_MAT3 = 35675,
  56898. FLOAT_MAT4 = 35676,
  56899. SAMPLER_2D = 35678
  56900. }
  56901. /** @hidden */
  56902. export enum ETextureWrapMode {
  56903. CLAMP_TO_EDGE = 33071,
  56904. MIRRORED_REPEAT = 33648,
  56905. REPEAT = 10497
  56906. }
  56907. /** @hidden */
  56908. export enum ETextureFilterType {
  56909. NEAREST = 9728,
  56910. LINEAR = 9728,
  56911. NEAREST_MIPMAP_NEAREST = 9984,
  56912. LINEAR_MIPMAP_NEAREST = 9985,
  56913. NEAREST_MIPMAP_LINEAR = 9986,
  56914. LINEAR_MIPMAP_LINEAR = 9987
  56915. }
  56916. /** @hidden */
  56917. export enum ETextureFormat {
  56918. ALPHA = 6406,
  56919. RGB = 6407,
  56920. RGBA = 6408,
  56921. LUMINANCE = 6409,
  56922. LUMINANCE_ALPHA = 6410
  56923. }
  56924. /** @hidden */
  56925. export enum ECullingType {
  56926. FRONT = 1028,
  56927. BACK = 1029,
  56928. FRONT_AND_BACK = 1032
  56929. }
  56930. /** @hidden */
  56931. export enum EBlendingFunction {
  56932. ZERO = 0,
  56933. ONE = 1,
  56934. SRC_COLOR = 768,
  56935. ONE_MINUS_SRC_COLOR = 769,
  56936. DST_COLOR = 774,
  56937. ONE_MINUS_DST_COLOR = 775,
  56938. SRC_ALPHA = 770,
  56939. ONE_MINUS_SRC_ALPHA = 771,
  56940. DST_ALPHA = 772,
  56941. ONE_MINUS_DST_ALPHA = 773,
  56942. CONSTANT_COLOR = 32769,
  56943. ONE_MINUS_CONSTANT_COLOR = 32770,
  56944. CONSTANT_ALPHA = 32771,
  56945. ONE_MINUS_CONSTANT_ALPHA = 32772,
  56946. SRC_ALPHA_SATURATE = 776
  56947. }
  56948. /** @hidden */
  56949. export interface IGLTFProperty {
  56950. extensions?: {
  56951. [key: string]: any;
  56952. };
  56953. extras?: Object;
  56954. }
  56955. /** @hidden */
  56956. export interface IGLTFChildRootProperty extends IGLTFProperty {
  56957. name?: string;
  56958. }
  56959. /** @hidden */
  56960. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  56961. bufferView: string;
  56962. byteOffset: number;
  56963. byteStride: number;
  56964. count: number;
  56965. type: string;
  56966. componentType: EComponentType;
  56967. max?: number[];
  56968. min?: number[];
  56969. name?: string;
  56970. }
  56971. /** @hidden */
  56972. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  56973. buffer: string;
  56974. byteOffset: number;
  56975. byteLength: number;
  56976. byteStride: number;
  56977. target?: number;
  56978. }
  56979. /** @hidden */
  56980. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  56981. uri: string;
  56982. byteLength?: number;
  56983. type?: string;
  56984. }
  56985. /** @hidden */
  56986. export interface IGLTFShader extends IGLTFChildRootProperty {
  56987. uri: string;
  56988. type: EShaderType;
  56989. }
  56990. /** @hidden */
  56991. export interface IGLTFProgram extends IGLTFChildRootProperty {
  56992. attributes: string[];
  56993. fragmentShader: string;
  56994. vertexShader: string;
  56995. }
  56996. /** @hidden */
  56997. export interface IGLTFTechniqueParameter {
  56998. type: number;
  56999. count?: number;
  57000. semantic?: string;
  57001. node?: string;
  57002. value?: number | boolean | string | Array<any>;
  57003. source?: string;
  57004. babylonValue?: any;
  57005. }
  57006. /** @hidden */
  57007. export interface IGLTFTechniqueCommonProfile {
  57008. lightingModel: string;
  57009. texcoordBindings: Object;
  57010. parameters?: Array<any>;
  57011. }
  57012. /** @hidden */
  57013. export interface IGLTFTechniqueStatesFunctions {
  57014. blendColor?: number[];
  57015. blendEquationSeparate?: number[];
  57016. blendFuncSeparate?: number[];
  57017. colorMask: boolean[];
  57018. cullFace: number[];
  57019. }
  57020. /** @hidden */
  57021. export interface IGLTFTechniqueStates {
  57022. enable: number[];
  57023. functions: IGLTFTechniqueStatesFunctions;
  57024. }
  57025. /** @hidden */
  57026. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  57027. parameters: {
  57028. [key: string]: IGLTFTechniqueParameter;
  57029. };
  57030. program: string;
  57031. attributes: {
  57032. [key: string]: string;
  57033. };
  57034. uniforms: {
  57035. [key: string]: string;
  57036. };
  57037. states: IGLTFTechniqueStates;
  57038. }
  57039. /** @hidden */
  57040. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  57041. technique?: string;
  57042. values: string[];
  57043. }
  57044. /** @hidden */
  57045. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  57046. attributes: {
  57047. [key: string]: string;
  57048. };
  57049. indices: string;
  57050. material: string;
  57051. mode?: number;
  57052. }
  57053. /** @hidden */
  57054. export interface IGLTFMesh extends IGLTFChildRootProperty {
  57055. primitives: IGLTFMeshPrimitive[];
  57056. }
  57057. /** @hidden */
  57058. export interface IGLTFImage extends IGLTFChildRootProperty {
  57059. uri: string;
  57060. }
  57061. /** @hidden */
  57062. export interface IGLTFSampler extends IGLTFChildRootProperty {
  57063. magFilter?: number;
  57064. minFilter?: number;
  57065. wrapS?: number;
  57066. wrapT?: number;
  57067. }
  57068. /** @hidden */
  57069. export interface IGLTFTexture extends IGLTFChildRootProperty {
  57070. sampler: string;
  57071. source: string;
  57072. format?: ETextureFormat;
  57073. internalFormat?: ETextureFormat;
  57074. target?: number;
  57075. type?: number;
  57076. babylonTexture?: Texture;
  57077. }
  57078. /** @hidden */
  57079. export interface IGLTFAmbienLight {
  57080. color?: number[];
  57081. }
  57082. /** @hidden */
  57083. export interface IGLTFDirectionalLight {
  57084. color?: number[];
  57085. }
  57086. /** @hidden */
  57087. export interface IGLTFPointLight {
  57088. color?: number[];
  57089. constantAttenuation?: number;
  57090. linearAttenuation?: number;
  57091. quadraticAttenuation?: number;
  57092. }
  57093. /** @hidden */
  57094. export interface IGLTFSpotLight {
  57095. color?: number[];
  57096. constantAttenuation?: number;
  57097. fallOfAngle?: number;
  57098. fallOffExponent?: number;
  57099. linearAttenuation?: number;
  57100. quadraticAttenuation?: number;
  57101. }
  57102. /** @hidden */
  57103. export interface IGLTFLight extends IGLTFChildRootProperty {
  57104. type: string;
  57105. }
  57106. /** @hidden */
  57107. export interface IGLTFCameraOrthographic {
  57108. xmag: number;
  57109. ymag: number;
  57110. zfar: number;
  57111. znear: number;
  57112. }
  57113. /** @hidden */
  57114. export interface IGLTFCameraPerspective {
  57115. aspectRatio: number;
  57116. yfov: number;
  57117. zfar: number;
  57118. znear: number;
  57119. }
  57120. /** @hidden */
  57121. export interface IGLTFCamera extends IGLTFChildRootProperty {
  57122. type: string;
  57123. }
  57124. /** @hidden */
  57125. export interface IGLTFAnimationChannelTarget {
  57126. id: string;
  57127. path: string;
  57128. }
  57129. /** @hidden */
  57130. export interface IGLTFAnimationChannel {
  57131. sampler: string;
  57132. target: IGLTFAnimationChannelTarget;
  57133. }
  57134. /** @hidden */
  57135. export interface IGLTFAnimationSampler {
  57136. input: string;
  57137. output: string;
  57138. interpolation?: string;
  57139. }
  57140. /** @hidden */
  57141. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  57142. channels?: IGLTFAnimationChannel[];
  57143. parameters?: {
  57144. [key: string]: string;
  57145. };
  57146. samplers?: {
  57147. [key: string]: IGLTFAnimationSampler;
  57148. };
  57149. }
  57150. /** @hidden */
  57151. export interface IGLTFNodeInstanceSkin {
  57152. skeletons: string[];
  57153. skin: string;
  57154. meshes: string[];
  57155. }
  57156. /** @hidden */
  57157. export interface IGLTFSkins extends IGLTFChildRootProperty {
  57158. bindShapeMatrix: number[];
  57159. inverseBindMatrices: string;
  57160. jointNames: string[];
  57161. babylonSkeleton?: Skeleton;
  57162. }
  57163. /** @hidden */
  57164. export interface IGLTFNode extends IGLTFChildRootProperty {
  57165. camera?: string;
  57166. children: string[];
  57167. skin?: string;
  57168. jointName?: string;
  57169. light?: string;
  57170. matrix: number[];
  57171. mesh?: string;
  57172. meshes?: string[];
  57173. rotation?: number[];
  57174. scale?: number[];
  57175. translation?: number[];
  57176. babylonNode?: Node;
  57177. }
  57178. /** @hidden */
  57179. export interface IGLTFScene extends IGLTFChildRootProperty {
  57180. nodes: string[];
  57181. }
  57182. /** @hidden */
  57183. export interface IGLTFRuntime {
  57184. extensions: {
  57185. [key: string]: any;
  57186. };
  57187. accessors: {
  57188. [key: string]: IGLTFAccessor;
  57189. };
  57190. buffers: {
  57191. [key: string]: IGLTFBuffer;
  57192. };
  57193. bufferViews: {
  57194. [key: string]: IGLTFBufferView;
  57195. };
  57196. meshes: {
  57197. [key: string]: IGLTFMesh;
  57198. };
  57199. lights: {
  57200. [key: string]: IGLTFLight;
  57201. };
  57202. cameras: {
  57203. [key: string]: IGLTFCamera;
  57204. };
  57205. nodes: {
  57206. [key: string]: IGLTFNode;
  57207. };
  57208. images: {
  57209. [key: string]: IGLTFImage;
  57210. };
  57211. textures: {
  57212. [key: string]: IGLTFTexture;
  57213. };
  57214. shaders: {
  57215. [key: string]: IGLTFShader;
  57216. };
  57217. programs: {
  57218. [key: string]: IGLTFProgram;
  57219. };
  57220. samplers: {
  57221. [key: string]: IGLTFSampler;
  57222. };
  57223. techniques: {
  57224. [key: string]: IGLTFTechnique;
  57225. };
  57226. materials: {
  57227. [key: string]: IGLTFMaterial;
  57228. };
  57229. animations: {
  57230. [key: string]: IGLTFAnimation;
  57231. };
  57232. skins: {
  57233. [key: string]: IGLTFSkins;
  57234. };
  57235. currentScene?: Object;
  57236. scenes: {
  57237. [key: string]: IGLTFScene;
  57238. };
  57239. extensionsUsed: string[];
  57240. extensionsRequired?: string[];
  57241. buffersCount: number;
  57242. shaderscount: number;
  57243. scene: Scene;
  57244. rootUrl: string;
  57245. loadedBufferCount: number;
  57246. loadedBufferViews: {
  57247. [name: string]: ArrayBufferView;
  57248. };
  57249. loadedShaderCount: number;
  57250. importOnlyMeshes: boolean;
  57251. importMeshesNames?: string[];
  57252. dummyNodes: Node[];
  57253. }
  57254. /** @hidden */
  57255. export interface INodeToRoot {
  57256. bone: Bone;
  57257. node: IGLTFNode;
  57258. id: string;
  57259. }
  57260. /** @hidden */
  57261. export interface IJointNode {
  57262. node: IGLTFNode;
  57263. id: string;
  57264. }
  57265. }
  57266. declare module BABYLON.GLTF1 {
  57267. /**
  57268. * Utils functions for GLTF
  57269. * @hidden
  57270. */
  57271. export class GLTFUtils {
  57272. /**
  57273. * Sets the given "parameter" matrix
  57274. * @param scene: the Scene object
  57275. * @param source: the source node where to pick the matrix
  57276. * @param parameter: the GLTF technique parameter
  57277. * @param uniformName: the name of the shader's uniform
  57278. * @param shaderMaterial: the shader material
  57279. */
  57280. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  57281. /**
  57282. * Sets the given "parameter" matrix
  57283. * @param shaderMaterial: the shader material
  57284. * @param uniform: the name of the shader's uniform
  57285. * @param value: the value of the uniform
  57286. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  57287. */
  57288. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  57289. /**
  57290. * Returns the wrap mode of the texture
  57291. * @param mode: the mode value
  57292. */
  57293. static GetWrapMode(mode: number): number;
  57294. /**
  57295. * Returns the byte stride giving an accessor
  57296. * @param accessor: the GLTF accessor objet
  57297. */
  57298. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  57299. /**
  57300. * Returns the texture filter mode giving a mode value
  57301. * @param mode: the filter mode value
  57302. */
  57303. static GetTextureFilterMode(mode: number): ETextureFilterType;
  57304. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  57305. /**
  57306. * Returns a buffer from its accessor
  57307. * @param gltfRuntime: the GLTF runtime
  57308. * @param accessor: the GLTF accessor
  57309. */
  57310. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  57311. /**
  57312. * Decodes a buffer view into a string
  57313. * @param view: the buffer view
  57314. */
  57315. static DecodeBufferToText(view: ArrayBufferView): string;
  57316. /**
  57317. * Returns the default material of gltf. Related to
  57318. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  57319. * @param scene: the Babylon.js scene
  57320. */
  57321. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  57322. private static _DefaultMaterial;
  57323. }
  57324. }
  57325. declare module BABYLON.GLTF1 {
  57326. /**
  57327. * Implementation of the base glTF spec
  57328. * @hidden
  57329. */
  57330. export class GLTFLoaderBase {
  57331. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  57332. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  57333. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  57334. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  57335. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  57336. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  57337. }
  57338. /**
  57339. * glTF V1 Loader
  57340. * @hidden
  57341. */
  57342. export class GLTFLoader implements IGLTFLoader {
  57343. static Extensions: {
  57344. [name: string]: GLTFLoaderExtension;
  57345. };
  57346. static RegisterExtension(extension: GLTFLoaderExtension): void;
  57347. state: Nullable<GLTFLoaderState>;
  57348. dispose(): void;
  57349. private _importMeshAsync;
  57350. /**
  57351. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  57352. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  57353. * @param scene the scene the meshes should be added to
  57354. * @param data gltf data containing information of the meshes in a loaded file
  57355. * @param rootUrl root url to load from
  57356. * @param onProgress event that fires when loading progress has occured
  57357. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  57358. */
  57359. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  57360. meshes: AbstractMesh[];
  57361. particleSystems: IParticleSystem[];
  57362. skeletons: Skeleton[];
  57363. animationGroups: AnimationGroup[];
  57364. }>;
  57365. private _loadAsync;
  57366. /**
  57367. * Imports all objects from a loaded gltf file and adds them to the scene
  57368. * @param scene the scene the objects should be added to
  57369. * @param data gltf data containing information of the meshes in a loaded file
  57370. * @param rootUrl root url to load from
  57371. * @param onProgress event that fires when loading progress has occured
  57372. * @returns a promise which completes when objects have been loaded to the scene
  57373. */
  57374. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  57375. private _loadShadersAsync;
  57376. private _loadBuffersAsync;
  57377. private _createNodes;
  57378. }
  57379. /** @hidden */
  57380. export abstract class GLTFLoaderExtension {
  57381. private _name;
  57382. constructor(name: string);
  57383. readonly name: string;
  57384. /**
  57385. * Defines an override for loading the runtime
  57386. * Return true to stop further extensions from loading the runtime
  57387. */
  57388. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  57389. /**
  57390. * Defines an onverride for creating gltf runtime
  57391. * Return true to stop further extensions from creating the runtime
  57392. */
  57393. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  57394. /**
  57395. * Defines an override for loading buffers
  57396. * Return true to stop further extensions from loading this buffer
  57397. */
  57398. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  57399. /**
  57400. * Defines an override for loading texture buffers
  57401. * Return true to stop further extensions from loading this texture data
  57402. */
  57403. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  57404. /**
  57405. * Defines an override for creating textures
  57406. * Return true to stop further extensions from loading this texture
  57407. */
  57408. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  57409. /**
  57410. * Defines an override for loading shader strings
  57411. * Return true to stop further extensions from loading this shader data
  57412. */
  57413. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  57414. /**
  57415. * Defines an override for loading materials
  57416. * Return true to stop further extensions from loading this material
  57417. */
  57418. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  57419. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  57420. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  57421. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  57422. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  57423. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  57424. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  57425. private static LoadTextureBufferAsync;
  57426. private static CreateTextureAsync;
  57427. private static ApplyExtensions;
  57428. }
  57429. }
  57430. declare module BABYLON.GLTF1 {
  57431. /** @hidden */
  57432. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  57433. private _bin;
  57434. constructor();
  57435. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  57436. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  57437. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  57438. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  57439. }
  57440. }
  57441. declare module BABYLON.GLTF1 {
  57442. /** @hidden */
  57443. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  57444. constructor();
  57445. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  57446. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  57447. private _loadTexture;
  57448. }
  57449. }
  57450. declare module BABYLON.GLTF2.Loader {
  57451. /**
  57452. * Loader interface with an index field.
  57453. */
  57454. export interface IArrayItem {
  57455. /**
  57456. * The index of this item in the array.
  57457. */
  57458. index: number;
  57459. }
  57460. /**
  57461. * Loader interface with additional members.
  57462. */
  57463. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  57464. /** @hidden */ data?: Promise<ArrayBufferView>;
  57465. /** @hidden */ babylonVertexBuffer?: Promise<VertexBuffer>;
  57466. }
  57467. /**
  57468. * Loader interface with additional members.
  57469. */
  57470. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  57471. }
  57472. /** @hidden */
  57473. export interface _IAnimationSamplerData {
  57474. input: Float32Array;
  57475. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  57476. output: Float32Array;
  57477. }
  57478. /**
  57479. * Loader interface with additional members.
  57480. */
  57481. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  57482. /** @hidden */ data?: Promise<_IAnimationSamplerData>;
  57483. }
  57484. /**
  57485. * Loader interface with additional members.
  57486. */
  57487. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  57488. channels: IAnimationChannel[];
  57489. samplers: IAnimationSampler[];
  57490. /** @hidden */ babylonAnimationGroup?: AnimationGroup;
  57491. }
  57492. /**
  57493. * Loader interface with additional members.
  57494. */
  57495. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  57496. /** @hidden */ data?: Promise<ArrayBufferView>;
  57497. }
  57498. /**
  57499. * Loader interface with additional members.
  57500. */
  57501. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  57502. /** @hidden */ data?: Promise<ArrayBufferView>;
  57503. /** @hidden */ babylonBuffer?: Promise<Buffer>;
  57504. }
  57505. /**
  57506. * Loader interface with additional members.
  57507. */
  57508. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  57509. }
  57510. /**
  57511. * Loader interface with additional members.
  57512. */
  57513. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  57514. /** @hidden */ data?: Promise<ArrayBufferView>;
  57515. }
  57516. /**
  57517. * Loader interface with additional members.
  57518. */
  57519. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  57520. }
  57521. /**
  57522. * Loader interface with additional members.
  57523. */
  57524. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  57525. }
  57526. /**
  57527. * Loader interface with additional members.
  57528. */
  57529. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  57530. baseColorTexture?: ITextureInfo;
  57531. metallicRoughnessTexture?: ITextureInfo;
  57532. }
  57533. /**
  57534. * Loader interface with additional members.
  57535. */
  57536. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  57537. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  57538. normalTexture?: IMaterialNormalTextureInfo;
  57539. occlusionTexture?: IMaterialOcclusionTextureInfo;
  57540. emissiveTexture?: ITextureInfo;
  57541. /** @hidden */ data?: {
  57542. [babylonDrawMode: number]: {
  57543. babylonMaterial: Material;
  57544. babylonMeshes: AbstractMesh[];
  57545. promise: Promise<void>;
  57546. };
  57547. };
  57548. }
  57549. /**
  57550. * Loader interface with additional members.
  57551. */
  57552. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  57553. primitives: IMeshPrimitive[];
  57554. }
  57555. /**
  57556. * Loader interface with additional members.
  57557. */
  57558. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  57559. /** @hidden */ instanceData?: {
  57560. babylonSourceMesh: Mesh;
  57561. promise: Promise<any>;
  57562. };
  57563. }
  57564. /**
  57565. * Loader interface with additional members.
  57566. */
  57567. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  57568. /**
  57569. * The parent glTF node.
  57570. */
  57571. parent?: INode;
  57572. /** @hidden */ babylonTransformNode?: TransformNode;
  57573. /** @hidden */ primitiveBabylonMeshes?: AbstractMesh[];
  57574. /** @hidden */ babylonBones?: Bone[];
  57575. /** @hidden */ numMorphTargets?: number;
  57576. }
  57577. /** @hidden */
  57578. export interface _ISamplerData {
  57579. noMipMaps: boolean;
  57580. samplingMode: number;
  57581. wrapU: number;
  57582. wrapV: number;
  57583. }
  57584. /**
  57585. * Loader interface with additional members.
  57586. */
  57587. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  57588. /** @hidden */ data?: _ISamplerData;
  57589. }
  57590. /**
  57591. * Loader interface with additional members.
  57592. */
  57593. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  57594. }
  57595. /**
  57596. * Loader interface with additional members.
  57597. */
  57598. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  57599. /** @hidden */ data?: {
  57600. babylonSkeleton: Skeleton;
  57601. promise: Promise<void>;
  57602. };
  57603. }
  57604. /**
  57605. * Loader interface with additional members.
  57606. */
  57607. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  57608. }
  57609. /**
  57610. * Loader interface with additional members.
  57611. */
  57612. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  57613. }
  57614. /**
  57615. * Loader interface with additional members.
  57616. */
  57617. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  57618. accessors?: IAccessor[];
  57619. animations?: IAnimation[];
  57620. buffers?: IBuffer[];
  57621. bufferViews?: IBufferView[];
  57622. cameras?: ICamera[];
  57623. images?: IImage[];
  57624. materials?: IMaterial[];
  57625. meshes?: IMesh[];
  57626. nodes?: INode[];
  57627. samplers?: ISampler[];
  57628. scenes?: IScene[];
  57629. skins?: ISkin[];
  57630. textures?: ITexture[];
  57631. }
  57632. }
  57633. declare module BABYLON.GLTF2 {
  57634. /**
  57635. * Interface for a glTF loader extension.
  57636. */
  57637. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  57638. /**
  57639. * Called after the loader state changes to LOADING.
  57640. */
  57641. onLoading?(): void;
  57642. /**
  57643. * Called after the loader state changes to READY.
  57644. */
  57645. onReady?(): void;
  57646. /**
  57647. * Define this method to modify the default behavior when loading scenes.
  57648. * @param context The context when loading the asset
  57649. * @param scene The glTF scene property
  57650. * @returns A promise that resolves when the load is complete or null if not handled
  57651. */
  57652. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  57653. /**
  57654. * Define this method to modify the default behavior when loading nodes.
  57655. * @param context The context when loading the asset
  57656. * @param node The glTF node property
  57657. * @param assign A function called synchronously after parsing the glTF properties
  57658. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  57659. */
  57660. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  57661. /**
  57662. * Define this method to modify the default behavior when loading cameras.
  57663. * @param context The context when loading the asset
  57664. * @param camera The glTF camera property
  57665. * @param assign A function called synchronously after parsing the glTF properties
  57666. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  57667. */
  57668. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  57669. /**
  57670. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  57671. * @param context The context when loading the asset
  57672. * @param primitive The glTF mesh primitive property
  57673. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  57674. */ loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  57675. /**
  57676. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  57677. * @param context The context when loading the asset
  57678. * @param material The glTF material property
  57679. * @param assign A function called synchronously after parsing the glTF properties
  57680. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  57681. */ loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  57682. /**
  57683. * Define this method to modify the default behavior when creating materials.
  57684. * @param context The context when loading the asset
  57685. * @param material The glTF material property
  57686. * @param babylonDrawMode The draw mode for the Babylon material
  57687. * @returns The Babylon material or null if not handled
  57688. */
  57689. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  57690. /**
  57691. * Define this method to modify the default behavior when loading material properties.
  57692. * @param context The context when loading the asset
  57693. * @param material The glTF material property
  57694. * @param babylonMaterial The Babylon material
  57695. * @returns A promise that resolves when the load is complete or null if not handled
  57696. */
  57697. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  57698. /**
  57699. * Define this method to modify the default behavior when loading texture infos.
  57700. * @param context The context when loading the asset
  57701. * @param textureInfo The glTF texture info property
  57702. * @param assign A function called synchronously after parsing the glTF properties
  57703. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  57704. */
  57705. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  57706. /**
  57707. * Define this method to modify the default behavior when loading animations.
  57708. * @param context The context when loading the asset
  57709. * @param animation The glTF animation property
  57710. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  57711. */
  57712. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  57713. /**
  57714. * Define this method to modify the default behavior when loading uris.
  57715. * @param context The context when loading the asset
  57716. * @param uri The uri to load
  57717. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  57718. */ loadUriAsync?(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  57719. }
  57720. }
  57721. declare module BABYLON.GLTF2 {
  57722. /**
  57723. * Helper class for working with arrays when loading the glTF asset
  57724. */
  57725. export class ArrayItem {
  57726. /**
  57727. * Gets an item from the given array.
  57728. * @param context The context when loading the asset
  57729. * @param array The array to get the item from
  57730. * @param index The index to the array
  57731. * @returns The array item
  57732. */
  57733. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  57734. /**
  57735. * Assign an `index` field to each item of the given array.
  57736. * @param array The array of items
  57737. */
  57738. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  57739. }
  57740. /**
  57741. * The glTF 2.0 loader
  57742. */
  57743. export class GLTFLoader implements IGLTFLoader {
  57744. /** The glTF object parsed from the JSON. */
  57745. gltf: IGLTF;
  57746. /** The Babylon scene when loading the asset. */
  57747. babylonScene: Scene;
  57748. /** @hidden */ completePromises: Promise<any>[];
  57749. private _disposed;
  57750. private _parent;
  57751. private _state;
  57752. private _extensions;
  57753. private _rootUrl;
  57754. private _fileName;
  57755. private _uniqueRootUrl;
  57756. private _rootBabylonMesh;
  57757. private _defaultBabylonMaterialData;
  57758. private _progressCallback?;
  57759. private _requests;
  57760. private static readonly _DefaultSampler;
  57761. private static _ExtensionNames;
  57762. private static _ExtensionFactories;
  57763. /**
  57764. * Registers a loader extension.
  57765. * @param name The name of the loader extension.
  57766. * @param factory The factory function that creates the loader extension.
  57767. */
  57768. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  57769. /**
  57770. * Unregisters a loader extension.
  57771. * @param name The name of the loader extenion.
  57772. * @returns A boolean indicating whether the extension has been unregistered
  57773. */
  57774. static UnregisterExtension(name: string): boolean;
  57775. /**
  57776. * Gets the loader state.
  57777. */
  57778. readonly state: Nullable<GLTFLoaderState>;
  57779. /** @hidden */
  57780. constructor(parent: GLTFFileLoader);
  57781. /** @hidden */
  57782. dispose(): void;
  57783. /** @hidden */
  57784. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  57785. meshes: AbstractMesh[];
  57786. particleSystems: IParticleSystem[];
  57787. skeletons: Skeleton[];
  57788. animationGroups: AnimationGroup[];
  57789. }>;
  57790. /** @hidden */
  57791. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  57792. private _loadAsync;
  57793. private _loadData;
  57794. private _setupData;
  57795. private _loadExtensions;
  57796. private _checkExtensions;
  57797. private _setState;
  57798. private _createRootNode;
  57799. /**
  57800. * Loads a glTF scene.
  57801. * @param context The context when loading the asset
  57802. * @param scene The glTF scene property
  57803. * @returns A promise that resolves when the load is complete
  57804. */
  57805. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  57806. private _forEachPrimitive;
  57807. private _getMeshes;
  57808. private _getSkeletons;
  57809. private _getAnimationGroups;
  57810. private _startAnimations;
  57811. /**
  57812. * Loads a glTF node.
  57813. * @param context The context when loading the asset
  57814. * @param node The glTF node property
  57815. * @param assign A function called synchronously after parsing the glTF properties
  57816. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  57817. */
  57818. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  57819. private _loadMeshAsync;
  57820. private _loadMeshPrimitiveAsync;
  57821. private _loadVertexDataAsync;
  57822. private _createMorphTargets;
  57823. private _loadMorphTargetsAsync;
  57824. private _loadMorphTargetVertexDataAsync;
  57825. private static _LoadTransform;
  57826. private _loadSkinAsync;
  57827. private _loadBones;
  57828. private _loadBone;
  57829. private _loadSkinInverseBindMatricesDataAsync;
  57830. private _updateBoneMatrices;
  57831. private _getNodeMatrix;
  57832. /**
  57833. * Loads a glTF camera.
  57834. * @param context The context when loading the asset
  57835. * @param camera The glTF camera property
  57836. * @param assign A function called synchronously after parsing the glTF properties
  57837. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  57838. */
  57839. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  57840. private _loadAnimationsAsync;
  57841. /**
  57842. * Loads a glTF animation.
  57843. * @param context The context when loading the asset
  57844. * @param animation The glTF animation property
  57845. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  57846. */
  57847. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  57848. private _loadAnimationChannelAsync;
  57849. private _loadAnimationSamplerAsync;
  57850. private _loadBufferAsync;
  57851. /**
  57852. * Loads a glTF buffer view.
  57853. * @param context The context when loading the asset
  57854. * @param bufferView The glTF buffer view property
  57855. * @returns A promise that resolves with the loaded data when the load is complete
  57856. */
  57857. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  57858. private _loadIndicesAccessorAsync;
  57859. private _loadFloatAccessorAsync;
  57860. private _loadVertexBufferViewAsync;
  57861. private _loadVertexAccessorAsync;
  57862. private _loadMaterialMetallicRoughnessPropertiesAsync;
  57863. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  57864. private _createDefaultMaterial;
  57865. /**
  57866. * Creates a Babylon material from a glTF material.
  57867. * @param context The context when loading the asset
  57868. * @param material The glTF material property
  57869. * @param babylonDrawMode The draw mode for the Babylon material
  57870. * @returns The Babylon material
  57871. */
  57872. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  57873. /**
  57874. * Loads properties from a glTF material into a Babylon material.
  57875. * @param context The context when loading the asset
  57876. * @param material The glTF material property
  57877. * @param babylonMaterial The Babylon material
  57878. * @returns A promise that resolves when the load is complete
  57879. */
  57880. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  57881. /**
  57882. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  57883. * @param context The context when loading the asset
  57884. * @param material The glTF material property
  57885. * @param babylonMaterial The Babylon material
  57886. * @returns A promise that resolves when the load is complete
  57887. */
  57888. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  57889. /**
  57890. * Loads the alpha properties from a glTF material into a Babylon material.
  57891. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  57892. * @param context The context when loading the asset
  57893. * @param material The glTF material property
  57894. * @param babylonMaterial The Babylon material
  57895. */
  57896. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  57897. /**
  57898. * Loads a glTF texture info.
  57899. * @param context The context when loading the asset
  57900. * @param textureInfo The glTF texture info property
  57901. * @param assign A function called synchronously after parsing the glTF properties
  57902. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  57903. */
  57904. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  57905. private _loadTextureAsync;
  57906. private _loadSampler;
  57907. /**
  57908. * Loads a glTF image.
  57909. * @param context The context when loading the asset
  57910. * @param image The glTF image property
  57911. * @returns A promise that resolves with the loaded data when the load is complete
  57912. */
  57913. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  57914. /**
  57915. * Loads a glTF uri.
  57916. * @param context The context when loading the asset
  57917. * @param uri The base64 or relative uri
  57918. * @returns A promise that resolves with the loaded data when the load is complete
  57919. */
  57920. loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
  57921. private _onProgress;
  57922. /**
  57923. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  57924. * @param babylonObject the Babylon object with metadata
  57925. * @param pointer the JSON pointer
  57926. */
  57927. static AddPointerMetadata(babylonObject: {
  57928. metadata: any;
  57929. }, pointer: string): void;
  57930. private static _GetTextureWrapMode;
  57931. private static _GetTextureSamplingMode;
  57932. private static _GetTypedArray;
  57933. private static _GetNumComponents;
  57934. private static _ValidateUri;
  57935. private static _GetDrawMode;
  57936. private _compileMaterialsAsync;
  57937. private _compileShadowGeneratorsAsync;
  57938. private _forEachExtensions;
  57939. private _applyExtensions;
  57940. private _extensionsOnLoading;
  57941. private _extensionsOnReady;
  57942. private _extensionsLoadSceneAsync;
  57943. private _extensionsLoadNodeAsync;
  57944. private _extensionsLoadCameraAsync;
  57945. private _extensionsLoadVertexDataAsync;
  57946. private _extensionsLoadMaterialAsync;
  57947. private _extensionsCreateMaterial;
  57948. private _extensionsLoadMaterialPropertiesAsync;
  57949. private _extensionsLoadTextureInfoAsync;
  57950. private _extensionsLoadAnimationAsync;
  57951. private _extensionsLoadUriAsync;
  57952. /**
  57953. * Helper method called by a loader extension to load an glTF extension.
  57954. * @param context The context when loading the asset
  57955. * @param property The glTF property to load the extension from
  57956. * @param extensionName The name of the extension to load
  57957. * @param actionAsync The action to run
  57958. * @returns The promise returned by actionAsync or null if the extension does not exist
  57959. */
  57960. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  57961. /**
  57962. * Helper method called by a loader extension to load a glTF extra.
  57963. * @param context The context when loading the asset
  57964. * @param property The glTF property to load the extra from
  57965. * @param extensionName The name of the extension to load
  57966. * @param actionAsync The action to run
  57967. * @returns The promise returned by actionAsync or null if the extra does not exist
  57968. */
  57969. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  57970. /**
  57971. * Increments the indentation level and logs a message.
  57972. * @param message The message to log
  57973. */
  57974. logOpen(message: string): void;
  57975. /**
  57976. * Decrements the indentation level.
  57977. */
  57978. logClose(): void;
  57979. /**
  57980. * Logs a message
  57981. * @param message The message to log
  57982. */
  57983. log(message: string): void;
  57984. /**
  57985. * Starts a performance counter.
  57986. * @param counterName The name of the performance counter
  57987. */
  57988. startPerformanceCounter(counterName: string): void;
  57989. /**
  57990. * Ends a performance counter.
  57991. * @param counterName The name of the performance counter
  57992. */
  57993. endPerformanceCounter(counterName: string): void;
  57994. }
  57995. }
  57996. declare module BABYLON.GLTF2.Loader.Extensions {
  57997. /**
  57998. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  57999. */
  58000. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  58001. /** The name of this extension. */
  58002. readonly name: string;
  58003. /** Defines whether this extension is enabled. */
  58004. enabled: boolean;
  58005. private _loader;
  58006. private _lights?;
  58007. /** @hidden */
  58008. constructor(loader: GLTFLoader);
  58009. /** @hidden */
  58010. dispose(): void;
  58011. /** @hidden */
  58012. onLoading(): void;
  58013. /** @hidden */
  58014. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  58015. private _loadLightAsync;
  58016. }
  58017. }
  58018. declare module BABYLON.GLTF2.Loader.Extensions {
  58019. /**
  58020. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  58021. */
  58022. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  58023. /** The name of this extension. */
  58024. readonly name: string;
  58025. /** Defines whether this extension is enabled. */
  58026. enabled: boolean;
  58027. private _loader;
  58028. private _dracoCompression?;
  58029. /** @hidden */
  58030. constructor(loader: GLTFLoader);
  58031. /** @hidden */
  58032. dispose(): void;
  58033. /** @hidden */ loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  58034. }
  58035. }
  58036. declare module BABYLON.GLTF2.Loader.Extensions {
  58037. /**
  58038. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  58039. */
  58040. export class KHR_lights implements IGLTFLoaderExtension {
  58041. /** The name of this extension. */
  58042. readonly name: string;
  58043. /** Defines whether this extension is enabled. */
  58044. enabled: boolean;
  58045. private _loader;
  58046. private _lights?;
  58047. /** @hidden */
  58048. constructor(loader: GLTFLoader);
  58049. /** @hidden */
  58050. dispose(): void;
  58051. /** @hidden */
  58052. onLoading(): void;
  58053. /** @hidden */
  58054. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  58055. }
  58056. }
  58057. declare module BABYLON.GLTF2.Loader.Extensions {
  58058. /**
  58059. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  58060. */
  58061. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  58062. /** The name of this extension. */
  58063. readonly name: string;
  58064. /** Defines whether this extension is enabled. */
  58065. enabled: boolean;
  58066. private _loader;
  58067. /** @hidden */
  58068. constructor(loader: GLTFLoader);
  58069. /** @hidden */
  58070. dispose(): void;
  58071. /** @hidden */
  58072. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  58073. private _loadSpecularGlossinessPropertiesAsync;
  58074. }
  58075. }
  58076. declare module BABYLON.GLTF2.Loader.Extensions {
  58077. /**
  58078. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  58079. */
  58080. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  58081. /** The name of this extension. */
  58082. readonly name: string;
  58083. /** Defines whether this extension is enabled. */
  58084. enabled: boolean;
  58085. private _loader;
  58086. /** @hidden */
  58087. constructor(loader: GLTFLoader);
  58088. /** @hidden */
  58089. dispose(): void;
  58090. /** @hidden */
  58091. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  58092. private _loadUnlitPropertiesAsync;
  58093. }
  58094. }
  58095. declare module BABYLON.GLTF2.Loader.Extensions {
  58096. /**
  58097. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  58098. */
  58099. export class KHR_texture_transform implements IGLTFLoaderExtension {
  58100. /** The name of this extension. */
  58101. readonly name: string;
  58102. /** Defines whether this extension is enabled. */
  58103. enabled: boolean;
  58104. private _loader;
  58105. /** @hidden */
  58106. constructor(loader: GLTFLoader);
  58107. /** @hidden */
  58108. dispose(): void;
  58109. /** @hidden */
  58110. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  58111. }
  58112. }
  58113. declare module BABYLON.GLTF2.Loader.Extensions {
  58114. /**
  58115. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  58116. */
  58117. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  58118. /** The name of this extension. */
  58119. readonly name: string;
  58120. /** Defines whether this extension is enabled. */
  58121. enabled: boolean;
  58122. private _loader;
  58123. private _clips;
  58124. private _emitters;
  58125. /** @hidden */
  58126. constructor(loader: GLTFLoader);
  58127. /** @hidden */
  58128. dispose(): void;
  58129. /** @hidden */
  58130. onLoading(): void;
  58131. /** @hidden */
  58132. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  58133. /** @hidden */
  58134. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  58135. /** @hidden */
  58136. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  58137. private _loadClipAsync;
  58138. private _loadEmitterAsync;
  58139. private _getEventAction;
  58140. private _loadAnimationEventAsync;
  58141. }
  58142. }
  58143. declare module BABYLON.GLTF2.Loader.Extensions {
  58144. /**
  58145. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  58146. */
  58147. export class MSFT_lod implements IGLTFLoaderExtension {
  58148. /** The name of this extension. */
  58149. readonly name: string;
  58150. /** Defines whether this extension is enabled. */
  58151. enabled: boolean;
  58152. /**
  58153. * Maximum number of LODs to load, starting from the lowest LOD.
  58154. */
  58155. maxLODsToLoad: number;
  58156. /**
  58157. * Observable raised when all node LODs of one level are loaded.
  58158. * The event data is the index of the loaded LOD starting from zero.
  58159. * Dispose the loader to cancel the loading of the next level of LODs.
  58160. */
  58161. onNodeLODsLoadedObservable: Observable<number>;
  58162. /**
  58163. * Observable raised when all material LODs of one level are loaded.
  58164. * The event data is the index of the loaded LOD starting from zero.
  58165. * Dispose the loader to cancel the loading of the next level of LODs.
  58166. */
  58167. onMaterialLODsLoadedObservable: Observable<number>;
  58168. private _loader;
  58169. private _nodeIndexLOD;
  58170. private _nodeSignalLODs;
  58171. private _nodePromiseLODs;
  58172. private _materialIndexLOD;
  58173. private _materialSignalLODs;
  58174. private _materialPromiseLODs;
  58175. /** @hidden */
  58176. constructor(loader: GLTFLoader);
  58177. /** @hidden */
  58178. dispose(): void;
  58179. /** @hidden */
  58180. onReady(): void;
  58181. /** @hidden */
  58182. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  58183. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  58184. /** @hidden */ loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  58185. /**
  58186. * Gets an array of LOD properties from lowest to highest.
  58187. */
  58188. private _getLODs;
  58189. private _disposeUnusedMaterials;
  58190. }
  58191. }
  58192. declare module BABYLON.GLTF2.Loader.Extensions {
  58193. /** @hidden */
  58194. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  58195. readonly name: string;
  58196. enabled: boolean;
  58197. private _loader;
  58198. constructor(loader: GLTFLoader);
  58199. dispose(): void;
  58200. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  58201. }
  58202. }
  58203. declare module BABYLON.GLTF2.Loader.Extensions {
  58204. /** @hidden */
  58205. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  58206. readonly name: string;
  58207. enabled: boolean;
  58208. private _loader;
  58209. constructor(loader: GLTFLoader);
  58210. dispose(): void;
  58211. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  58212. }
  58213. }
  58214. declare module BABYLON {
  58215. /**
  58216. * Class reading and parsing the MTL file bundled with the obj file.
  58217. */
  58218. export class MTLFileLoader {
  58219. /**
  58220. * All material loaded from the mtl will be set here
  58221. */
  58222. materials: StandardMaterial[];
  58223. /**
  58224. * This function will read the mtl file and create each material described inside
  58225. * This function could be improve by adding :
  58226. * -some component missing (Ni, Tf...)
  58227. * -including the specific options available
  58228. *
  58229. * @param scene defines the scene the material will be created in
  58230. * @param data defines the mtl data to parse
  58231. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  58232. */
  58233. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  58234. /**
  58235. * Gets the texture for the material.
  58236. *
  58237. * If the material is imported from input file,
  58238. * We sanitize the url to ensure it takes the textre from aside the material.
  58239. *
  58240. * @param rootUrl The root url to load from
  58241. * @param value The value stored in the mtl
  58242. * @return The Texture
  58243. */
  58244. private static _getTexture;
  58245. }
  58246. /**
  58247. * OBJ file type loader.
  58248. * This is a babylon scene loader plugin.
  58249. */
  58250. export class OBJFileLoader implements ISceneLoaderPluginAsync {
  58251. /**
  58252. * Defines if UVs are optimized by default during load.
  58253. */
  58254. static OPTIMIZE_WITH_UV: boolean;
  58255. /**
  58256. * Invert model on y-axis (does a model scaling inversion)
  58257. */
  58258. static INVERT_Y: boolean;
  58259. /**
  58260. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  58261. */
  58262. static IMPORT_VERTEX_COLORS: boolean;
  58263. /**
  58264. * Compute the normals for the model, even if normals are present in the file
  58265. */
  58266. static COMPUTE_NORMALS: boolean;
  58267. /**
  58268. * Defines the name of the plugin.
  58269. */
  58270. name: string;
  58271. /**
  58272. * Defines the extension the plugin is able to load.
  58273. */
  58274. extensions: string;
  58275. /** @hidden */
  58276. obj: RegExp;
  58277. /** @hidden */
  58278. group: RegExp;
  58279. /** @hidden */
  58280. mtllib: RegExp;
  58281. /** @hidden */
  58282. usemtl: RegExp;
  58283. /** @hidden */
  58284. smooth: RegExp;
  58285. /** @hidden */
  58286. vertexPattern: RegExp;
  58287. /** @hidden */
  58288. normalPattern: RegExp;
  58289. /** @hidden */
  58290. uvPattern: RegExp;
  58291. /** @hidden */
  58292. facePattern1: RegExp;
  58293. /** @hidden */
  58294. facePattern2: RegExp;
  58295. /** @hidden */
  58296. facePattern3: RegExp;
  58297. /** @hidden */
  58298. facePattern4: RegExp;
  58299. /** @hidden */
  58300. facePattern5: RegExp;
  58301. /**
  58302. * Calls synchronously the MTL file attached to this obj.
  58303. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  58304. * Without this function materials are not displayed in the first frame (but displayed after).
  58305. * In consequence it is impossible to get material information in your HTML file
  58306. *
  58307. * @param url The URL of the MTL file
  58308. * @param rootUrl
  58309. * @param onSuccess Callback function to be called when the MTL file is loaded
  58310. * @private
  58311. */
  58312. private _loadMTL;
  58313. /**
  58314. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  58315. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  58316. * @param scene the scene the meshes should be added to
  58317. * @param data the OBJ data to load
  58318. * @param rootUrl root url to load from
  58319. * @param onProgress event that fires when loading progress has occured
  58320. * @param fileName Defines the name of the file to load
  58321. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  58322. */
  58323. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  58324. meshes: AbstractMesh[];
  58325. particleSystems: IParticleSystem[];
  58326. skeletons: Skeleton[];
  58327. animationGroups: AnimationGroup[];
  58328. }>;
  58329. /**
  58330. * Imports all objects from the loaded OBJ data and adds them to the scene
  58331. * @param scene the scene the objects should be added to
  58332. * @param data the OBJ data to load
  58333. * @param rootUrl root url to load from
  58334. * @param onProgress event that fires when loading progress has occured
  58335. * @param fileName Defines the name of the file to load
  58336. * @returns a promise which completes when objects have been loaded to the scene
  58337. */
  58338. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  58339. /**
  58340. * Load into an asset container.
  58341. * @param scene The scene to load into
  58342. * @param data The data to import
  58343. * @param rootUrl The root url for scene and resources
  58344. * @param onProgress The callback when the load progresses
  58345. * @param fileName Defines the name of the file to load
  58346. * @returns The loaded asset container
  58347. */
  58348. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  58349. /**
  58350. * Read the OBJ file and create an Array of meshes.
  58351. * Each mesh contains all information given by the OBJ and the MTL file.
  58352. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  58353. *
  58354. * @param meshesNames
  58355. * @param scene Scene The scene where are displayed the data
  58356. * @param data String The content of the obj file
  58357. * @param rootUrl String The path to the folder
  58358. * @returns Array<AbstractMesh>
  58359. * @private
  58360. */
  58361. private _parseSolid;
  58362. }
  58363. }
  58364. declare module BABYLON {
  58365. /**
  58366. * STL file type loader.
  58367. * This is a babylon scene loader plugin.
  58368. */
  58369. export class STLFileLoader implements ISceneLoaderPlugin {
  58370. /** @hidden */
  58371. solidPattern: RegExp;
  58372. /** @hidden */
  58373. facetsPattern: RegExp;
  58374. /** @hidden */
  58375. normalPattern: RegExp;
  58376. /** @hidden */
  58377. vertexPattern: RegExp;
  58378. /**
  58379. * Defines the name of the plugin.
  58380. */
  58381. name: string;
  58382. /**
  58383. * Defines the extensions the stl loader is able to load.
  58384. * force data to come in as an ArrayBuffer
  58385. * we'll convert to string if it looks like it's an ASCII .stl
  58386. */
  58387. extensions: ISceneLoaderPluginExtensions;
  58388. /**
  58389. * Import meshes into a scene.
  58390. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  58391. * @param scene The scene to import into
  58392. * @param data The data to import
  58393. * @param rootUrl The root url for scene and resources
  58394. * @param meshes The meshes array to import into
  58395. * @param particleSystems The particle systems array to import into
  58396. * @param skeletons The skeletons array to import into
  58397. * @param onError The callback when import fails
  58398. * @returns True if successful or false otherwise
  58399. */
  58400. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  58401. /**
  58402. * Load into a scene.
  58403. * @param scene The scene to load into
  58404. * @param data The data to import
  58405. * @param rootUrl The root url for scene and resources
  58406. * @param onError The callback when import fails
  58407. * @returns true if successful or false otherwise
  58408. */
  58409. load(scene: Scene, data: any, rootUrl: string): boolean;
  58410. /**
  58411. * Load into an asset container.
  58412. * @param scene The scene to load into
  58413. * @param data The data to import
  58414. * @param rootUrl The root url for scene and resources
  58415. * @param onError The callback when import fails
  58416. * @returns The loaded asset container
  58417. */
  58418. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  58419. private _isBinary;
  58420. private _parseBinary;
  58421. private _parseASCII;
  58422. }
  58423. }
  58424. declare module BABYLON {
  58425. /**
  58426. * Class for generating OBJ data from a Babylon scene.
  58427. */
  58428. export class OBJExport {
  58429. /**
  58430. * Exports the geometry of a Mesh array in .OBJ file format (text)
  58431. * @param mesh defines the list of meshes to serialize
  58432. * @param materials defines if materials should be exported
  58433. * @param matlibname defines the name of the associated mtl file
  58434. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  58435. * @returns the OBJ content
  58436. */
  58437. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  58438. /**
  58439. * Exports the material(s) of a mesh in .MTL file format (text)
  58440. * @param mesh defines the mesh to extract the material from
  58441. * @returns the mtl content
  58442. */
  58443. static MTL(mesh: Mesh): string;
  58444. }
  58445. }
  58446. declare module BABYLON {
  58447. /** @hidden */
  58448. export var __IGLTFExporterExtension: number;
  58449. /**
  58450. * Interface for extending the exporter
  58451. * @hidden
  58452. */
  58453. export interface IGLTFExporterExtension {
  58454. /**
  58455. * The name of this extension
  58456. */
  58457. readonly name: string;
  58458. /**
  58459. * Defines whether this extension is enabled
  58460. */
  58461. enabled: boolean;
  58462. /**
  58463. * Defines whether this extension is required
  58464. */
  58465. required: boolean;
  58466. }
  58467. }
  58468. declare module BABYLON.GLTF2.Exporter {
  58469. /** @hidden */
  58470. export var __IGLTFExporterExtensionV2: number;
  58471. /**
  58472. * Interface for a glTF exporter extension
  58473. * @hidden
  58474. */
  58475. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  58476. /**
  58477. * Define this method to modify the default behavior before exporting a texture
  58478. * @param context The context when loading the asset
  58479. * @param babylonTexture The glTF texture info property
  58480. * @param mimeType The mime-type of the generated image
  58481. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  58482. */
  58483. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  58484. /**
  58485. * Define this method to modify the default behavior when exporting texture info
  58486. * @param context The context when loading the asset
  58487. * @param meshPrimitive glTF mesh primitive
  58488. * @param babylonSubMesh Babylon submesh
  58489. * @param binaryWriter glTF serializer binary writer instance
  58490. */
  58491. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  58492. }
  58493. }
  58494. declare module BABYLON.GLTF2.Exporter {
  58495. /**
  58496. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  58497. * @hidden
  58498. */
  58499. export class _GLTFMaterialExporter {
  58500. /**
  58501. * Represents the dielectric specular values for R, G and B
  58502. */
  58503. private static readonly _DielectricSpecular;
  58504. /**
  58505. * Allows the maximum specular power to be defined for material calculations
  58506. */
  58507. private static readonly _MaxSpecularPower;
  58508. /**
  58509. * Mapping to store textures
  58510. */
  58511. private _textureMap;
  58512. /**
  58513. * Numeric tolerance value
  58514. */
  58515. private static readonly _Epsilon;
  58516. /**
  58517. * Reference to the glTF Exporter
  58518. */
  58519. private _exporter;
  58520. constructor(exporter: _Exporter);
  58521. /**
  58522. * Specifies if two colors are approximately equal in value
  58523. * @param color1 first color to compare to
  58524. * @param color2 second color to compare to
  58525. * @param epsilon threshold value
  58526. */
  58527. private static FuzzyEquals;
  58528. /**
  58529. * Gets the materials from a Babylon scene and converts them to glTF materials
  58530. * @param scene babylonjs scene
  58531. * @param mimeType texture mime type
  58532. * @param images array of images
  58533. * @param textures array of textures
  58534. * @param materials array of materials
  58535. * @param imageData mapping of texture names to base64 textures
  58536. * @param hasTextureCoords specifies if texture coordinates are present on the material
  58537. */ convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  58538. /**
  58539. * Makes a copy of the glTF material without the texture parameters
  58540. * @param originalMaterial original glTF material
  58541. * @returns glTF material without texture parameters
  58542. */ stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  58543. /**
  58544. * Specifies if the material has any texture parameters present
  58545. * @param material glTF Material
  58546. * @returns boolean specifying if texture parameters are present
  58547. */ hasTexturesPresent(material: IMaterial): boolean;
  58548. /**
  58549. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  58550. * @param babylonStandardMaterial
  58551. * @returns glTF Metallic Roughness Material representation
  58552. */ convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  58553. /**
  58554. * Computes the metallic factor
  58555. * @param diffuse diffused value
  58556. * @param specular specular value
  58557. * @param oneMinusSpecularStrength one minus the specular strength
  58558. * @returns metallic value
  58559. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  58560. /**
  58561. * Gets the glTF alpha mode from the Babylon Material
  58562. * @param babylonMaterial Babylon Material
  58563. * @returns The Babylon alpha mode value
  58564. */ getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  58565. /**
  58566. * Converts a Babylon Standard Material to a glTF Material
  58567. * @param babylonStandardMaterial BJS Standard Material
  58568. * @param mimeType mime type to use for the textures
  58569. * @param images array of glTF image interfaces
  58570. * @param textures array of glTF texture interfaces
  58571. * @param materials array of glTF material interfaces
  58572. * @param imageData map of image file name to data
  58573. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58574. */ convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  58575. /**
  58576. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  58577. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  58578. * @param mimeType mime type to use for the textures
  58579. * @param images array of glTF image interfaces
  58580. * @param textures array of glTF texture interfaces
  58581. * @param materials array of glTF material interfaces
  58582. * @param imageData map of image file name to data
  58583. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58584. */ convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  58585. /**
  58586. * Converts an image typed array buffer to a base64 image
  58587. * @param buffer typed array buffer
  58588. * @param width width of the image
  58589. * @param height height of the image
  58590. * @param mimeType mimetype of the image
  58591. * @returns base64 image string
  58592. */
  58593. private _createBase64FromCanvasAsync;
  58594. /**
  58595. * Generates a white texture based on the specified width and height
  58596. * @param width width of the texture in pixels
  58597. * @param height height of the texture in pixels
  58598. * @param scene babylonjs scene
  58599. * @returns white texture
  58600. */
  58601. private _createWhiteTexture;
  58602. /**
  58603. * 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
  58604. * @param texture1 first texture to resize
  58605. * @param texture2 second texture to resize
  58606. * @param scene babylonjs scene
  58607. * @returns resized textures or null
  58608. */
  58609. private _resizeTexturesToSameDimensions;
  58610. /**
  58611. * Converts an array of pixels to a Float32Array
  58612. * Throws an error if the pixel format is not supported
  58613. * @param pixels - array buffer containing pixel values
  58614. * @returns Float32 of pixels
  58615. */
  58616. private _convertPixelArrayToFloat32;
  58617. /**
  58618. * Convert Specular Glossiness Textures to Metallic Roughness
  58619. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  58620. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  58621. * @param diffuseTexture texture used to store diffuse information
  58622. * @param specularGlossinessTexture texture used to store specular and glossiness information
  58623. * @param factors specular glossiness material factors
  58624. * @param mimeType the mime type to use for the texture
  58625. * @returns pbr metallic roughness interface or null
  58626. */
  58627. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  58628. /**
  58629. * Converts specular glossiness material properties to metallic roughness
  58630. * @param specularGlossiness interface with specular glossiness material properties
  58631. * @returns interface with metallic roughness material properties
  58632. */
  58633. private _convertSpecularGlossinessToMetallicRoughness;
  58634. /**
  58635. * Calculates the surface reflectance, independent of lighting conditions
  58636. * @param color Color source to calculate brightness from
  58637. * @returns number representing the perceived brightness, or zero if color is undefined
  58638. */
  58639. private _getPerceivedBrightness;
  58640. /**
  58641. * Returns the maximum color component value
  58642. * @param color
  58643. * @returns maximum color component value, or zero if color is null or undefined
  58644. */
  58645. private _getMaxComponent;
  58646. /**
  58647. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  58648. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  58649. * @param mimeType mime type to use for the textures
  58650. * @param images array of glTF image interfaces
  58651. * @param textures array of glTF texture interfaces
  58652. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  58653. * @param imageData map of image file name to data
  58654. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58655. * @returns glTF PBR Metallic Roughness factors
  58656. */
  58657. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  58658. private _getGLTFTextureSampler;
  58659. private _getGLTFTextureWrapMode;
  58660. private _getGLTFTextureWrapModesSampler;
  58661. /**
  58662. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  58663. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  58664. * @param mimeType mime type to use for the textures
  58665. * @param images array of glTF image interfaces
  58666. * @param textures array of glTF texture interfaces
  58667. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  58668. * @param imageData map of image file name to data
  58669. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58670. * @returns glTF PBR Metallic Roughness factors
  58671. */
  58672. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  58673. /**
  58674. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  58675. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  58676. * @param mimeType mime type to use for the textures
  58677. * @param images array of glTF image interfaces
  58678. * @param textures array of glTF texture interfaces
  58679. * @param materials array of glTF material interfaces
  58680. * @param imageData map of image file name to data
  58681. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58682. */ convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  58683. private setMetallicRoughnessPbrMaterial;
  58684. private getPixelsFromTexture;
  58685. /**
  58686. * Extracts a texture from a Babylon texture into file data and glTF data
  58687. * @param babylonTexture Babylon texture to extract
  58688. * @param mimeType Mime Type of the babylonTexture
  58689. * @return glTF texture info, or null if the texture format is not supported
  58690. */ exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  58691. /**
  58692. * Builds a texture from base64 string
  58693. * @param base64Texture base64 texture string
  58694. * @param baseTextureName Name to use for the texture
  58695. * @param mimeType image mime type for the texture
  58696. * @param images array of images
  58697. * @param textures array of textures
  58698. * @param imageData map of image data
  58699. * @returns glTF texture info, or null if the texture format is not supported
  58700. */
  58701. private _getTextureInfoFromBase64;
  58702. }
  58703. }
  58704. declare module BABYLON {
  58705. /**
  58706. * Class for holding and downloading glTF file data
  58707. */
  58708. export class GLTFData {
  58709. /**
  58710. * Object which contains the file name as the key and its data as the value
  58711. */
  58712. glTFFiles: {
  58713. [fileName: string]: string | Blob;
  58714. };
  58715. /**
  58716. * Initializes the glTF file object
  58717. */
  58718. constructor();
  58719. /**
  58720. * Downloads the glTF data as files based on their names and data
  58721. */
  58722. downloadFiles(): void;
  58723. }
  58724. }
  58725. declare module BABYLON {
  58726. /**
  58727. * Holds a collection of exporter options and parameters
  58728. */
  58729. export interface IExportOptions {
  58730. /**
  58731. * Function which indicates whether a babylon mesh should be exported or not
  58732. * @param transformNode source Babylon transform node. It is used to check whether it should be exported to glTF or not
  58733. * @returns boolean, which indicates whether the mesh should be exported (true) or not (false)
  58734. */
  58735. shouldExportTransformNode?(transformNode: TransformNode): boolean;
  58736. /**
  58737. * The sample rate to bake animation curves
  58738. */
  58739. animationSampleRate?: number;
  58740. /**
  58741. * Begin serialization without waiting for the scene to be ready
  58742. */
  58743. exportWithoutWaitingForScene?: boolean;
  58744. }
  58745. /**
  58746. * Class for generating glTF data from a Babylon scene.
  58747. */
  58748. export class GLTF2Export {
  58749. /**
  58750. * Exports the geometry of the scene to .gltf file format asynchronously
  58751. * @param scene Babylon scene with scene hierarchy information
  58752. * @param filePrefix File prefix to use when generating the glTF file
  58753. * @param options Exporter options
  58754. * @returns Returns an object with a .gltf file and associates texture names
  58755. * as keys and their data and paths as values
  58756. */
  58757. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  58758. private static _PreExportAsync;
  58759. private static _PostExportAsync;
  58760. /**
  58761. * Exports the geometry of the scene to .glb file format asychronously
  58762. * @param scene Babylon scene with scene hierarchy information
  58763. * @param filePrefix File prefix to use when generating glb file
  58764. * @param options Exporter options
  58765. * @returns Returns an object with a .glb filename as key and data as value
  58766. */
  58767. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  58768. }
  58769. }
  58770. declare module BABYLON.GLTF2.Exporter {
  58771. /**
  58772. * @hidden
  58773. */
  58774. export class _GLTFUtilities {
  58775. /**
  58776. * Creates a buffer view based on the supplied arguments
  58777. * @param bufferIndex index value of the specified buffer
  58778. * @param byteOffset byte offset value
  58779. * @param byteLength byte length of the bufferView
  58780. * @param byteStride byte distance between conequential elements
  58781. * @param name name of the buffer view
  58782. * @returns bufferView for glTF
  58783. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  58784. /**
  58785. * Creates an accessor based on the supplied arguments
  58786. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  58787. * @param name The name of the accessor
  58788. * @param type The type of the accessor
  58789. * @param componentType The datatype of components in the attribute
  58790. * @param count The number of attributes referenced by this accessor
  58791. * @param byteOffset The offset relative to the start of the bufferView in bytes
  58792. * @param min Minimum value of each component in this attribute
  58793. * @param max Maximum value of each component in this attribute
  58794. * @returns accessor for glTF
  58795. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  58796. /**
  58797. * Calculates the minimum and maximum values of an array of position floats
  58798. * @param positions Positions array of a mesh
  58799. * @param vertexStart Starting vertex offset to calculate min and max values
  58800. * @param vertexCount Number of vertices to check for min and max values
  58801. * @returns min number array and max number array
  58802. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  58803. min: number[];
  58804. max: number[];
  58805. };
  58806. /**
  58807. * Converts a new right-handed Vector3
  58808. * @param vector vector3 array
  58809. * @returns right-handed Vector3
  58810. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  58811. /**
  58812. * Converts a Vector3 to right-handed
  58813. * @param vector Vector3 to convert to right-handed
  58814. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  58815. /**
  58816. * Converts a three element number array to right-handed
  58817. * @param vector number array to convert to right-handed
  58818. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  58819. /**
  58820. * Converts a new right-handed Vector3
  58821. * @param vector vector3 array
  58822. * @returns right-handed Vector3
  58823. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  58824. /**
  58825. * Converts a Vector3 to right-handed
  58826. * @param vector Vector3 to convert to right-handed
  58827. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  58828. /**
  58829. * Converts a three element number array to right-handed
  58830. * @param vector number array to convert to right-handed
  58831. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  58832. /**
  58833. * Converts a Vector4 to right-handed
  58834. * @param vector Vector4 to convert to right-handed
  58835. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  58836. /**
  58837. * Converts a Vector4 to right-handed
  58838. * @param vector Vector4 to convert to right-handed
  58839. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  58840. /**
  58841. * Converts a Quaternion to right-handed
  58842. * @param quaternion Source quaternion to convert to right-handed
  58843. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  58844. /**
  58845. * Converts a Quaternion to right-handed
  58846. * @param quaternion Source quaternion to convert to right-handed
  58847. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  58848. }
  58849. }
  58850. declare module BABYLON.GLTF2.Exporter {
  58851. /**
  58852. * Converts Babylon Scene into glTF 2.0.
  58853. * @hidden
  58854. */
  58855. export class _Exporter {
  58856. /**
  58857. * Stores all generated buffer views, which represents views into the main glTF buffer data
  58858. */ bufferViews: IBufferView[];
  58859. /**
  58860. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  58861. */ accessors: IAccessor[];
  58862. /**
  58863. * Stores all the generated nodes, which contains transform and/or mesh information per node
  58864. */
  58865. private _nodes;
  58866. /**
  58867. * Stores the glTF asset information, which represents the glTF version and this file generator
  58868. */
  58869. private _asset;
  58870. /**
  58871. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  58872. */
  58873. private _scenes;
  58874. /**
  58875. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  58876. */
  58877. private _meshes;
  58878. /**
  58879. * Stores all the generated material information, which represents the appearance of each primitive
  58880. */ materials: IMaterial[]; materialMap: {
  58881. [materialID: number]: number;
  58882. };
  58883. /**
  58884. * Stores all the generated texture information, which is referenced by glTF materials
  58885. */ textures: ITexture[];
  58886. /**
  58887. * Stores all the generated image information, which is referenced by glTF textures
  58888. */ images: IImage[];
  58889. /**
  58890. * Stores all the texture samplers
  58891. */ samplers: ISampler[];
  58892. /**
  58893. * Stores all the generated animation samplers, which is referenced by glTF animations
  58894. */
  58895. /**
  58896. * Stores the animations for glTF models
  58897. */
  58898. private _animations;
  58899. /**
  58900. * Stores the total amount of bytes stored in the glTF buffer
  58901. */
  58902. private _totalByteLength;
  58903. /**
  58904. * Stores a reference to the Babylon scene containing the source geometry and material information
  58905. */
  58906. private _babylonScene;
  58907. /**
  58908. * Stores a map of the image data, where the key is the file name and the value
  58909. * is the image data
  58910. */ imageData: {
  58911. [fileName: string]: {
  58912. data: Uint8Array;
  58913. mimeType: ImageMimeType;
  58914. };
  58915. };
  58916. /**
  58917. * Stores a map of the unique id of a node to its index in the node array
  58918. */
  58919. private _nodeMap;
  58920. /**
  58921. * Specifies if the Babylon scene should be converted to right-handed on export
  58922. */
  58923. private _convertToRightHandedSystem;
  58924. /**
  58925. * Baked animation sample rate
  58926. */
  58927. private _animationSampleRate;
  58928. /**
  58929. * Callback which specifies if a transform node should be exported or not
  58930. */
  58931. private _shouldExportTransformNode;
  58932. private _localEngine; glTFMaterialExporter: _GLTFMaterialExporter;
  58933. private _extensions;
  58934. private _extensionsUsed;
  58935. private _extensionsRequired;
  58936. private static _ExtensionNames;
  58937. private static _ExtensionFactories;
  58938. private _applyExtensions; extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  58939. /**
  58940. * Load glTF serializer extensions
  58941. */
  58942. private _loadExtensions;
  58943. /**
  58944. * Creates a glTF Exporter instance, which can accept optional exporter options
  58945. * @param babylonScene Babylon scene object
  58946. * @param options Options to modify the behavior of the exporter
  58947. */
  58948. constructor(babylonScene: Scene, options?: IExportOptions);
  58949. /**
  58950. * Registers a glTF exporter extension
  58951. * @param name Name of the extension to export
  58952. * @param factory The factory function that creates the exporter extension
  58953. */
  58954. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  58955. /**
  58956. * Un-registers an exporter extension
  58957. * @param name The name fo the exporter extension
  58958. * @returns A boolean indicating whether the extension has been un-registered
  58959. */
  58960. static UnregisterExtension(name: string): boolean;
  58961. /**
  58962. * Lazy load a local engine with premultiplied alpha set to false
  58963. */ getLocalEngine(): Engine;
  58964. private reorderIndicesBasedOnPrimitiveMode;
  58965. /**
  58966. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  58967. * clock-wise during export to glTF
  58968. * @param submesh BabylonJS submesh
  58969. * @param primitiveMode Primitive mode of the mesh
  58970. * @param sideOrientation the winding order of the submesh
  58971. * @param vertexBufferKind The type of vertex attribute
  58972. * @param meshAttributeArray The vertex attribute data
  58973. * @param byteOffset The offset to the binary data
  58974. * @param binaryWriter The binary data for the glTF file
  58975. */
  58976. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  58977. /**
  58978. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  58979. * clock-wise during export to glTF
  58980. * @param submesh BabylonJS submesh
  58981. * @param primitiveMode Primitive mode of the mesh
  58982. * @param sideOrientation the winding order of the submesh
  58983. * @param vertexBufferKind The type of vertex attribute
  58984. * @param meshAttributeArray The vertex attribute data
  58985. * @param byteOffset The offset to the binary data
  58986. * @param binaryWriter The binary data for the glTF file
  58987. */
  58988. private reorderTriangleFillMode;
  58989. /**
  58990. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  58991. * clock-wise during export to glTF
  58992. * @param submesh BabylonJS submesh
  58993. * @param primitiveMode Primitive mode of the mesh
  58994. * @param sideOrientation the winding order of the submesh
  58995. * @param vertexBufferKind The type of vertex attribute
  58996. * @param meshAttributeArray The vertex attribute data
  58997. * @param byteOffset The offset to the binary data
  58998. * @param binaryWriter The binary data for the glTF file
  58999. */
  59000. private reorderTriangleStripDrawMode;
  59001. /**
  59002. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  59003. * clock-wise during export to glTF
  59004. * @param submesh BabylonJS submesh
  59005. * @param primitiveMode Primitive mode of the mesh
  59006. * @param sideOrientation the winding order of the submesh
  59007. * @param vertexBufferKind The type of vertex attribute
  59008. * @param meshAttributeArray The vertex attribute data
  59009. * @param byteOffset The offset to the binary data
  59010. * @param binaryWriter The binary data for the glTF file
  59011. */
  59012. private reorderTriangleFanMode;
  59013. /**
  59014. * Writes the vertex attribute data to binary
  59015. * @param vertices The vertices to write to the binary writer
  59016. * @param byteOffset The offset into the binary writer to overwrite binary data
  59017. * @param vertexAttributeKind The vertex attribute type
  59018. * @param meshAttributeArray The vertex attribute data
  59019. * @param binaryWriter The writer containing the binary data
  59020. */
  59021. private writeVertexAttributeData;
  59022. /**
  59023. * Writes mesh attribute data to a data buffer
  59024. * Returns the bytelength of the data
  59025. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  59026. * @param meshAttributeArray Array containing the attribute data
  59027. * @param binaryWriter The buffer to write the binary data to
  59028. * @param indices Used to specify the order of the vertex data
  59029. */
  59030. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  59031. /**
  59032. * Generates glTF json data
  59033. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  59034. * @param glTFPrefix Text to use when prefixing a glTF file
  59035. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  59036. * @returns json data as string
  59037. */
  59038. private generateJSON;
  59039. /**
  59040. * Generates data for .gltf and .bin files based on the glTF prefix string
  59041. * @param glTFPrefix Text to use when prefixing a glTF file
  59042. * @returns GLTFData with glTF file data
  59043. */ generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  59044. /**
  59045. * Creates a binary buffer for glTF
  59046. * @returns array buffer for binary data
  59047. */
  59048. private _generateBinaryAsync;
  59049. /**
  59050. * Pads the number to a multiple of 4
  59051. * @param num number to pad
  59052. * @returns padded number
  59053. */
  59054. private _getPadding;
  59055. /**
  59056. * Generates a glb file from the json and binary data
  59057. * Returns an object with the glb file name as the key and data as the value
  59058. * @param glTFPrefix
  59059. * @returns object with glb filename as key and data as value
  59060. */ generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  59061. /**
  59062. * Sets the TRS for each node
  59063. * @param node glTF Node for storing the transformation data
  59064. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  59065. */
  59066. private setNodeTransformation;
  59067. private getVertexBufferFromMesh;
  59068. /**
  59069. * Creates a bufferview based on the vertices type for the Babylon mesh
  59070. * @param kind Indicates the type of vertices data
  59071. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  59072. * @param binaryWriter The buffer to write the bufferview data to
  59073. */
  59074. private createBufferViewKind;
  59075. /**
  59076. * The primitive mode of the Babylon mesh
  59077. * @param babylonMesh The BabylonJS mesh
  59078. */
  59079. private getMeshPrimitiveMode;
  59080. /**
  59081. * Sets the primitive mode of the glTF mesh primitive
  59082. * @param meshPrimitive glTF mesh primitive
  59083. * @param primitiveMode The primitive mode
  59084. */
  59085. private setPrimitiveMode;
  59086. /**
  59087. * Sets the vertex attribute accessor based of the glTF mesh primitive
  59088. * @param meshPrimitive glTF mesh primitive
  59089. * @param attributeKind vertex attribute
  59090. * @returns boolean specifying if uv coordinates are present
  59091. */
  59092. private setAttributeKind;
  59093. /**
  59094. * Sets data for the primitive attributes of each submesh
  59095. * @param mesh glTF Mesh object to store the primitive attribute information
  59096. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  59097. * @param binaryWriter Buffer to write the attribute data to
  59098. */
  59099. private setPrimitiveAttributesAsync;
  59100. /**
  59101. * Creates a glTF scene based on the array of meshes
  59102. * Returns the the total byte offset
  59103. * @param babylonScene Babylon scene to get the mesh data from
  59104. * @param binaryWriter Buffer to write binary data to
  59105. */
  59106. private createSceneAsync;
  59107. /**
  59108. * Creates a mapping of Node unique id to node index and handles animations
  59109. * @param babylonScene Babylon Scene
  59110. * @param nodes Babylon transform nodes
  59111. * @param shouldExportTransformNode Callback specifying if a transform node should be exported
  59112. * @param binaryWriter Buffer to write binary data to
  59113. * @returns Node mapping of unique id to index
  59114. */
  59115. private createNodeMapAndAnimationsAsync;
  59116. /**
  59117. * Creates a glTF node from a Babylon mesh
  59118. * @param babylonMesh Source Babylon mesh
  59119. * @param binaryWriter Buffer for storing geometry data
  59120. * @returns glTF node
  59121. */
  59122. private createNodeAsync;
  59123. }
  59124. /**
  59125. * @hidden
  59126. *
  59127. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  59128. */
  59129. export class _BinaryWriter {
  59130. /**
  59131. * Array buffer which stores all binary data
  59132. */
  59133. private _arrayBuffer;
  59134. /**
  59135. * View of the array buffer
  59136. */
  59137. private _dataView;
  59138. /**
  59139. * byte offset of data in array buffer
  59140. */
  59141. private _byteOffset;
  59142. /**
  59143. * Initialize binary writer with an initial byte length
  59144. * @param byteLength Initial byte length of the array buffer
  59145. */
  59146. constructor(byteLength: number);
  59147. /**
  59148. * Resize the array buffer to the specified byte length
  59149. * @param byteLength
  59150. */
  59151. private resizeBuffer;
  59152. /**
  59153. * Get an array buffer with the length of the byte offset
  59154. * @returns ArrayBuffer resized to the byte offset
  59155. */
  59156. getArrayBuffer(): ArrayBuffer;
  59157. /**
  59158. * Get the byte offset of the array buffer
  59159. * @returns byte offset
  59160. */
  59161. getByteOffset(): number;
  59162. /**
  59163. * Stores an UInt8 in the array buffer
  59164. * @param entry
  59165. * @param byteOffset If defined, specifies where to set the value as an offset.
  59166. */
  59167. setUInt8(entry: number, byteOffset?: number): void;
  59168. /**
  59169. * Gets an UInt32 in the array buffer
  59170. * @param entry
  59171. * @param byteOffset If defined, specifies where to set the value as an offset.
  59172. */
  59173. getUInt32(byteOffset: number): number;
  59174. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  59175. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  59176. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  59177. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  59178. /**
  59179. * Stores a Float32 in the array buffer
  59180. * @param entry
  59181. */
  59182. setFloat32(entry: number, byteOffset?: number): void;
  59183. /**
  59184. * Stores an UInt32 in the array buffer
  59185. * @param entry
  59186. * @param byteOffset If defined, specifies where to set the value as an offset.
  59187. */
  59188. setUInt32(entry: number, byteOffset?: number): void;
  59189. }
  59190. }
  59191. declare module BABYLON.GLTF2.Exporter {
  59192. /**
  59193. * @hidden
  59194. * Interface to store animation data.
  59195. */
  59196. export interface _IAnimationData {
  59197. /**
  59198. * Keyframe data.
  59199. */
  59200. inputs: number[];
  59201. /**
  59202. * Value data.
  59203. */
  59204. outputs: number[][];
  59205. /**
  59206. * Animation interpolation data.
  59207. */
  59208. samplerInterpolation: AnimationSamplerInterpolation;
  59209. /**
  59210. * Minimum keyframe value.
  59211. */
  59212. inputsMin: number;
  59213. /**
  59214. * Maximum keyframe value.
  59215. */
  59216. inputsMax: number;
  59217. }
  59218. /**
  59219. * @hidden
  59220. */
  59221. export interface _IAnimationInfo {
  59222. /**
  59223. * The target channel for the animation
  59224. */
  59225. animationChannelTargetPath: AnimationChannelTargetPath;
  59226. /**
  59227. * The glTF accessor type for the data.
  59228. */
  59229. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  59230. /**
  59231. * Specifies if quaternions should be used.
  59232. */
  59233. useQuaternion: boolean;
  59234. }
  59235. /**
  59236. * @hidden
  59237. * Utility class for generating glTF animation data from BabylonJS.
  59238. */
  59239. export class _GLTFAnimation {
  59240. /**
  59241. * @ignore
  59242. *
  59243. * Creates glTF channel animation from BabylonJS animation.
  59244. * @param babylonTransformNode - BabylonJS mesh.
  59245. * @param animation - animation.
  59246. * @param animationChannelTargetPath - The target animation channel.
  59247. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  59248. * @param useQuaternion - Specifies if quaternions are used.
  59249. * @returns nullable IAnimationData
  59250. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  59251. private static _DeduceAnimationInfo;
  59252. /**
  59253. * @ignore
  59254. * Create node animations from the transform node animations
  59255. * @param babylonTransformNode
  59256. * @param runtimeGLTFAnimation
  59257. * @param idleGLTFAnimations
  59258. * @param nodeMap
  59259. * @param nodes
  59260. * @param binaryWriter
  59261. * @param bufferViews
  59262. * @param accessors
  59263. * @param convertToRightHandedSystem
  59264. */ private static _CreateNodeAnimationFromTransformNodeAnimations(babylonTransformNode: TransformNode, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  59265. [key: number]: number;
  59266. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  59267. /**
  59268. * @ignore
  59269. * Create node animations from the animation groups
  59270. * @param babylonScene
  59271. * @param glTFAnimations
  59272. * @param nodeMap
  59273. * @param nodes
  59274. * @param binaryWriter
  59275. * @param bufferViews
  59276. * @param accessors
  59277. * @param convertToRightHandedSystem
  59278. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  59279. [key: number]: number;
  59280. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  59281. private static AddAnimation;
  59282. /**
  59283. * Create a baked animation
  59284. * @param babylonTransformNode BabylonJS mesh
  59285. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  59286. * @param animationChannelTargetPath animation target channel
  59287. * @param minFrame minimum animation frame
  59288. * @param maxFrame maximum animation frame
  59289. * @param fps frames per second of the animation
  59290. * @param inputs input key frames of the animation
  59291. * @param outputs output key frame data of the animation
  59292. * @param convertToRightHandedSystem converts the values to right-handed
  59293. * @param useQuaternion specifies if quaternions should be used
  59294. */
  59295. private static _CreateBakedAnimation;
  59296. private static _ConvertFactorToVector3OrQuaternion;
  59297. private static _SetInterpolatedValue;
  59298. /**
  59299. * Creates linear animation from the animation key frames
  59300. * @param babylonTransformNode BabylonJS mesh
  59301. * @param animation BabylonJS animation
  59302. * @param animationChannelTargetPath The target animation channel
  59303. * @param frameDelta The difference between the last and first frame of the animation
  59304. * @param inputs Array to store the key frame times
  59305. * @param outputs Array to store the key frame data
  59306. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  59307. * @param useQuaternion Specifies if quaternions are used in the animation
  59308. */
  59309. private static _CreateLinearOrStepAnimation;
  59310. /**
  59311. * Creates cubic spline animation from the animation key frames
  59312. * @param babylonTransformNode BabylonJS mesh
  59313. * @param animation BabylonJS animation
  59314. * @param animationChannelTargetPath The target animation channel
  59315. * @param frameDelta The difference between the last and first frame of the animation
  59316. * @param inputs Array to store the key frame times
  59317. * @param outputs Array to store the key frame data
  59318. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  59319. * @param useQuaternion Specifies if quaternions are used in the animation
  59320. */
  59321. private static _CreateCubicSplineAnimation;
  59322. private static _GetBasePositionRotationOrScale;
  59323. /**
  59324. * Adds a key frame value
  59325. * @param keyFrame
  59326. * @param animation
  59327. * @param outputs
  59328. * @param animationChannelTargetPath
  59329. * @param basePositionRotationOrScale
  59330. * @param convertToRightHandedSystem
  59331. * @param useQuaternion
  59332. */
  59333. private static _AddKeyframeValue;
  59334. /**
  59335. * Determine the interpolation based on the key frames
  59336. * @param keyFrames
  59337. * @param animationChannelTargetPath
  59338. * @param useQuaternion
  59339. */
  59340. private static _DeduceInterpolation;
  59341. /**
  59342. * Adds an input tangent or output tangent to the output data
  59343. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  59344. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  59345. * @param outputs The animation data by keyframe
  59346. * @param animationChannelTargetPath The target animation channel
  59347. * @param interpolation The interpolation type
  59348. * @param keyFrame The key frame with the animation data
  59349. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  59350. * @param useQuaternion Specifies if quaternions are used
  59351. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  59352. */
  59353. private static AddSplineTangent;
  59354. /**
  59355. * Get the minimum and maximum key frames' frame values
  59356. * @param keyFrames animation key frames
  59357. * @returns the minimum and maximum key frame value
  59358. */
  59359. private static calculateMinMaxKeyFrames;
  59360. }
  59361. }
  59362. declare module BABYLON.GLTF2.Exporter {
  59363. /** @hidden */
  59364. export var textureTransformPixelShader: {
  59365. name: string;
  59366. shader: string;
  59367. };
  59368. }
  59369. declare module BABYLON.GLTF2.Exporter.Extensions {
  59370. /**
  59371. * @hidden
  59372. */
  59373. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  59374. /** Name of this extension */
  59375. readonly name: string;
  59376. /** Defines whether this extension is enabled */
  59377. enabled: boolean;
  59378. /** Defines whether this extension is required */
  59379. required: boolean;
  59380. /** Reference to the glTF exporter */
  59381. private _exporter;
  59382. constructor(exporter: _Exporter);
  59383. dispose(): void;
  59384. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  59385. /**
  59386. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  59387. * @param babylonTexture
  59388. * @param offset
  59389. * @param rotation
  59390. * @param scale
  59391. * @param scene
  59392. */
  59393. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  59394. }
  59395. }
  59396. /**
  59397. * @ignoreChildren
  59398. * @ignore
  59399. */
  59400. declare module "babylonjs-gltf2interface" {
  59401. export = BABYLON.GLTF2;
  59402. }
  59403. /**
  59404. * Module for glTF 2.0 Interface
  59405. * @ignoreChildren
  59406. * @ignore
  59407. */
  59408. declare module BABYLON.GLTF2 {
  59409. /**
  59410. * The datatype of the components in the attribute
  59411. */
  59412. const enum AccessorComponentType {
  59413. /**
  59414. * Byte
  59415. */
  59416. BYTE = 5120,
  59417. /**
  59418. * Unsigned Byte
  59419. */
  59420. UNSIGNED_BYTE = 5121,
  59421. /**
  59422. * Short
  59423. */
  59424. SHORT = 5122,
  59425. /**
  59426. * Unsigned Short
  59427. */
  59428. UNSIGNED_SHORT = 5123,
  59429. /**
  59430. * Unsigned Int
  59431. */
  59432. UNSIGNED_INT = 5125,
  59433. /**
  59434. * Float
  59435. */
  59436. FLOAT = 5126,
  59437. }
  59438. /**
  59439. * Specifies if the attirbute is a scalar, vector, or matrix
  59440. */
  59441. const enum AccessorType {
  59442. /**
  59443. * Scalar
  59444. */
  59445. SCALAR = "SCALAR",
  59446. /**
  59447. * Vector2
  59448. */
  59449. VEC2 = "VEC2",
  59450. /**
  59451. * Vector3
  59452. */
  59453. VEC3 = "VEC3",
  59454. /**
  59455. * Vector4
  59456. */
  59457. VEC4 = "VEC4",
  59458. /**
  59459. * Matrix2x2
  59460. */
  59461. MAT2 = "MAT2",
  59462. /**
  59463. * Matrix3x3
  59464. */
  59465. MAT3 = "MAT3",
  59466. /**
  59467. * Matrix4x4
  59468. */
  59469. MAT4 = "MAT4",
  59470. }
  59471. /**
  59472. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  59473. */
  59474. const enum AnimationChannelTargetPath {
  59475. /**
  59476. * Translation
  59477. */
  59478. TRANSLATION = "translation",
  59479. /**
  59480. * Rotation
  59481. */
  59482. ROTATION = "rotation",
  59483. /**
  59484. * Scale
  59485. */
  59486. SCALE = "scale",
  59487. /**
  59488. * Weights
  59489. */
  59490. WEIGHTS = "weights",
  59491. }
  59492. /**
  59493. * Interpolation algorithm
  59494. */
  59495. const enum AnimationSamplerInterpolation {
  59496. /**
  59497. * The animated values are linearly interpolated between keyframes
  59498. */
  59499. LINEAR = "LINEAR",
  59500. /**
  59501. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  59502. */
  59503. STEP = "STEP",
  59504. /**
  59505. * The animation's interpolation is computed using a cubic spline with specified tangents
  59506. */
  59507. CUBICSPLINE = "CUBICSPLINE",
  59508. }
  59509. /**
  59510. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  59511. */
  59512. const enum CameraType {
  59513. /**
  59514. * A perspective camera containing properties to create a perspective projection matrix
  59515. */
  59516. PERSPECTIVE = "perspective",
  59517. /**
  59518. * An orthographic camera containing properties to create an orthographic projection matrix
  59519. */
  59520. ORTHOGRAPHIC = "orthographic",
  59521. }
  59522. /**
  59523. * The mime-type of the image
  59524. */
  59525. const enum ImageMimeType {
  59526. /**
  59527. * JPEG Mime-type
  59528. */
  59529. JPEG = "image/jpeg",
  59530. /**
  59531. * PNG Mime-type
  59532. */
  59533. PNG = "image/png",
  59534. }
  59535. /**
  59536. * The alpha rendering mode of the material
  59537. */
  59538. const enum MaterialAlphaMode {
  59539. /**
  59540. * The alpha value is ignored and the rendered output is fully opaque
  59541. */
  59542. OPAQUE = "OPAQUE",
  59543. /**
  59544. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  59545. */
  59546. MASK = "MASK",
  59547. /**
  59548. * 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)
  59549. */
  59550. BLEND = "BLEND",
  59551. }
  59552. /**
  59553. * The type of the primitives to render
  59554. */
  59555. const enum MeshPrimitiveMode {
  59556. /**
  59557. * Points
  59558. */
  59559. POINTS = 0,
  59560. /**
  59561. * Lines
  59562. */
  59563. LINES = 1,
  59564. /**
  59565. * Line Loop
  59566. */
  59567. LINE_LOOP = 2,
  59568. /**
  59569. * Line Strip
  59570. */
  59571. LINE_STRIP = 3,
  59572. /**
  59573. * Triangles
  59574. */
  59575. TRIANGLES = 4,
  59576. /**
  59577. * Triangle Strip
  59578. */
  59579. TRIANGLE_STRIP = 5,
  59580. /**
  59581. * Triangle Fan
  59582. */
  59583. TRIANGLE_FAN = 6,
  59584. }
  59585. /**
  59586. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  59587. */
  59588. const enum TextureMagFilter {
  59589. /**
  59590. * Nearest
  59591. */
  59592. NEAREST = 9728,
  59593. /**
  59594. * Linear
  59595. */
  59596. LINEAR = 9729,
  59597. }
  59598. /**
  59599. * Minification filter. All valid values correspond to WebGL enums
  59600. */
  59601. const enum TextureMinFilter {
  59602. /**
  59603. * Nearest
  59604. */
  59605. NEAREST = 9728,
  59606. /**
  59607. * Linear
  59608. */
  59609. LINEAR = 9729,
  59610. /**
  59611. * Nearest Mip-Map Nearest
  59612. */
  59613. NEAREST_MIPMAP_NEAREST = 9984,
  59614. /**
  59615. * Linear Mipmap Nearest
  59616. */
  59617. LINEAR_MIPMAP_NEAREST = 9985,
  59618. /**
  59619. * Nearest Mipmap Linear
  59620. */
  59621. NEAREST_MIPMAP_LINEAR = 9986,
  59622. /**
  59623. * Linear Mipmap Linear
  59624. */
  59625. LINEAR_MIPMAP_LINEAR = 9987,
  59626. }
  59627. /**
  59628. * S (U) wrapping mode. All valid values correspond to WebGL enums
  59629. */
  59630. const enum TextureWrapMode {
  59631. /**
  59632. * Clamp to Edge
  59633. */
  59634. CLAMP_TO_EDGE = 33071,
  59635. /**
  59636. * Mirrored Repeat
  59637. */
  59638. MIRRORED_REPEAT = 33648,
  59639. /**
  59640. * Repeat
  59641. */
  59642. REPEAT = 10497,
  59643. }
  59644. /**
  59645. * glTF Property
  59646. */
  59647. interface IProperty {
  59648. /**
  59649. * Dictionary object with extension-specific objects
  59650. */
  59651. extensions?: {
  59652. [key: string]: any;
  59653. };
  59654. /**
  59655. * Application-Specific data
  59656. */
  59657. extras?: any;
  59658. }
  59659. /**
  59660. * glTF Child of Root Property
  59661. */
  59662. interface IChildRootProperty extends IProperty {
  59663. /**
  59664. * The user-defined name of this object
  59665. */
  59666. name?: string;
  59667. }
  59668. /**
  59669. * Indices of those attributes that deviate from their initialization value
  59670. */
  59671. interface IAccessorSparseIndices extends IProperty {
  59672. /**
  59673. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  59674. */
  59675. bufferView: number;
  59676. /**
  59677. * The offset relative to the start of the bufferView in bytes. Must be aligned
  59678. */
  59679. byteOffset?: number;
  59680. /**
  59681. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  59682. */
  59683. componentType: AccessorComponentType;
  59684. }
  59685. /**
  59686. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  59687. */
  59688. interface IAccessorSparseValues extends IProperty {
  59689. /**
  59690. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  59691. */
  59692. bufferView: number;
  59693. /**
  59694. * The offset relative to the start of the bufferView in bytes. Must be aligned
  59695. */
  59696. byteOffset?: number;
  59697. }
  59698. /**
  59699. * Sparse storage of attributes that deviate from their initialization value
  59700. */
  59701. interface IAccessorSparse extends IProperty {
  59702. /**
  59703. * The number of attributes encoded in this sparse accessor
  59704. */
  59705. count: number;
  59706. /**
  59707. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  59708. */
  59709. indices: IAccessorSparseIndices;
  59710. /**
  59711. * 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
  59712. */
  59713. values: IAccessorSparseValues;
  59714. }
  59715. /**
  59716. * 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
  59717. */
  59718. interface IAccessor extends IChildRootProperty {
  59719. /**
  59720. * The index of the bufferview
  59721. */
  59722. bufferView?: number;
  59723. /**
  59724. * The offset relative to the start of the bufferView in bytes
  59725. */
  59726. byteOffset?: number;
  59727. /**
  59728. * The datatype of components in the attribute
  59729. */
  59730. componentType: AccessorComponentType;
  59731. /**
  59732. * Specifies whether integer data values should be normalized
  59733. */
  59734. normalized?: boolean;
  59735. /**
  59736. * The number of attributes referenced by this accessor
  59737. */
  59738. count: number;
  59739. /**
  59740. * Specifies if the attribute is a scalar, vector, or matrix
  59741. */
  59742. type: AccessorType;
  59743. /**
  59744. * Maximum value of each component in this attribute
  59745. */
  59746. max?: number[];
  59747. /**
  59748. * Minimum value of each component in this attribute
  59749. */
  59750. min?: number[];
  59751. /**
  59752. * Sparse storage of attributes that deviate from their initialization value
  59753. */
  59754. sparse?: IAccessorSparse;
  59755. }
  59756. /**
  59757. * Targets an animation's sampler at a node's property
  59758. */
  59759. interface IAnimationChannel extends IProperty {
  59760. /**
  59761. * The index of a sampler in this animation used to compute the value for the target
  59762. */
  59763. sampler: number;
  59764. /**
  59765. * The index of the node and TRS property to target
  59766. */
  59767. target: IAnimationChannelTarget;
  59768. }
  59769. /**
  59770. * The index of the node and TRS property that an animation channel targets
  59771. */
  59772. interface IAnimationChannelTarget extends IProperty {
  59773. /**
  59774. * The index of the node to target
  59775. */
  59776. node: number;
  59777. /**
  59778. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  59779. */
  59780. path: AnimationChannelTargetPath;
  59781. }
  59782. /**
  59783. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  59784. */
  59785. interface IAnimationSampler extends IProperty {
  59786. /**
  59787. * The index of an accessor containing keyframe input values, e.g., time
  59788. */
  59789. input: number;
  59790. /**
  59791. * Interpolation algorithm
  59792. */
  59793. interpolation?: AnimationSamplerInterpolation;
  59794. /**
  59795. * The index of an accessor, containing keyframe output values
  59796. */
  59797. output: number;
  59798. }
  59799. /**
  59800. * A keyframe animation
  59801. */
  59802. interface IAnimation extends IChildRootProperty {
  59803. /**
  59804. * An array of channels, each of which targets an animation's sampler at a node's property
  59805. */
  59806. channels: IAnimationChannel[];
  59807. /**
  59808. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  59809. */
  59810. samplers: IAnimationSampler[];
  59811. }
  59812. /**
  59813. * Metadata about the glTF asset
  59814. */
  59815. interface IAsset extends IChildRootProperty {
  59816. /**
  59817. * A copyright message suitable for display to credit the content creator
  59818. */
  59819. copyright?: string;
  59820. /**
  59821. * Tool that generated this glTF model. Useful for debugging
  59822. */
  59823. generator?: string;
  59824. /**
  59825. * The glTF version that this asset targets
  59826. */
  59827. version: string;
  59828. /**
  59829. * The minimum glTF version that this asset targets
  59830. */
  59831. minVersion?: string;
  59832. }
  59833. /**
  59834. * A buffer points to binary geometry, animation, or skins
  59835. */
  59836. interface IBuffer extends IChildRootProperty {
  59837. /**
  59838. * 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
  59839. */
  59840. uri?: string;
  59841. /**
  59842. * The length of the buffer in bytes
  59843. */
  59844. byteLength: number;
  59845. }
  59846. /**
  59847. * A view into a buffer generally representing a subset of the buffer
  59848. */
  59849. interface IBufferView extends IChildRootProperty {
  59850. /**
  59851. * The index of the buffer
  59852. */
  59853. buffer: number;
  59854. /**
  59855. * The offset into the buffer in bytes
  59856. */
  59857. byteOffset?: number;
  59858. /**
  59859. * The lenth of the bufferView in bytes
  59860. */
  59861. byteLength: number;
  59862. /**
  59863. * The stride, in bytes
  59864. */
  59865. byteStride?: number;
  59866. }
  59867. /**
  59868. * An orthographic camera containing properties to create an orthographic projection matrix
  59869. */
  59870. interface ICameraOrthographic extends IProperty {
  59871. /**
  59872. * The floating-point horizontal magnification of the view. Must not be zero
  59873. */
  59874. xmag: number;
  59875. /**
  59876. * The floating-point vertical magnification of the view. Must not be zero
  59877. */
  59878. ymag: number;
  59879. /**
  59880. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  59881. */
  59882. zfar: number;
  59883. /**
  59884. * The floating-point distance to the near clipping plane
  59885. */
  59886. znear: number;
  59887. }
  59888. /**
  59889. * A perspective camera containing properties to create a perspective projection matrix
  59890. */
  59891. interface ICameraPerspective extends IProperty {
  59892. /**
  59893. * The floating-point aspect ratio of the field of view
  59894. */
  59895. aspectRatio?: number;
  59896. /**
  59897. * The floating-point vertical field of view in radians
  59898. */
  59899. yfov: number;
  59900. /**
  59901. * The floating-point distance to the far clipping plane
  59902. */
  59903. zfar?: number;
  59904. /**
  59905. * The floating-point distance to the near clipping plane
  59906. */
  59907. znear: number;
  59908. }
  59909. /**
  59910. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  59911. */
  59912. interface ICamera extends IChildRootProperty {
  59913. /**
  59914. * An orthographic camera containing properties to create an orthographic projection matrix
  59915. */
  59916. orthographic?: ICameraOrthographic;
  59917. /**
  59918. * A perspective camera containing properties to create a perspective projection matrix
  59919. */
  59920. perspective?: ICameraPerspective;
  59921. /**
  59922. * Specifies if the camera uses a perspective or orthographic projection
  59923. */
  59924. type: CameraType;
  59925. }
  59926. /**
  59927. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  59928. */
  59929. interface IImage extends IChildRootProperty {
  59930. /**
  59931. * 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
  59932. */
  59933. uri?: string;
  59934. /**
  59935. * The image's MIME type
  59936. */
  59937. mimeType?: ImageMimeType;
  59938. /**
  59939. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  59940. */
  59941. bufferView?: number;
  59942. }
  59943. /**
  59944. * Material Normal Texture Info
  59945. */
  59946. interface IMaterialNormalTextureInfo extends ITextureInfo {
  59947. /**
  59948. * The scalar multiplier applied to each normal vector of the normal texture
  59949. */
  59950. scale?: number;
  59951. }
  59952. /**
  59953. * Material Occlusion Texture Info
  59954. */
  59955. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  59956. /**
  59957. * A scalar multiplier controlling the amount of occlusion applied
  59958. */
  59959. strength?: number;
  59960. }
  59961. /**
  59962. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  59963. */
  59964. interface IMaterialPbrMetallicRoughness {
  59965. /**
  59966. * The material's base color factor
  59967. */
  59968. baseColorFactor?: number[];
  59969. /**
  59970. * The base color texture
  59971. */
  59972. baseColorTexture?: ITextureInfo;
  59973. /**
  59974. * The metalness of the material
  59975. */
  59976. metallicFactor?: number;
  59977. /**
  59978. * The roughness of the material
  59979. */
  59980. roughnessFactor?: number;
  59981. /**
  59982. * The metallic-roughness texture
  59983. */
  59984. metallicRoughnessTexture?: ITextureInfo;
  59985. }
  59986. /**
  59987. * The material appearance of a primitive
  59988. */
  59989. interface IMaterial extends IChildRootProperty {
  59990. /**
  59991. * 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
  59992. */
  59993. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  59994. /**
  59995. * The normal map texture
  59996. */
  59997. normalTexture?: IMaterialNormalTextureInfo;
  59998. /**
  59999. * The occlusion map texture
  60000. */
  60001. occlusionTexture?: IMaterialOcclusionTextureInfo;
  60002. /**
  60003. * The emissive map texture
  60004. */
  60005. emissiveTexture?: ITextureInfo;
  60006. /**
  60007. * 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
  60008. */
  60009. emissiveFactor?: number[];
  60010. /**
  60011. * The alpha rendering mode of the material
  60012. */
  60013. alphaMode?: MaterialAlphaMode;
  60014. /**
  60015. * The alpha cutoff value of the material
  60016. */
  60017. alphaCutoff?: number;
  60018. /**
  60019. * Specifies whether the material is double sided
  60020. */
  60021. doubleSided?: boolean;
  60022. }
  60023. /**
  60024. * Geometry to be rendered with the given material
  60025. */
  60026. interface IMeshPrimitive extends IProperty {
  60027. /**
  60028. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  60029. */
  60030. attributes: {
  60031. [name: string]: number;
  60032. };
  60033. /**
  60034. * The index of the accessor that contains the indices
  60035. */
  60036. indices?: number;
  60037. /**
  60038. * The index of the material to apply to this primitive when rendering
  60039. */
  60040. material?: number;
  60041. /**
  60042. * The type of primitives to render. All valid values correspond to WebGL enums
  60043. */
  60044. mode?: MeshPrimitiveMode;
  60045. /**
  60046. * 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
  60047. */
  60048. targets?: {
  60049. [name: string]: number;
  60050. }[];
  60051. }
  60052. /**
  60053. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  60054. */
  60055. interface IMesh extends IChildRootProperty {
  60056. /**
  60057. * An array of primitives, each defining geometry to be rendered with a material
  60058. */
  60059. primitives: IMeshPrimitive[];
  60060. /**
  60061. * Array of weights to be applied to the Morph Targets
  60062. */
  60063. weights?: number[];
  60064. }
  60065. /**
  60066. * A node in the node hierarchy
  60067. */
  60068. interface INode extends IChildRootProperty {
  60069. /**
  60070. * The index of the camera referenced by this node
  60071. */
  60072. camera?: number;
  60073. /**
  60074. * The indices of this node's children
  60075. */
  60076. children?: number[];
  60077. /**
  60078. * The index of the skin referenced by this node
  60079. */
  60080. skin?: number;
  60081. /**
  60082. * A floating-point 4x4 transformation matrix stored in column-major order
  60083. */
  60084. matrix?: number[];
  60085. /**
  60086. * The index of the mesh in this node
  60087. */
  60088. mesh?: number;
  60089. /**
  60090. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  60091. */
  60092. rotation?: number[];
  60093. /**
  60094. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  60095. */
  60096. scale?: number[];
  60097. /**
  60098. * The node's translation along the x, y, and z axes
  60099. */
  60100. translation?: number[];
  60101. /**
  60102. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  60103. */
  60104. weights?: number[];
  60105. }
  60106. /**
  60107. * Texture sampler properties for filtering and wrapping modes
  60108. */
  60109. interface ISampler extends IChildRootProperty {
  60110. /**
  60111. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  60112. */
  60113. magFilter?: TextureMagFilter;
  60114. /**
  60115. * Minification filter. All valid values correspond to WebGL enums
  60116. */
  60117. minFilter?: TextureMinFilter;
  60118. /**
  60119. * S (U) wrapping mode. All valid values correspond to WebGL enums
  60120. */
  60121. wrapS?: TextureWrapMode;
  60122. /**
  60123. * T (V) wrapping mode. All valid values correspond to WebGL enums
  60124. */
  60125. wrapT?: TextureWrapMode;
  60126. }
  60127. /**
  60128. * The root nodes of a scene
  60129. */
  60130. interface IScene extends IChildRootProperty {
  60131. /**
  60132. * The indices of each root node
  60133. */
  60134. nodes: number[];
  60135. }
  60136. /**
  60137. * Joints and matrices defining a skin
  60138. */
  60139. interface ISkin extends IChildRootProperty {
  60140. /**
  60141. * 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
  60142. */
  60143. inverseBindMatrices?: number;
  60144. /**
  60145. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  60146. */
  60147. skeleton?: number;
  60148. /**
  60149. * 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)
  60150. */
  60151. joints: number[];
  60152. }
  60153. /**
  60154. * A texture and its sampler
  60155. */
  60156. interface ITexture extends IChildRootProperty {
  60157. /**
  60158. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  60159. */
  60160. sampler?: number;
  60161. /**
  60162. * The index of the image used by this texture
  60163. */
  60164. source: number;
  60165. }
  60166. /**
  60167. * Reference to a texture
  60168. */
  60169. interface ITextureInfo extends IProperty {
  60170. /**
  60171. * The index of the texture
  60172. */
  60173. index: number;
  60174. /**
  60175. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  60176. */
  60177. texCoord?: number;
  60178. }
  60179. /**
  60180. * The root object for a glTF asset
  60181. */
  60182. interface IGLTF extends IProperty {
  60183. /**
  60184. * An array of accessors. An accessor is a typed view into a bufferView
  60185. */
  60186. accessors?: IAccessor[];
  60187. /**
  60188. * An array of keyframe animations
  60189. */
  60190. animations?: IAnimation[];
  60191. /**
  60192. * Metadata about the glTF asset
  60193. */
  60194. asset: IAsset;
  60195. /**
  60196. * An array of buffers. A buffer points to binary geometry, animation, or skins
  60197. */
  60198. buffers?: IBuffer[];
  60199. /**
  60200. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  60201. */
  60202. bufferViews?: IBufferView[];
  60203. /**
  60204. * An array of cameras
  60205. */
  60206. cameras?: ICamera[];
  60207. /**
  60208. * Names of glTF extensions used somewhere in this asset
  60209. */
  60210. extensionsUsed?: string[];
  60211. /**
  60212. * Names of glTF extensions required to properly load this asset
  60213. */
  60214. extensionsRequired?: string[];
  60215. /**
  60216. * An array of images. An image defines data used to create a texture
  60217. */
  60218. images?: IImage[];
  60219. /**
  60220. * An array of materials. A material defines the appearance of a primitive
  60221. */
  60222. materials?: IMaterial[];
  60223. /**
  60224. * An array of meshes. A mesh is a set of primitives to be rendered
  60225. */
  60226. meshes?: IMesh[];
  60227. /**
  60228. * An array of nodes
  60229. */
  60230. nodes?: INode[];
  60231. /**
  60232. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  60233. */
  60234. samplers?: ISampler[];
  60235. /**
  60236. * The index of the default scene
  60237. */
  60238. scene?: number;
  60239. /**
  60240. * An array of scenes
  60241. */
  60242. scenes?: IScene[];
  60243. /**
  60244. * An array of skins. A skin is defined by joints and matrices
  60245. */
  60246. skins?: ISkin[];
  60247. /**
  60248. * An array of textures
  60249. */
  60250. textures?: ITexture[];
  60251. }
  60252. /**
  60253. * Interface for glTF validation results
  60254. */
  60255. interface IGLTFValidationResults {
  60256. info: {
  60257. generator: string;
  60258. hasAnimations: boolean;
  60259. hasDefaultScene: boolean;
  60260. hasMaterials: boolean;
  60261. hasMorphTargets: boolean;
  60262. hasSkins: boolean;
  60263. hasTextures: boolean;
  60264. maxAttributesUsed: number;
  60265. primitivesCount: number
  60266. };
  60267. issues: {
  60268. messages: Array<string>;
  60269. numErrors: number;
  60270. numHints: number;
  60271. numInfos: number;
  60272. numWarnings: number;
  60273. truncated: boolean
  60274. };
  60275. mimeType: string;
  60276. uri: string;
  60277. validatedAt: string;
  60278. validatorVersion: string;
  60279. }
  60280. /**
  60281. * Interface for glTF validation options
  60282. */
  60283. interface IGLTFValidationOptions {
  60284. uri?: string;
  60285. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  60286. validateAccessorData?: boolean;
  60287. maxIssues?: number;
  60288. ignoredIssues?: Array<string>;
  60289. severityOverrides?: Object;
  60290. }
  60291. /**
  60292. * glTF validator object Tyyings
  60293. */
  60294. interface IGLTFValidatorTypings {
  60295. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  60296. }
  60297. }
  60298. /**
  60299. * Interface for glTF validation results
  60300. */
  60301. interface IGLTFValidationResults {
  60302. info: {
  60303. generator: string;
  60304. hasAnimations: boolean;
  60305. hasDefaultScene: boolean;
  60306. hasMaterials: boolean;
  60307. hasMorphTargets: boolean;
  60308. hasSkins: boolean;
  60309. hasTextures: boolean;
  60310. maxAttributesUsed: number;
  60311. primitivesCount: number
  60312. };
  60313. issues: {
  60314. messages: Array<string>;
  60315. numErrors: number;
  60316. numHints: number;
  60317. numInfos: number;
  60318. numWarnings: number;
  60319. truncated: boolean
  60320. };
  60321. mimeType: string;
  60322. uri: string;
  60323. validatedAt: string;
  60324. validatorVersion: string;
  60325. }
  60326. /**
  60327. * Interface for glTF validation options
  60328. */
  60329. interface IGLTFValidationOptions {
  60330. uri?: string;
  60331. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  60332. validateAccessorData?: boolean;
  60333. maxIssues?: number;
  60334. ignoredIssues?: Array<string>;
  60335. severityOverrides?: Object;
  60336. }
  60337. /**
  60338. * glTF validator object Tyyings
  60339. */
  60340. interface IGLTFValidatorTypings {
  60341. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  60342. }
  60343. declare module BABYLON {
  60344. /** @hidden */
  60345. export var cellPixelShader: {
  60346. name: string;
  60347. shader: string;
  60348. };
  60349. }
  60350. declare module BABYLON {
  60351. /** @hidden */
  60352. export var cellVertexShader: {
  60353. name: string;
  60354. shader: string;
  60355. };
  60356. }
  60357. declare module BABYLON {
  60358. export class CellMaterial extends BABYLON.PushMaterial {
  60359. private _diffuseTexture;
  60360. diffuseTexture: BABYLON.BaseTexture;
  60361. diffuseColor: BABYLON.Color3; computeHighLevel: boolean;
  60362. computeHighLevel: boolean;
  60363. private _disableLighting;
  60364. disableLighting: boolean;
  60365. private _maxSimultaneousLights;
  60366. maxSimultaneousLights: number;
  60367. private _renderId;
  60368. constructor(name: string, scene: BABYLON.Scene);
  60369. needAlphaBlending(): boolean;
  60370. needAlphaTesting(): boolean;
  60371. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60372. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60373. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60374. getAnimatables(): BABYLON.IAnimatable[];
  60375. getActiveTextures(): BABYLON.BaseTexture[];
  60376. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60377. dispose(forceDisposeEffect?: boolean): void;
  60378. getClassName(): string;
  60379. clone(name: string): CellMaterial;
  60380. serialize(): any;
  60381. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  60382. }
  60383. }
  60384. declare module BABYLON {
  60385. export class CustomShaderStructure {
  60386. FragmentStore: string;
  60387. VertexStore: string;
  60388. constructor();
  60389. }
  60390. export class ShaderSpecialParts {
  60391. constructor();
  60392. Fragment_Begin: string;
  60393. Fragment_Definitions: string;
  60394. Fragment_MainBegin: string;
  60395. Fragment_Custom_Diffuse: string;
  60396. Fragment_Custom_Alpha: string;
  60397. Fragment_Before_FragColor: string;
  60398. Vertex_Begin: string;
  60399. Vertex_Definitions: string;
  60400. Vertex_MainBegin: string;
  60401. Vertex_Before_PositionUpdated: string;
  60402. Vertex_Before_NormalUpdated: string;
  60403. }
  60404. export class CustomMaterial extends BABYLON.StandardMaterial {
  60405. static ShaderIndexer: number;
  60406. CustomParts: ShaderSpecialParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  60407. FragmentShader: string;
  60408. VertexShader: string;
  60409. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  60410. ReviewUniform(name: string, arr: string[]): string[];
  60411. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  60412. constructor(name: string, scene: BABYLON.Scene);
  60413. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  60414. Fragment_Begin(shaderPart: string): CustomMaterial;
  60415. Fragment_Definitions(shaderPart: string): CustomMaterial;
  60416. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  60417. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  60418. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  60419. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  60420. Vertex_Begin(shaderPart: string): CustomMaterial;
  60421. Vertex_Definitions(shaderPart: string): CustomMaterial;
  60422. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  60423. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  60424. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  60425. }
  60426. }
  60427. declare module BABYLON {
  60428. /** @hidden */
  60429. export var firePixelShader: {
  60430. name: string;
  60431. shader: string;
  60432. };
  60433. }
  60434. declare module BABYLON {
  60435. /** @hidden */
  60436. export var fireVertexShader: {
  60437. name: string;
  60438. shader: string;
  60439. };
  60440. }
  60441. declare module BABYLON {
  60442. export class FireMaterial extends BABYLON.PushMaterial {
  60443. private _diffuseTexture;
  60444. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  60445. private _distortionTexture;
  60446. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  60447. private _opacityTexture;
  60448. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  60449. diffuseColor: BABYLON.Color3;
  60450. speed: number;
  60451. private _scaledDiffuse;
  60452. private _renderId;
  60453. private _lastTime;
  60454. constructor(name: string, scene: BABYLON.Scene);
  60455. needAlphaBlending(): boolean;
  60456. needAlphaTesting(): boolean;
  60457. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60458. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60459. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60460. getAnimatables(): BABYLON.IAnimatable[];
  60461. getActiveTextures(): BABYLON.BaseTexture[];
  60462. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60463. getClassName(): string;
  60464. dispose(forceDisposeEffect?: boolean): void;
  60465. clone(name: string): FireMaterial;
  60466. serialize(): any;
  60467. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  60468. }
  60469. }
  60470. declare module BABYLON {
  60471. /** @hidden */
  60472. export var furPixelShader: {
  60473. name: string;
  60474. shader: string;
  60475. };
  60476. }
  60477. declare module BABYLON {
  60478. /** @hidden */
  60479. export var furVertexShader: {
  60480. name: string;
  60481. shader: string;
  60482. };
  60483. }
  60484. declare module BABYLON {
  60485. export class FurMaterial extends BABYLON.PushMaterial {
  60486. private _diffuseTexture;
  60487. diffuseTexture: BABYLON.BaseTexture;
  60488. private _heightTexture;
  60489. heightTexture: BABYLON.BaseTexture;
  60490. diffuseColor: BABYLON.Color3;
  60491. furLength: number;
  60492. furAngle: number;
  60493. furColor: BABYLON.Color3;
  60494. furOffset: number;
  60495. furSpacing: number;
  60496. furGravity: BABYLON.Vector3;
  60497. furSpeed: number;
  60498. furDensity: number;
  60499. furOcclusion: number;
  60500. furTexture: BABYLON.DynamicTexture;
  60501. private _disableLighting;
  60502. disableLighting: boolean;
  60503. private _maxSimultaneousLights;
  60504. maxSimultaneousLights: number;
  60505. highLevelFur: boolean; meshes: BABYLON.AbstractMesh[];
  60506. private _renderId;
  60507. private _furTime;
  60508. constructor(name: string, scene: BABYLON.Scene);
  60509. furTime: number;
  60510. needAlphaBlending(): boolean;
  60511. needAlphaTesting(): boolean;
  60512. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60513. updateFur(): void;
  60514. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60515. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60516. getAnimatables(): BABYLON.IAnimatable[];
  60517. getActiveTextures(): BABYLON.BaseTexture[];
  60518. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60519. dispose(forceDisposeEffect?: boolean): void;
  60520. clone(name: string): FurMaterial;
  60521. serialize(): any;
  60522. getClassName(): string;
  60523. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  60524. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  60525. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  60526. }
  60527. }
  60528. declare module BABYLON {
  60529. /** @hidden */
  60530. export var gradientPixelShader: {
  60531. name: string;
  60532. shader: string;
  60533. };
  60534. }
  60535. declare module BABYLON {
  60536. /** @hidden */
  60537. export var gradientVertexShader: {
  60538. name: string;
  60539. shader: string;
  60540. };
  60541. }
  60542. declare module BABYLON {
  60543. export class GradientMaterial extends BABYLON.PushMaterial {
  60544. private _maxSimultaneousLights;
  60545. maxSimultaneousLights: number;
  60546. topColor: BABYLON.Color3;
  60547. topColorAlpha: number;
  60548. bottomColor: BABYLON.Color3;
  60549. bottomColorAlpha: number;
  60550. offset: number;
  60551. scale: number;
  60552. smoothness: number;
  60553. private _disableLighting;
  60554. disableLighting: boolean;
  60555. private _renderId;
  60556. constructor(name: string, scene: BABYLON.Scene);
  60557. needAlphaBlending(): boolean;
  60558. needAlphaTesting(): boolean;
  60559. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60560. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60561. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60562. getAnimatables(): BABYLON.IAnimatable[];
  60563. dispose(forceDisposeEffect?: boolean): void;
  60564. clone(name: string): GradientMaterial;
  60565. serialize(): any;
  60566. getClassName(): string;
  60567. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  60568. }
  60569. }
  60570. declare module BABYLON {
  60571. /** @hidden */
  60572. export var gridPixelShader: {
  60573. name: string;
  60574. shader: string;
  60575. };
  60576. }
  60577. declare module BABYLON {
  60578. /** @hidden */
  60579. export var gridVertexShader: {
  60580. name: string;
  60581. shader: string;
  60582. };
  60583. }
  60584. declare module BABYLON {
  60585. /**
  60586. * The grid materials allows you to wrap any shape with a grid.
  60587. * Colors are customizable.
  60588. */
  60589. export class GridMaterial extends BABYLON.PushMaterial {
  60590. /**
  60591. * Main color of the grid (e.g. between lines)
  60592. */
  60593. mainColor: BABYLON.Color3;
  60594. /**
  60595. * Color of the grid lines.
  60596. */
  60597. lineColor: BABYLON.Color3;
  60598. /**
  60599. * The scale of the grid compared to unit.
  60600. */
  60601. gridRatio: number;
  60602. /**
  60603. * Allows setting an offset for the grid lines.
  60604. */
  60605. gridOffset: BABYLON.Vector3;
  60606. /**
  60607. * The frequency of thicker lines.
  60608. */
  60609. majorUnitFrequency: number;
  60610. /**
  60611. * The visibility of minor units in the grid.
  60612. */
  60613. minorUnitVisibility: number;
  60614. /**
  60615. * The grid opacity outside of the lines.
  60616. */
  60617. opacity: number;
  60618. /**
  60619. * Determine RBG output is premultiplied by alpha value.
  60620. */
  60621. preMultiplyAlpha: boolean;
  60622. private _opacityTexture;
  60623. opacityTexture: BABYLON.BaseTexture;
  60624. private _gridControl;
  60625. private _renderId;
  60626. /**
  60627. * constructor
  60628. * @param name The name given to the material in order to identify it afterwards.
  60629. * @param scene The scene the material is used in.
  60630. */
  60631. constructor(name: string, scene: BABYLON.Scene);
  60632. /**
  60633. * Returns wehter or not the grid requires alpha blending.
  60634. */
  60635. needAlphaBlending(): boolean;
  60636. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  60637. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60638. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60639. /**
  60640. * Dispose the material and its associated resources.
  60641. * @param forceDisposeEffect will also dispose the used effect when true
  60642. */
  60643. dispose(forceDisposeEffect?: boolean): void;
  60644. clone(name: string): GridMaterial;
  60645. serialize(): any;
  60646. getClassName(): string;
  60647. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  60648. }
  60649. }
  60650. declare module BABYLON {
  60651. /** @hidden */
  60652. export var lavaPixelShader: {
  60653. name: string;
  60654. shader: string;
  60655. };
  60656. }
  60657. declare module BABYLON {
  60658. /** @hidden */
  60659. export var lavaVertexShader: {
  60660. name: string;
  60661. shader: string;
  60662. };
  60663. }
  60664. declare module BABYLON {
  60665. export class LavaMaterial extends BABYLON.PushMaterial {
  60666. private _diffuseTexture;
  60667. diffuseTexture: BABYLON.BaseTexture;
  60668. noiseTexture: BABYLON.BaseTexture;
  60669. fogColor: BABYLON.Color3;
  60670. speed: number;
  60671. movingSpeed: number;
  60672. lowFrequencySpeed: number;
  60673. fogDensity: number;
  60674. private _lastTime;
  60675. diffuseColor: BABYLON.Color3;
  60676. private _disableLighting;
  60677. disableLighting: boolean;
  60678. private _unlit;
  60679. unlit: boolean;
  60680. private _maxSimultaneousLights;
  60681. maxSimultaneousLights: number;
  60682. private _scaledDiffuse;
  60683. private _renderId;
  60684. constructor(name: string, scene: BABYLON.Scene);
  60685. needAlphaBlending(): boolean;
  60686. needAlphaTesting(): boolean;
  60687. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60688. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60689. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60690. getAnimatables(): BABYLON.IAnimatable[];
  60691. getActiveTextures(): BABYLON.BaseTexture[];
  60692. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60693. dispose(forceDisposeEffect?: boolean): void;
  60694. clone(name: string): LavaMaterial;
  60695. serialize(): any;
  60696. getClassName(): string;
  60697. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  60698. }
  60699. }
  60700. declare module BABYLON {
  60701. /** @hidden */
  60702. export var mixPixelShader: {
  60703. name: string;
  60704. shader: string;
  60705. };
  60706. }
  60707. declare module BABYLON {
  60708. /** @hidden */
  60709. export var mixVertexShader: {
  60710. name: string;
  60711. shader: string;
  60712. };
  60713. }
  60714. declare module BABYLON {
  60715. export class MixMaterial extends BABYLON.PushMaterial {
  60716. /**
  60717. * Mix textures
  60718. */
  60719. private _mixTexture1;
  60720. mixTexture1: BABYLON.BaseTexture;
  60721. private _mixTexture2;
  60722. mixTexture2: BABYLON.BaseTexture;
  60723. /**
  60724. * Diffuse textures
  60725. */
  60726. private _diffuseTexture1;
  60727. diffuseTexture1: BABYLON.Texture;
  60728. private _diffuseTexture2;
  60729. diffuseTexture2: BABYLON.Texture;
  60730. private _diffuseTexture3;
  60731. diffuseTexture3: BABYLON.Texture;
  60732. private _diffuseTexture4;
  60733. diffuseTexture4: BABYLON.Texture;
  60734. private _diffuseTexture5;
  60735. diffuseTexture5: BABYLON.Texture;
  60736. private _diffuseTexture6;
  60737. diffuseTexture6: BABYLON.Texture;
  60738. private _diffuseTexture7;
  60739. diffuseTexture7: BABYLON.Texture;
  60740. private _diffuseTexture8;
  60741. diffuseTexture8: BABYLON.Texture;
  60742. /**
  60743. * Uniforms
  60744. */
  60745. diffuseColor: BABYLON.Color3;
  60746. specularColor: BABYLON.Color3;
  60747. specularPower: number;
  60748. private _disableLighting;
  60749. disableLighting: boolean;
  60750. private _maxSimultaneousLights;
  60751. maxSimultaneousLights: number;
  60752. private _renderId;
  60753. constructor(name: string, scene: BABYLON.Scene);
  60754. needAlphaBlending(): boolean;
  60755. needAlphaTesting(): boolean;
  60756. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60757. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60758. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60759. getAnimatables(): BABYLON.IAnimatable[];
  60760. getActiveTextures(): BABYLON.BaseTexture[];
  60761. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60762. dispose(forceDisposeEffect?: boolean): void;
  60763. clone(name: string): MixMaterial;
  60764. serialize(): any;
  60765. getClassName(): string;
  60766. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  60767. }
  60768. }
  60769. declare module BABYLON {
  60770. /** @hidden */
  60771. export var normalPixelShader: {
  60772. name: string;
  60773. shader: string;
  60774. };
  60775. }
  60776. declare module BABYLON {
  60777. /** @hidden */
  60778. export var normalVertexShader: {
  60779. name: string;
  60780. shader: string;
  60781. };
  60782. }
  60783. declare module BABYLON {
  60784. export class NormalMaterial extends BABYLON.PushMaterial {
  60785. private _diffuseTexture;
  60786. diffuseTexture: BABYLON.BaseTexture;
  60787. diffuseColor: BABYLON.Color3;
  60788. private _disableLighting;
  60789. disableLighting: boolean;
  60790. private _maxSimultaneousLights;
  60791. maxSimultaneousLights: number;
  60792. private _renderId;
  60793. constructor(name: string, scene: BABYLON.Scene);
  60794. needAlphaBlending(): boolean;
  60795. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  60796. needAlphaTesting(): boolean;
  60797. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60798. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60799. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60800. getAnimatables(): BABYLON.IAnimatable[];
  60801. getActiveTextures(): BABYLON.BaseTexture[];
  60802. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60803. dispose(forceDisposeEffect?: boolean): void;
  60804. clone(name: string): NormalMaterial;
  60805. serialize(): any;
  60806. getClassName(): string;
  60807. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  60808. }
  60809. }
  60810. declare module BABYLON {
  60811. /** @hidden */
  60812. export var shadowOnlyPixelShader: {
  60813. name: string;
  60814. shader: string;
  60815. };
  60816. }
  60817. declare module BABYLON {
  60818. /** @hidden */
  60819. export var shadowOnlyVertexShader: {
  60820. name: string;
  60821. shader: string;
  60822. };
  60823. }
  60824. declare module BABYLON {
  60825. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  60826. private _renderId;
  60827. private _activeLight;
  60828. constructor(name: string, scene: BABYLON.Scene);
  60829. shadowColor: BABYLON.Color3;
  60830. needAlphaBlending(): boolean;
  60831. needAlphaTesting(): boolean;
  60832. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60833. activeLight: BABYLON.IShadowLight;
  60834. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60835. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60836. clone(name: string): ShadowOnlyMaterial;
  60837. serialize(): any;
  60838. getClassName(): string;
  60839. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  60840. }
  60841. }
  60842. declare module BABYLON {
  60843. /** @hidden */
  60844. export var simplePixelShader: {
  60845. name: string;
  60846. shader: string;
  60847. };
  60848. }
  60849. declare module BABYLON {
  60850. /** @hidden */
  60851. export var simpleVertexShader: {
  60852. name: string;
  60853. shader: string;
  60854. };
  60855. }
  60856. declare module BABYLON {
  60857. export class SimpleMaterial extends BABYLON.PushMaterial {
  60858. private _diffuseTexture;
  60859. diffuseTexture: BABYLON.BaseTexture;
  60860. diffuseColor: BABYLON.Color3;
  60861. private _disableLighting;
  60862. disableLighting: boolean;
  60863. private _maxSimultaneousLights;
  60864. maxSimultaneousLights: number;
  60865. private _renderId;
  60866. constructor(name: string, scene: BABYLON.Scene);
  60867. needAlphaBlending(): boolean;
  60868. needAlphaTesting(): boolean;
  60869. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60870. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60871. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60872. getAnimatables(): BABYLON.IAnimatable[];
  60873. getActiveTextures(): BABYLON.BaseTexture[];
  60874. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60875. dispose(forceDisposeEffect?: boolean): void;
  60876. clone(name: string): SimpleMaterial;
  60877. serialize(): any;
  60878. getClassName(): string;
  60879. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  60880. }
  60881. }
  60882. declare module BABYLON {
  60883. /** @hidden */
  60884. export var skyPixelShader: {
  60885. name: string;
  60886. shader: string;
  60887. };
  60888. }
  60889. declare module BABYLON {
  60890. /** @hidden */
  60891. export var skyVertexShader: {
  60892. name: string;
  60893. shader: string;
  60894. };
  60895. }
  60896. declare module BABYLON {
  60897. /**
  60898. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  60899. * @see https://doc.babylonjs.com/extensions/sky
  60900. */
  60901. export class SkyMaterial extends BABYLON.PushMaterial {
  60902. /**
  60903. * Defines the overall luminance of sky in interval ]0, 1[.
  60904. */
  60905. luminance: number;
  60906. /**
  60907. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  60908. */
  60909. turbidity: number;
  60910. /**
  60911. * Defines the sky appearance (light intensity).
  60912. */
  60913. rayleigh: number;
  60914. /**
  60915. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  60916. */
  60917. mieCoefficient: number;
  60918. /**
  60919. * Defines the amount of haze particles following the Mie scattering theory.
  60920. */
  60921. mieDirectionalG: number;
  60922. /**
  60923. * Defines the distance of the sun according to the active scene camera.
  60924. */
  60925. distance: number;
  60926. /**
  60927. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  60928. * "inclined".
  60929. */
  60930. inclination: number;
  60931. /**
  60932. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  60933. * an object direction and a reference direction.
  60934. */
  60935. azimuth: number;
  60936. /**
  60937. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  60938. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  60939. */
  60940. sunPosition: BABYLON.Vector3;
  60941. /**
  60942. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  60943. * .sunPosition property.
  60944. */
  60945. useSunPosition: boolean;
  60946. /**
  60947. * Defines an offset vector used to get a horizon offset.
  60948. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  60949. */
  60950. cameraOffset: BABYLON.Vector3;
  60951. private _cameraPosition;
  60952. private _renderId;
  60953. /**
  60954. * Instantiates a new sky material.
  60955. * This material allows to create dynamic and texture free
  60956. * effects for skyboxes by taking care of the atmosphere state.
  60957. * @see https://doc.babylonjs.com/extensions/sky
  60958. * @param name Define the name of the material in the scene
  60959. * @param scene Define the scene the material belong to
  60960. */
  60961. constructor(name: string, scene: BABYLON.Scene);
  60962. /**
  60963. * Specifies if the material will require alpha blending
  60964. * @returns a boolean specifying if alpha blending is needed
  60965. */
  60966. needAlphaBlending(): boolean;
  60967. /**
  60968. * Specifies if this material should be rendered in alpha test mode
  60969. * @returns false as the sky material doesn't need alpha testing.
  60970. */
  60971. needAlphaTesting(): boolean;
  60972. /**
  60973. * Get the texture used for alpha test purpose.
  60974. * @returns null as the sky material has no texture.
  60975. */
  60976. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60977. /**
  60978. * Get if the submesh is ready to be used and all its information available.
  60979. * Child classes can use it to update shaders
  60980. * @param mesh defines the mesh to check
  60981. * @param subMesh defines which submesh to check
  60982. * @param useInstances specifies that instances should be used
  60983. * @returns a boolean indicating that the submesh is ready or not
  60984. */
  60985. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60986. /**
  60987. * Binds the submesh to this material by preparing the effect and shader to draw
  60988. * @param world defines the world transformation matrix
  60989. * @param mesh defines the mesh containing the submesh
  60990. * @param subMesh defines the submesh to bind the material to
  60991. */
  60992. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60993. /**
  60994. * Get the list of animatables in the material.
  60995. * @returns the list of animatables object used in the material
  60996. */
  60997. getAnimatables(): BABYLON.IAnimatable[];
  60998. /**
  60999. * Disposes the material
  61000. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  61001. */
  61002. dispose(forceDisposeEffect?: boolean): void;
  61003. /**
  61004. * Makes a duplicate of the material, and gives it a new name
  61005. * @param name defines the new name for the duplicated material
  61006. * @returns the cloned material
  61007. */
  61008. clone(name: string): SkyMaterial;
  61009. /**
  61010. * Serializes this material in a JSON representation
  61011. * @returns the serialized material object
  61012. */
  61013. serialize(): any;
  61014. /**
  61015. * Gets the current class name of the material e.g. "SkyMaterial"
  61016. * Mainly use in serialization.
  61017. * @returns the class name
  61018. */
  61019. getClassName(): string;
  61020. /**
  61021. * Creates a sky material from parsed material data
  61022. * @param source defines the JSON representation of the material
  61023. * @param scene defines the hosting scene
  61024. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61025. * @returns a new sky material
  61026. */
  61027. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  61028. }
  61029. }
  61030. declare module BABYLON {
  61031. /** @hidden */
  61032. export var terrainPixelShader: {
  61033. name: string;
  61034. shader: string;
  61035. };
  61036. }
  61037. declare module BABYLON {
  61038. /** @hidden */
  61039. export var terrainVertexShader: {
  61040. name: string;
  61041. shader: string;
  61042. };
  61043. }
  61044. declare module BABYLON {
  61045. export class TerrainMaterial extends BABYLON.PushMaterial {
  61046. private _mixTexture;
  61047. mixTexture: BABYLON.BaseTexture;
  61048. private _diffuseTexture1;
  61049. diffuseTexture1: BABYLON.Texture;
  61050. private _diffuseTexture2;
  61051. diffuseTexture2: BABYLON.Texture;
  61052. private _diffuseTexture3;
  61053. diffuseTexture3: BABYLON.Texture;
  61054. private _bumpTexture1;
  61055. bumpTexture1: BABYLON.Texture;
  61056. private _bumpTexture2;
  61057. bumpTexture2: BABYLON.Texture;
  61058. private _bumpTexture3;
  61059. bumpTexture3: BABYLON.Texture;
  61060. diffuseColor: BABYLON.Color3;
  61061. specularColor: BABYLON.Color3;
  61062. specularPower: number;
  61063. private _disableLighting;
  61064. disableLighting: boolean;
  61065. private _maxSimultaneousLights;
  61066. maxSimultaneousLights: number;
  61067. private _renderId;
  61068. constructor(name: string, scene: BABYLON.Scene);
  61069. needAlphaBlending(): boolean;
  61070. needAlphaTesting(): boolean;
  61071. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  61072. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  61073. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  61074. getAnimatables(): BABYLON.IAnimatable[];
  61075. getActiveTextures(): BABYLON.BaseTexture[];
  61076. hasTexture(texture: BABYLON.BaseTexture): boolean;
  61077. dispose(forceDisposeEffect?: boolean): void;
  61078. clone(name: string): TerrainMaterial;
  61079. serialize(): any;
  61080. getClassName(): string;
  61081. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  61082. }
  61083. }
  61084. declare module BABYLON {
  61085. /** @hidden */
  61086. export var triplanarPixelShader: {
  61087. name: string;
  61088. shader: string;
  61089. };
  61090. }
  61091. declare module BABYLON {
  61092. /** @hidden */
  61093. export var triplanarVertexShader: {
  61094. name: string;
  61095. shader: string;
  61096. };
  61097. }
  61098. declare module BABYLON {
  61099. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  61100. mixTexture: BABYLON.BaseTexture;
  61101. private _diffuseTextureX;
  61102. diffuseTextureX: BABYLON.BaseTexture;
  61103. private _diffuseTextureY;
  61104. diffuseTextureY: BABYLON.BaseTexture;
  61105. private _diffuseTextureZ;
  61106. diffuseTextureZ: BABYLON.BaseTexture;
  61107. private _normalTextureX;
  61108. normalTextureX: BABYLON.BaseTexture;
  61109. private _normalTextureY;
  61110. normalTextureY: BABYLON.BaseTexture;
  61111. private _normalTextureZ;
  61112. normalTextureZ: BABYLON.BaseTexture;
  61113. tileSize: number;
  61114. diffuseColor: BABYLON.Color3;
  61115. specularColor: BABYLON.Color3;
  61116. specularPower: number;
  61117. private _disableLighting;
  61118. disableLighting: boolean;
  61119. private _maxSimultaneousLights;
  61120. maxSimultaneousLights: number;
  61121. private _renderId;
  61122. constructor(name: string, scene: BABYLON.Scene);
  61123. needAlphaBlending(): boolean;
  61124. needAlphaTesting(): boolean;
  61125. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  61126. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  61127. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  61128. getAnimatables(): BABYLON.IAnimatable[];
  61129. getActiveTextures(): BABYLON.BaseTexture[];
  61130. hasTexture(texture: BABYLON.BaseTexture): boolean;
  61131. dispose(forceDisposeEffect?: boolean): void;
  61132. clone(name: string): TriPlanarMaterial;
  61133. serialize(): any;
  61134. getClassName(): string;
  61135. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  61136. }
  61137. }
  61138. declare module BABYLON {
  61139. /** @hidden */
  61140. export var waterPixelShader: {
  61141. name: string;
  61142. shader: string;
  61143. };
  61144. }
  61145. declare module BABYLON {
  61146. /** @hidden */
  61147. export var waterVertexShader: {
  61148. name: string;
  61149. shader: string;
  61150. };
  61151. }
  61152. declare module BABYLON {
  61153. export class WaterMaterial extends BABYLON.PushMaterial {
  61154. renderTargetSize: BABYLON.Vector2;
  61155. private _bumpTexture;
  61156. bumpTexture: BABYLON.BaseTexture;
  61157. diffuseColor: BABYLON.Color3;
  61158. specularColor: BABYLON.Color3;
  61159. specularPower: number;
  61160. private _disableLighting;
  61161. disableLighting: boolean;
  61162. private _maxSimultaneousLights;
  61163. maxSimultaneousLights: number;
  61164. /**
  61165. * @param {number}: Represents the wind force
  61166. */
  61167. windForce: number;
  61168. /**
  61169. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  61170. */
  61171. windDirection: BABYLON.Vector2;
  61172. /**
  61173. * @param {number}: Wave height, represents the height of the waves
  61174. */
  61175. waveHeight: number;
  61176. /**
  61177. * @param {number}: Bump height, represents the bump height related to the bump map
  61178. */
  61179. bumpHeight: number;
  61180. /**
  61181. * @param {boolean}: Add a smaller moving bump to less steady waves.
  61182. */
  61183. private _bumpSuperimpose;
  61184. bumpSuperimpose: boolean;
  61185. /**
  61186. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  61187. */
  61188. private _fresnelSeparate;
  61189. fresnelSeparate: boolean;
  61190. /**
  61191. * @param {boolean}: bump Waves modify the reflection.
  61192. */
  61193. private _bumpAffectsReflection;
  61194. bumpAffectsReflection: boolean;
  61195. /**
  61196. * @param {number}: The water color blended with the refraction (near)
  61197. */
  61198. waterColor: BABYLON.Color3;
  61199. /**
  61200. * @param {number}: The blend factor related to the water color
  61201. */
  61202. colorBlendFactor: number;
  61203. /**
  61204. * @param {number}: The water color blended with the reflection (far)
  61205. */
  61206. waterColor2: BABYLON.Color3;
  61207. /**
  61208. * @param {number}: The blend factor related to the water color (reflection, far)
  61209. */
  61210. colorBlendFactor2: number;
  61211. /**
  61212. * @param {number}: Represents the maximum length of a wave
  61213. */
  61214. waveLength: number;
  61215. /**
  61216. * @param {number}: Defines the waves speed
  61217. */
  61218. waveSpeed: number;
  61219. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  61220. private _mesh;
  61221. private _refractionRTT;
  61222. private _reflectionRTT;
  61223. private _reflectionTransform;
  61224. private _lastTime;
  61225. private _lastDeltaTime;
  61226. private _renderId;
  61227. private _useLogarithmicDepth;
  61228. private _waitingRenderList;
  61229. /**
  61230. * Gets a boolean indicating that current material needs to register RTT
  61231. */
  61232. readonly hasRenderTargetTextures: boolean;
  61233. /**
  61234. * Constructor
  61235. */
  61236. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  61237. useLogarithmicDepth: boolean;
  61238. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  61239. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  61240. addToRenderList(node: any): void;
  61241. enableRenderTargets(enable: boolean): void;
  61242. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  61243. readonly renderTargetsEnabled: boolean;
  61244. needAlphaBlending(): boolean;
  61245. needAlphaTesting(): boolean;
  61246. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  61247. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  61248. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  61249. private _createRenderTargets;
  61250. getAnimatables(): BABYLON.IAnimatable[];
  61251. getActiveTextures(): BABYLON.BaseTexture[];
  61252. hasTexture(texture: BABYLON.BaseTexture): boolean;
  61253. dispose(forceDisposeEffect?: boolean): void;
  61254. clone(name: string): WaterMaterial;
  61255. serialize(): any;
  61256. getClassName(): string;
  61257. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  61258. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  61259. }
  61260. }
  61261. declare module BABYLON {
  61262. /** @hidden */
  61263. export var asciiartPixelShader: {
  61264. name: string;
  61265. shader: string;
  61266. };
  61267. }
  61268. declare module BABYLON {
  61269. /**
  61270. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  61271. *
  61272. * It basically takes care rendering the font front the given font size to a texture.
  61273. * This is used later on in the postprocess.
  61274. */
  61275. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  61276. private _font;
  61277. private _text;
  61278. private _charSize;
  61279. /**
  61280. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  61281. */
  61282. readonly charSize: number;
  61283. /**
  61284. * Create a new instance of the Ascii Art FontTexture class
  61285. * @param name the name of the texture
  61286. * @param font the font to use, use the W3C CSS notation
  61287. * @param text the caracter set to use in the rendering.
  61288. * @param scene the scene that owns the texture
  61289. */
  61290. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  61291. /**
  61292. * Gets the max char width of a font.
  61293. * @param font the font to use, use the W3C CSS notation
  61294. * @return the max char width
  61295. */
  61296. private getFontWidth;
  61297. /**
  61298. * Gets the max char height of a font.
  61299. * @param font the font to use, use the W3C CSS notation
  61300. * @return the max char height
  61301. */
  61302. private getFontHeight;
  61303. /**
  61304. * Clones the current AsciiArtTexture.
  61305. * @return the clone of the texture.
  61306. */
  61307. clone(): AsciiArtFontTexture;
  61308. /**
  61309. * Parses a json object representing the texture and returns an instance of it.
  61310. * @param source the source JSON representation
  61311. * @param scene the scene to create the texture for
  61312. * @return the parsed texture
  61313. */
  61314. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  61315. }
  61316. /**
  61317. * Option available in the Ascii Art Post Process.
  61318. */
  61319. export interface IAsciiArtPostProcessOptions {
  61320. /**
  61321. * The font to use following the w3c font definition.
  61322. */
  61323. font?: string;
  61324. /**
  61325. * The character set to use in the postprocess.
  61326. */
  61327. characterSet?: string;
  61328. /**
  61329. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  61330. * This number is defined between 0 and 1;
  61331. */
  61332. mixToTile?: number;
  61333. /**
  61334. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  61335. * This number is defined between 0 and 1;
  61336. */
  61337. mixToNormal?: number;
  61338. }
  61339. /**
  61340. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  61341. *
  61342. * Simmply add it to your scene and let the nerd that lives in you have fun.
  61343. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  61344. */
  61345. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  61346. /**
  61347. * The font texture used to render the char in the post process.
  61348. */
  61349. private _asciiArtFontTexture;
  61350. /**
  61351. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  61352. * This number is defined between 0 and 1;
  61353. */
  61354. mixToTile: number;
  61355. /**
  61356. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  61357. * This number is defined between 0 and 1;
  61358. */
  61359. mixToNormal: number;
  61360. /**
  61361. * Instantiates a new Ascii Art Post Process.
  61362. * @param name the name to give to the postprocess
  61363. * @camera the camera to apply the post process to.
  61364. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  61365. */
  61366. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  61367. }
  61368. }
  61369. declare module BABYLON {
  61370. /** @hidden */
  61371. export var digitalrainPixelShader: {
  61372. name: string;
  61373. shader: string;
  61374. };
  61375. }
  61376. declare module BABYLON {
  61377. /**
  61378. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  61379. *
  61380. * It basically takes care rendering the font front the given font size to a texture.
  61381. * This is used later on in the postprocess.
  61382. */
  61383. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  61384. private _font;
  61385. private _text;
  61386. private _charSize;
  61387. /**
  61388. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  61389. */
  61390. readonly charSize: number;
  61391. /**
  61392. * Create a new instance of the Digital Rain FontTexture class
  61393. * @param name the name of the texture
  61394. * @param font the font to use, use the W3C CSS notation
  61395. * @param text the caracter set to use in the rendering.
  61396. * @param scene the scene that owns the texture
  61397. */
  61398. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  61399. /**
  61400. * Gets the max char width of a font.
  61401. * @param font the font to use, use the W3C CSS notation
  61402. * @return the max char width
  61403. */
  61404. private getFontWidth;
  61405. /**
  61406. * Gets the max char height of a font.
  61407. * @param font the font to use, use the W3C CSS notation
  61408. * @return the max char height
  61409. */
  61410. private getFontHeight;
  61411. /**
  61412. * Clones the current DigitalRainFontTexture.
  61413. * @return the clone of the texture.
  61414. */
  61415. clone(): DigitalRainFontTexture;
  61416. /**
  61417. * Parses a json object representing the texture and returns an instance of it.
  61418. * @param source the source JSON representation
  61419. * @param scene the scene to create the texture for
  61420. * @return the parsed texture
  61421. */
  61422. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  61423. }
  61424. /**
  61425. * Option available in the Digital Rain Post Process.
  61426. */
  61427. export interface IDigitalRainPostProcessOptions {
  61428. /**
  61429. * The font to use following the w3c font definition.
  61430. */
  61431. font?: string;
  61432. /**
  61433. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  61434. * This number is defined between 0 and 1;
  61435. */
  61436. mixToTile?: number;
  61437. /**
  61438. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  61439. * This number is defined between 0 and 1;
  61440. */
  61441. mixToNormal?: number;
  61442. }
  61443. /**
  61444. * DigitalRainPostProcess helps rendering everithing in digital rain.
  61445. *
  61446. * Simmply add it to your scene and let the nerd that lives in you have fun.
  61447. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  61448. */
  61449. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  61450. /**
  61451. * The font texture used to render the char in the post process.
  61452. */
  61453. private _digitalRainFontTexture;
  61454. /**
  61455. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  61456. * This number is defined between 0 and 1;
  61457. */
  61458. mixToTile: number;
  61459. /**
  61460. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  61461. * This number is defined between 0 and 1;
  61462. */
  61463. mixToNormal: number;
  61464. /**
  61465. * Instantiates a new Digital Rain Post Process.
  61466. * @param name the name to give to the postprocess
  61467. * @camera the camera to apply the post process to.
  61468. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  61469. */
  61470. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  61471. }
  61472. }
  61473. declare module BABYLON {
  61474. /** @hidden */
  61475. export var brickProceduralTexturePixelShader: {
  61476. name: string;
  61477. shader: string;
  61478. };
  61479. }
  61480. declare module BABYLON {
  61481. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  61482. private _numberOfBricksHeight;
  61483. private _numberOfBricksWidth;
  61484. private _jointColor;
  61485. private _brickColor;
  61486. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61487. updateShaderUniforms(): void;
  61488. numberOfBricksHeight: number;
  61489. numberOfBricksWidth: number;
  61490. jointColor: BABYLON.Color3;
  61491. brickColor: BABYLON.Color3;
  61492. /**
  61493. * Serializes this brick procedural texture
  61494. * @returns a serialized brick procedural texture object
  61495. */
  61496. serialize(): any;
  61497. /**
  61498. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  61499. * @param parsedTexture defines parsed texture data
  61500. * @param scene defines the current scene
  61501. * @param rootUrl defines the root URL containing brick procedural texture information
  61502. * @returns a parsed Brick Procedural BABYLON.Texture
  61503. */
  61504. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  61505. }
  61506. }
  61507. declare module BABYLON {
  61508. /** @hidden */
  61509. export var cloudProceduralTexturePixelShader: {
  61510. name: string;
  61511. shader: string;
  61512. };
  61513. }
  61514. declare module BABYLON {
  61515. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  61516. private _skyColor;
  61517. private _cloudColor;
  61518. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61519. updateShaderUniforms(): void;
  61520. skyColor: BABYLON.Color4;
  61521. cloudColor: BABYLON.Color4;
  61522. /**
  61523. * Serializes this cloud procedural texture
  61524. * @returns a serialized cloud procedural texture object
  61525. */
  61526. serialize(): any;
  61527. /**
  61528. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  61529. * @param parsedTexture defines parsed texture data
  61530. * @param scene defines the current scene
  61531. * @param rootUrl defines the root URL containing cloud procedural texture information
  61532. * @returns a parsed Cloud Procedural BABYLON.Texture
  61533. */
  61534. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  61535. }
  61536. }
  61537. declare module BABYLON {
  61538. /** @hidden */
  61539. export var fireProceduralTexturePixelShader: {
  61540. name: string;
  61541. shader: string;
  61542. };
  61543. }
  61544. declare module BABYLON {
  61545. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  61546. private _time;
  61547. private _speed;
  61548. private _autoGenerateTime;
  61549. private _fireColors;
  61550. private _alphaThreshold;
  61551. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61552. updateShaderUniforms(): void;
  61553. render(useCameraPostProcess?: boolean): void;
  61554. static readonly PurpleFireColors: BABYLON.Color3[];
  61555. static readonly GreenFireColors: BABYLON.Color3[];
  61556. static readonly RedFireColors: BABYLON.Color3[];
  61557. static readonly BlueFireColors: BABYLON.Color3[];
  61558. autoGenerateTime: boolean;
  61559. fireColors: BABYLON.Color3[];
  61560. time: number;
  61561. speed: BABYLON.Vector2;
  61562. alphaThreshold: number;
  61563. /**
  61564. * Serializes this fire procedural texture
  61565. * @returns a serialized fire procedural texture object
  61566. */
  61567. serialize(): any;
  61568. /**
  61569. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  61570. * @param parsedTexture defines parsed texture data
  61571. * @param scene defines the current scene
  61572. * @param rootUrl defines the root URL containing fire procedural texture information
  61573. * @returns a parsed Fire Procedural BABYLON.Texture
  61574. */
  61575. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  61576. }
  61577. }
  61578. declare module BABYLON {
  61579. /** @hidden */
  61580. export var grassProceduralTexturePixelShader: {
  61581. name: string;
  61582. shader: string;
  61583. };
  61584. }
  61585. declare module BABYLON {
  61586. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  61587. private _grassColors;
  61588. private _groundColor;
  61589. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61590. updateShaderUniforms(): void;
  61591. grassColors: BABYLON.Color3[];
  61592. groundColor: BABYLON.Color3;
  61593. /**
  61594. * Serializes this grass procedural texture
  61595. * @returns a serialized grass procedural texture object
  61596. */
  61597. serialize(): any;
  61598. /**
  61599. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  61600. * @param parsedTexture defines parsed texture data
  61601. * @param scene defines the current scene
  61602. * @param rootUrl defines the root URL containing grass procedural texture information
  61603. * @returns a parsed Grass Procedural BABYLON.Texture
  61604. */
  61605. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  61606. }
  61607. }
  61608. declare module BABYLON {
  61609. /** @hidden */
  61610. export var marbleProceduralTexturePixelShader: {
  61611. name: string;
  61612. shader: string;
  61613. };
  61614. }
  61615. declare module BABYLON {
  61616. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  61617. private _numberOfTilesHeight;
  61618. private _numberOfTilesWidth;
  61619. private _amplitude;
  61620. private _jointColor;
  61621. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61622. updateShaderUniforms(): void;
  61623. numberOfTilesHeight: number;
  61624. amplitude: number;
  61625. numberOfTilesWidth: number;
  61626. jointColor: BABYLON.Color3;
  61627. /**
  61628. * Serializes this marble procedural texture
  61629. * @returns a serialized marble procedural texture object
  61630. */
  61631. serialize(): any;
  61632. /**
  61633. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  61634. * @param parsedTexture defines parsed texture data
  61635. * @param scene defines the current scene
  61636. * @param rootUrl defines the root URL containing marble procedural texture information
  61637. * @returns a parsed Marble Procedural BABYLON.Texture
  61638. */
  61639. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  61640. }
  61641. }
  61642. declare module BABYLON {
  61643. /** @hidden */
  61644. export var normalMapProceduralTexturePixelShader: {
  61645. name: string;
  61646. shader: string;
  61647. };
  61648. }
  61649. declare module BABYLON {
  61650. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  61651. private _baseTexture;
  61652. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61653. updateShaderUniforms(): void;
  61654. render(useCameraPostProcess?: boolean): void;
  61655. resize(size: any, generateMipMaps: any): void;
  61656. baseTexture: BABYLON.Texture;
  61657. /**
  61658. * Serializes this normal map procedural texture
  61659. * @returns a serialized normal map procedural texture object
  61660. */
  61661. serialize(): any;
  61662. /**
  61663. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  61664. * @param parsedTexture defines parsed texture data
  61665. * @param scene defines the current scene
  61666. * @param rootUrl defines the root URL containing normal map procedural texture information
  61667. * @returns a parsed Normal Map Procedural BABYLON.Texture
  61668. */
  61669. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  61670. }
  61671. }
  61672. declare module BABYLON {
  61673. /** @hidden */
  61674. export var perlinNoiseProceduralTexturePixelShader: {
  61675. name: string;
  61676. shader: string;
  61677. };
  61678. }
  61679. declare module BABYLON {
  61680. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  61681. time: number;
  61682. timeScale: number;
  61683. translationSpeed: number;
  61684. private _currentTranslation;
  61685. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61686. updateShaderUniforms(): void;
  61687. render(useCameraPostProcess?: boolean): void;
  61688. resize(size: any, generateMipMaps: any): void;
  61689. /**
  61690. * Serializes this perlin noise procedural texture
  61691. * @returns a serialized perlin noise procedural texture object
  61692. */
  61693. serialize(): any;
  61694. /**
  61695. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  61696. * @param parsedTexture defines parsed texture data
  61697. * @param scene defines the current scene
  61698. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  61699. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  61700. */
  61701. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  61702. }
  61703. }
  61704. declare module BABYLON {
  61705. /** @hidden */
  61706. export var roadProceduralTexturePixelShader: {
  61707. name: string;
  61708. shader: string;
  61709. };
  61710. }
  61711. declare module BABYLON {
  61712. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  61713. private _roadColor;
  61714. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61715. updateShaderUniforms(): void;
  61716. roadColor: BABYLON.Color3;
  61717. /**
  61718. * Serializes this road procedural texture
  61719. * @returns a serialized road procedural texture object
  61720. */
  61721. serialize(): any;
  61722. /**
  61723. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  61724. * @param parsedTexture defines parsed texture data
  61725. * @param scene defines the current scene
  61726. * @param rootUrl defines the root URL containing road procedural texture information
  61727. * @returns a parsed Road Procedural BABYLON.Texture
  61728. */
  61729. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  61730. }
  61731. }
  61732. declare module BABYLON {
  61733. /** @hidden */
  61734. export var starfieldProceduralTexturePixelShader: {
  61735. name: string;
  61736. shader: string;
  61737. };
  61738. }
  61739. declare module BABYLON {
  61740. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  61741. private _time;
  61742. private _alpha;
  61743. private _beta;
  61744. private _zoom;
  61745. private _formuparam;
  61746. private _stepsize;
  61747. private _tile;
  61748. private _brightness;
  61749. private _darkmatter;
  61750. private _distfading;
  61751. private _saturation;
  61752. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61753. updateShaderUniforms(): void;
  61754. time: number;
  61755. alpha: number;
  61756. beta: number;
  61757. formuparam: number;
  61758. stepsize: number;
  61759. zoom: number;
  61760. tile: number;
  61761. brightness: number;
  61762. darkmatter: number;
  61763. distfading: number;
  61764. saturation: number;
  61765. /**
  61766. * Serializes this starfield procedural texture
  61767. * @returns a serialized starfield procedural texture object
  61768. */
  61769. serialize(): any;
  61770. /**
  61771. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  61772. * @param parsedTexture defines parsed texture data
  61773. * @param scene defines the current scene
  61774. * @param rootUrl defines the root URL containing startfield procedural texture information
  61775. * @returns a parsed Starfield Procedural BABYLON.Texture
  61776. */
  61777. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  61778. }
  61779. }
  61780. declare module BABYLON {
  61781. /** @hidden */
  61782. export var woodProceduralTexturePixelShader: {
  61783. name: string;
  61784. shader: string;
  61785. };
  61786. }
  61787. declare module BABYLON {
  61788. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  61789. private _ampScale;
  61790. private _woodColor;
  61791. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61792. updateShaderUniforms(): void;
  61793. ampScale: number;
  61794. woodColor: BABYLON.Color3;
  61795. /**
  61796. * Serializes this wood procedural texture
  61797. * @returns a serialized wood procedural texture object
  61798. */
  61799. serialize(): any;
  61800. /**
  61801. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  61802. * @param parsedTexture defines parsed texture data
  61803. * @param scene defines the current scene
  61804. * @param rootUrl defines the root URL containing wood procedural texture information
  61805. * @returns a parsed Wood Procedural BABYLON.Texture
  61806. */
  61807. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  61808. }
  61809. }