babylon.d.txt 2.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938
  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. /** @hidden */
  4957. export class _DevTools {
  4958. static WarnImport(name: string): string;
  4959. }
  4960. }
  4961. declare module BABYLON {
  4962. /**
  4963. * Class used to evalaute queries containing `and` and `or` operators
  4964. */
  4965. export class AndOrNotEvaluator {
  4966. /**
  4967. * Evaluate a query
  4968. * @param query defines the query to evaluate
  4969. * @param evaluateCallback defines the callback used to filter result
  4970. * @returns true if the query matches
  4971. */
  4972. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4973. private static _HandleParenthesisContent;
  4974. private static _SimplifyNegation;
  4975. }
  4976. }
  4977. declare module BABYLON {
  4978. /**
  4979. * Class used to store custom tags
  4980. */
  4981. export class Tags {
  4982. /**
  4983. * Adds support for tags on the given object
  4984. * @param obj defines the object to use
  4985. */
  4986. static EnableFor(obj: any): void;
  4987. /**
  4988. * Removes tags support
  4989. * @param obj defines the object to use
  4990. */
  4991. static DisableFor(obj: any): void;
  4992. /**
  4993. * Gets a boolean indicating if the given object has tags
  4994. * @param obj defines the object to use
  4995. * @returns a boolean
  4996. */
  4997. static HasTags(obj: any): boolean;
  4998. /**
  4999. * Gets the tags available on a given object
  5000. * @param obj defines the object to use
  5001. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5002. * @returns the tags
  5003. */
  5004. static GetTags(obj: any, asString?: boolean): any;
  5005. /**
  5006. * Adds tags to an object
  5007. * @param obj defines the object to use
  5008. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5009. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5010. */
  5011. static AddTagsTo(obj: any, tagsString: string): void;
  5012. /**
  5013. * @hidden
  5014. */ private static _AddTagTo(obj: any, tag: string): void;
  5015. /**
  5016. * Removes specific tags from a specific object
  5017. * @param obj defines the object to use
  5018. * @param tagsString defines the tags to remove
  5019. */
  5020. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5021. /**
  5022. * @hidden
  5023. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5024. /**
  5025. * Defines if tags hosted on an object match a given query
  5026. * @param obj defines the object to use
  5027. * @param tagsQuery defines the tag query
  5028. * @returns a boolean
  5029. */
  5030. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5031. }
  5032. }
  5033. declare module BABYLON {
  5034. /**
  5035. * Manages the defines for the Material
  5036. */
  5037. export class MaterialDefines {
  5038. private _keys;
  5039. private _isDirty;
  5040. /** @hidden */ renderId: number;
  5041. /** @hidden */ areLightsDirty: boolean;
  5042. /** @hidden */ areAttributesDirty: boolean;
  5043. /** @hidden */ areTexturesDirty: boolean;
  5044. /** @hidden */ areFresnelDirty: boolean;
  5045. /** @hidden */ areMiscDirty: boolean;
  5046. /** @hidden */ areImageProcessingDirty: boolean;
  5047. /** @hidden */ normals: boolean;
  5048. /** @hidden */ uvs: boolean;
  5049. /** @hidden */ needNormals: boolean;
  5050. /** @hidden */ needUVs: boolean;
  5051. /**
  5052. * Specifies if the material needs to be re-calculated
  5053. */
  5054. readonly isDirty: boolean;
  5055. /**
  5056. * Marks the material to indicate that it has been re-calculated
  5057. */
  5058. markAsProcessed(): void;
  5059. /**
  5060. * Marks the material to indicate that it needs to be re-calculated
  5061. */
  5062. markAsUnprocessed(): void;
  5063. /**
  5064. * Marks the material to indicate all of its defines need to be re-calculated
  5065. */
  5066. markAllAsDirty(): void;
  5067. /**
  5068. * Marks the material to indicate that image processing needs to be re-calculated
  5069. */
  5070. markAsImageProcessingDirty(): void;
  5071. /**
  5072. * Marks the material to indicate the lights need to be re-calculated
  5073. */
  5074. markAsLightDirty(): void;
  5075. /**
  5076. * Marks the attribute state as changed
  5077. */
  5078. markAsAttributesDirty(): void;
  5079. /**
  5080. * Marks the texture state as changed
  5081. */
  5082. markAsTexturesDirty(): void;
  5083. /**
  5084. * Marks the fresnel state as changed
  5085. */
  5086. markAsFresnelDirty(): void;
  5087. /**
  5088. * Marks the misc state as changed
  5089. */
  5090. markAsMiscDirty(): void;
  5091. /**
  5092. * Rebuilds the material defines
  5093. */
  5094. rebuild(): void;
  5095. /**
  5096. * Specifies if two material defines are equal
  5097. * @param other - A material define instance to compare to
  5098. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5099. */
  5100. isEqual(other: MaterialDefines): boolean;
  5101. /**
  5102. * Clones this instance's defines to another instance
  5103. * @param other - material defines to clone values to
  5104. */
  5105. cloneTo(other: MaterialDefines): void;
  5106. /**
  5107. * Resets the material define values
  5108. */
  5109. reset(): void;
  5110. /**
  5111. * Converts the material define values to a string
  5112. * @returns - String of material define information
  5113. */
  5114. toString(): string;
  5115. }
  5116. }
  5117. declare module BABYLON {
  5118. /**
  5119. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5120. */
  5121. export class PerformanceMonitor {
  5122. private _enabled;
  5123. private _rollingFrameTime;
  5124. private _lastFrameTimeMs;
  5125. /**
  5126. * constructor
  5127. * @param frameSampleSize The number of samples required to saturate the sliding window
  5128. */
  5129. constructor(frameSampleSize?: number);
  5130. /**
  5131. * Samples current frame
  5132. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5133. */
  5134. sampleFrame(timeMs?: number): void;
  5135. /**
  5136. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5137. */
  5138. readonly averageFrameTime: number;
  5139. /**
  5140. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5141. */
  5142. readonly averageFrameTimeVariance: number;
  5143. /**
  5144. * Returns the frame time of the most recent frame
  5145. */
  5146. readonly instantaneousFrameTime: number;
  5147. /**
  5148. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5149. */
  5150. readonly averageFPS: number;
  5151. /**
  5152. * Returns the average framerate in frames per second using the most recent frame time
  5153. */
  5154. readonly instantaneousFPS: number;
  5155. /**
  5156. * Returns true if enough samples have been taken to completely fill the sliding window
  5157. */
  5158. readonly isSaturated: boolean;
  5159. /**
  5160. * Enables contributions to the sliding window sample set
  5161. */
  5162. enable(): void;
  5163. /**
  5164. * Disables contributions to the sliding window sample set
  5165. * Samples will not be interpolated over the disabled period
  5166. */
  5167. disable(): void;
  5168. /**
  5169. * Returns true if sampling is enabled
  5170. */
  5171. readonly isEnabled: boolean;
  5172. /**
  5173. * Resets performance monitor
  5174. */
  5175. reset(): void;
  5176. }
  5177. /**
  5178. * RollingAverage
  5179. *
  5180. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5181. */
  5182. export class RollingAverage {
  5183. /**
  5184. * Current average
  5185. */
  5186. average: number;
  5187. /**
  5188. * Current variance
  5189. */
  5190. variance: number;
  5191. protected _samples: Array<number>;
  5192. protected _sampleCount: number;
  5193. protected _pos: number;
  5194. protected _m2: number;
  5195. /**
  5196. * constructor
  5197. * @param length The number of samples required to saturate the sliding window
  5198. */
  5199. constructor(length: number);
  5200. /**
  5201. * Adds a sample to the sample set
  5202. * @param v The sample value
  5203. */
  5204. add(v: number): void;
  5205. /**
  5206. * Returns previously added values or null if outside of history or outside the sliding window domain
  5207. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5208. * @return Value previously recorded with add() or null if outside of range
  5209. */
  5210. history(i: number): number;
  5211. /**
  5212. * Returns true if enough samples have been taken to completely fill the sliding window
  5213. * @return true if sample-set saturated
  5214. */
  5215. isSaturated(): boolean;
  5216. /**
  5217. * Resets the rolling average (equivalent to 0 samples taken so far)
  5218. */
  5219. reset(): void;
  5220. /**
  5221. * Wraps a value around the sample range boundaries
  5222. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5223. * @return Wrapped position in sample range
  5224. */
  5225. protected _wrapPosition(i: number): number;
  5226. }
  5227. }
  5228. declare module BABYLON {
  5229. /**
  5230. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5231. * The underlying implementation relies on an associative array to ensure the best performances.
  5232. * The value can be anything including 'null' but except 'undefined'
  5233. */
  5234. export class StringDictionary<T> {
  5235. /**
  5236. * This will clear this dictionary and copy the content from the 'source' one.
  5237. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5238. * @param source the dictionary to take the content from and copy to this dictionary
  5239. */
  5240. copyFrom(source: StringDictionary<T>): void;
  5241. /**
  5242. * Get a value based from its key
  5243. * @param key the given key to get the matching value from
  5244. * @return the value if found, otherwise undefined is returned
  5245. */
  5246. get(key: string): T | undefined;
  5247. /**
  5248. * Get a value from its key or add it if it doesn't exist.
  5249. * This method will ensure you that a given key/data will be present in the dictionary.
  5250. * @param key the given key to get the matching value from
  5251. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5252. * The factory will only be invoked if there's no data for the given key.
  5253. * @return the value corresponding to the key.
  5254. */
  5255. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5256. /**
  5257. * Get a value from its key if present in the dictionary otherwise add it
  5258. * @param key the key to get the value from
  5259. * @param val if there's no such key/value pair in the dictionary add it with this value
  5260. * @return the value corresponding to the key
  5261. */
  5262. getOrAdd(key: string, val: T): T;
  5263. /**
  5264. * Check if there's a given key in the dictionary
  5265. * @param key the key to check for
  5266. * @return true if the key is present, false otherwise
  5267. */
  5268. contains(key: string): boolean;
  5269. /**
  5270. * Add a new key and its corresponding value
  5271. * @param key the key to add
  5272. * @param value the value corresponding to the key
  5273. * @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
  5274. */
  5275. add(key: string, value: T): boolean;
  5276. /**
  5277. * Update a specific value associated to a key
  5278. * @param key defines the key to use
  5279. * @param value defines the value to store
  5280. * @returns true if the value was updated (or false if the key was not found)
  5281. */
  5282. set(key: string, value: T): boolean;
  5283. /**
  5284. * Get the element of the given key and remove it from the dictionary
  5285. * @param key defines the key to search
  5286. * @returns the value associated with the key or null if not found
  5287. */
  5288. getAndRemove(key: string): Nullable<T>;
  5289. /**
  5290. * Remove a key/value from the dictionary.
  5291. * @param key the key to remove
  5292. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5293. */
  5294. remove(key: string): boolean;
  5295. /**
  5296. * Clear the whole content of the dictionary
  5297. */
  5298. clear(): void;
  5299. /**
  5300. * Gets the current count
  5301. */
  5302. readonly count: number;
  5303. /**
  5304. * Execute a callback on each key/val of the dictionary.
  5305. * Note that you can remove any element in this dictionary in the callback implementation
  5306. * @param callback the callback to execute on a given key/value pair
  5307. */
  5308. forEach(callback: (key: string, val: T) => void): void;
  5309. /**
  5310. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5311. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5312. * Note that you can remove any element in this dictionary in the callback implementation
  5313. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5314. * @returns the first item
  5315. */
  5316. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5317. private _count;
  5318. private _data;
  5319. }
  5320. }
  5321. declare module BABYLON {
  5322. /**
  5323. * Helper class that provides a small promise polyfill
  5324. */
  5325. export class PromisePolyfill {
  5326. /**
  5327. * Static function used to check if the polyfill is required
  5328. * If this is the case then the function will inject the polyfill to window.Promise
  5329. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5330. */
  5331. static Apply(force?: boolean): void;
  5332. }
  5333. }
  5334. declare module BABYLON {
  5335. /**
  5336. * Class used to store data that will be store in GPU memory
  5337. */
  5338. export class Buffer {
  5339. private _engine;
  5340. private _buffer;
  5341. /** @hidden */ data: Nullable<DataArray>;
  5342. private _updatable;
  5343. private _instanced;
  5344. /**
  5345. * Gets the byte stride.
  5346. */
  5347. readonly byteStride: number;
  5348. /**
  5349. * Constructor
  5350. * @param engine the engine
  5351. * @param data the data to use for this buffer
  5352. * @param updatable whether the data is updatable
  5353. * @param stride the stride (optional)
  5354. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5355. * @param instanced whether the buffer is instanced (optional)
  5356. * @param useBytes set to true if the stride in in bytes (optional)
  5357. */
  5358. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5359. /**
  5360. * Create a new VertexBuffer based on the current buffer
  5361. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5362. * @param offset defines offset in the buffer (0 by default)
  5363. * @param size defines the size in floats of attributes (position is 3 for instance)
  5364. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5365. * @param instanced defines if the vertex buffer contains indexed data
  5366. * @param useBytes defines if the offset and stride are in bytes
  5367. * @returns the new vertex buffer
  5368. */
  5369. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5370. /**
  5371. * Gets a boolean indicating if the Buffer is updatable?
  5372. * @returns true if the buffer is updatable
  5373. */
  5374. isUpdatable(): boolean;
  5375. /**
  5376. * Gets current buffer's data
  5377. * @returns a DataArray or null
  5378. */
  5379. getData(): Nullable<DataArray>;
  5380. /**
  5381. * Gets underlying native buffer
  5382. * @returns underlying native buffer
  5383. */
  5384. getBuffer(): Nullable<WebGLBuffer>;
  5385. /**
  5386. * Gets the stride in float32 units (i.e. byte stride / 4).
  5387. * May not be an integer if the byte stride is not divisible by 4.
  5388. * DEPRECATED. Use byteStride instead.
  5389. * @returns the stride in float32 units
  5390. */
  5391. getStrideSize(): number;
  5392. /**
  5393. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5394. * @param data defines the data to store
  5395. */
  5396. create(data?: Nullable<DataArray>): void;
  5397. /** @hidden */ rebuild(): void;
  5398. /**
  5399. * Update current buffer data
  5400. * @param data defines the data to store
  5401. */
  5402. update(data: DataArray): void;
  5403. /**
  5404. * Updates the data directly.
  5405. * @param data the new data
  5406. * @param offset the new offset
  5407. * @param vertexCount the vertex count (optional)
  5408. * @param useBytes set to true if the offset is in bytes
  5409. */
  5410. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5411. /**
  5412. * Release all resources
  5413. */
  5414. dispose(): void;
  5415. }
  5416. /**
  5417. * Specialized buffer used to store vertex data
  5418. */
  5419. export class VertexBuffer {
  5420. /** @hidden */ buffer: Buffer;
  5421. private _kind;
  5422. private _size;
  5423. private _ownsBuffer;
  5424. private _instanced;
  5425. private _instanceDivisor;
  5426. /**
  5427. * The byte type.
  5428. */
  5429. static readonly BYTE: number;
  5430. /**
  5431. * The unsigned byte type.
  5432. */
  5433. static readonly UNSIGNED_BYTE: number;
  5434. /**
  5435. * The short type.
  5436. */
  5437. static readonly SHORT: number;
  5438. /**
  5439. * The unsigned short type.
  5440. */
  5441. static readonly UNSIGNED_SHORT: number;
  5442. /**
  5443. * The integer type.
  5444. */
  5445. static readonly INT: number;
  5446. /**
  5447. * The unsigned integer type.
  5448. */
  5449. static readonly UNSIGNED_INT: number;
  5450. /**
  5451. * The float type.
  5452. */
  5453. static readonly FLOAT: number;
  5454. /**
  5455. * Gets or sets the instance divisor when in instanced mode
  5456. */
  5457. instanceDivisor: number;
  5458. /**
  5459. * Gets the byte stride.
  5460. */
  5461. readonly byteStride: number;
  5462. /**
  5463. * Gets the byte offset.
  5464. */
  5465. readonly byteOffset: number;
  5466. /**
  5467. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5468. */
  5469. readonly normalized: boolean;
  5470. /**
  5471. * Gets the data type of each component in the array.
  5472. */
  5473. readonly type: number;
  5474. /**
  5475. * Constructor
  5476. * @param engine the engine
  5477. * @param data the data to use for this vertex buffer
  5478. * @param kind the vertex buffer kind
  5479. * @param updatable whether the data is updatable
  5480. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5481. * @param stride the stride (optional)
  5482. * @param instanced whether the buffer is instanced (optional)
  5483. * @param offset the offset of the data (optional)
  5484. * @param size the number of components (optional)
  5485. * @param type the type of the component (optional)
  5486. * @param normalized whether the data contains normalized data (optional)
  5487. * @param useBytes set to true if stride and offset are in bytes (optional)
  5488. */
  5489. 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);
  5490. /** @hidden */ rebuild(): void;
  5491. /**
  5492. * Returns the kind of the VertexBuffer (string)
  5493. * @returns a string
  5494. */
  5495. getKind(): string;
  5496. /**
  5497. * Gets a boolean indicating if the VertexBuffer is updatable?
  5498. * @returns true if the buffer is updatable
  5499. */
  5500. isUpdatable(): boolean;
  5501. /**
  5502. * Gets current buffer's data
  5503. * @returns a DataArray or null
  5504. */
  5505. getData(): Nullable<DataArray>;
  5506. /**
  5507. * Gets underlying native buffer
  5508. * @returns underlying native buffer
  5509. */
  5510. getBuffer(): Nullable<WebGLBuffer>;
  5511. /**
  5512. * Gets the stride in float32 units (i.e. byte stride / 4).
  5513. * May not be an integer if the byte stride is not divisible by 4.
  5514. * DEPRECATED. Use byteStride instead.
  5515. * @returns the stride in float32 units
  5516. */
  5517. getStrideSize(): number;
  5518. /**
  5519. * Returns the offset as a multiple of the type byte length.
  5520. * DEPRECATED. Use byteOffset instead.
  5521. * @returns the offset in bytes
  5522. */
  5523. getOffset(): number;
  5524. /**
  5525. * Returns the number of components per vertex attribute (integer)
  5526. * @returns the size in float
  5527. */
  5528. getSize(): number;
  5529. /**
  5530. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5531. * @returns true if this buffer is instanced
  5532. */
  5533. getIsInstanced(): boolean;
  5534. /**
  5535. * Returns the instancing divisor, zero for non-instanced (integer).
  5536. * @returns a number
  5537. */
  5538. getInstanceDivisor(): number;
  5539. /**
  5540. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5541. * @param data defines the data to store
  5542. */
  5543. create(data?: DataArray): void;
  5544. /**
  5545. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5546. * This function will create a new buffer if the current one is not updatable
  5547. * @param data defines the data to store
  5548. */
  5549. update(data: DataArray): void;
  5550. /**
  5551. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5552. * Returns the directly updated WebGLBuffer.
  5553. * @param data the new data
  5554. * @param offset the new offset
  5555. * @param useBytes set to true if the offset is in bytes
  5556. */
  5557. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5558. /**
  5559. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5560. */
  5561. dispose(): void;
  5562. /**
  5563. * Enumerates each value of this vertex buffer as numbers.
  5564. * @param count the number of values to enumerate
  5565. * @param callback the callback function called for each value
  5566. */
  5567. forEach(count: number, callback: (value: number, index: number) => void): void;
  5568. /**
  5569. * Positions
  5570. */
  5571. static readonly PositionKind: string;
  5572. /**
  5573. * Normals
  5574. */
  5575. static readonly NormalKind: string;
  5576. /**
  5577. * Tangents
  5578. */
  5579. static readonly TangentKind: string;
  5580. /**
  5581. * Texture coordinates
  5582. */
  5583. static readonly UVKind: string;
  5584. /**
  5585. * Texture coordinates 2
  5586. */
  5587. static readonly UV2Kind: string;
  5588. /**
  5589. * Texture coordinates 3
  5590. */
  5591. static readonly UV3Kind: string;
  5592. /**
  5593. * Texture coordinates 4
  5594. */
  5595. static readonly UV4Kind: string;
  5596. /**
  5597. * Texture coordinates 5
  5598. */
  5599. static readonly UV5Kind: string;
  5600. /**
  5601. * Texture coordinates 6
  5602. */
  5603. static readonly UV6Kind: string;
  5604. /**
  5605. * Colors
  5606. */
  5607. static readonly ColorKind: string;
  5608. /**
  5609. * Matrix indices (for bones)
  5610. */
  5611. static readonly MatricesIndicesKind: string;
  5612. /**
  5613. * Matrix weights (for bones)
  5614. */
  5615. static readonly MatricesWeightsKind: string;
  5616. /**
  5617. * Additional matrix indices (for bones)
  5618. */
  5619. static readonly MatricesIndicesExtraKind: string;
  5620. /**
  5621. * Additional matrix weights (for bones)
  5622. */
  5623. static readonly MatricesWeightsExtraKind: string;
  5624. /**
  5625. * Deduces the stride given a kind.
  5626. * @param kind The kind string to deduce
  5627. * @returns The deduced stride
  5628. */
  5629. static DeduceStride(kind: string): number;
  5630. /**
  5631. * Gets the byte length of the given type.
  5632. * @param type the type
  5633. * @returns the number of bytes
  5634. */
  5635. static GetTypeByteLength(type: number): number;
  5636. /**
  5637. * Enumerates each value of the given parameters as numbers.
  5638. * @param data the data to enumerate
  5639. * @param byteOffset the byte offset of the data
  5640. * @param byteStride the byte stride of the data
  5641. * @param componentCount the number of components per element
  5642. * @param componentType the type of the component
  5643. * @param count the total number of components
  5644. * @param normalized whether the data is normalized
  5645. * @param callback the callback function called for each value
  5646. */
  5647. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5648. private static _GetFloatValue;
  5649. }
  5650. }
  5651. declare module BABYLON {
  5652. /**
  5653. * Class representing spherical polynomial coefficients to the 3rd degree
  5654. */
  5655. export class SphericalPolynomial {
  5656. /**
  5657. * The x coefficients of the spherical polynomial
  5658. */
  5659. x: Vector3;
  5660. /**
  5661. * The y coefficients of the spherical polynomial
  5662. */
  5663. y: Vector3;
  5664. /**
  5665. * The z coefficients of the spherical polynomial
  5666. */
  5667. z: Vector3;
  5668. /**
  5669. * The xx coefficients of the spherical polynomial
  5670. */
  5671. xx: Vector3;
  5672. /**
  5673. * The yy coefficients of the spherical polynomial
  5674. */
  5675. yy: Vector3;
  5676. /**
  5677. * The zz coefficients of the spherical polynomial
  5678. */
  5679. zz: Vector3;
  5680. /**
  5681. * The xy coefficients of the spherical polynomial
  5682. */
  5683. xy: Vector3;
  5684. /**
  5685. * The yz coefficients of the spherical polynomial
  5686. */
  5687. yz: Vector3;
  5688. /**
  5689. * The zx coefficients of the spherical polynomial
  5690. */
  5691. zx: Vector3;
  5692. /**
  5693. * Adds an ambient color to the spherical polynomial
  5694. * @param color the color to add
  5695. */
  5696. addAmbient(color: Color3): void;
  5697. /**
  5698. * Scales the spherical polynomial by the given amount
  5699. * @param scale the amount to scale
  5700. */
  5701. scale(scale: number): void;
  5702. /**
  5703. * Gets the spherical polynomial from harmonics
  5704. * @param harmonics the spherical harmonics
  5705. * @returns the spherical polynomial
  5706. */
  5707. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5708. /**
  5709. * Constructs a spherical polynomial from an array.
  5710. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5711. * @returns the spherical polynomial
  5712. */
  5713. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5714. }
  5715. /**
  5716. * Class representing spherical harmonics coefficients to the 3rd degree
  5717. */
  5718. export class SphericalHarmonics {
  5719. /**
  5720. * The l0,0 coefficients of the spherical harmonics
  5721. */
  5722. l00: Vector3;
  5723. /**
  5724. * The l1,-1 coefficients of the spherical harmonics
  5725. */
  5726. l1_1: Vector3;
  5727. /**
  5728. * The l1,0 coefficients of the spherical harmonics
  5729. */
  5730. l10: Vector3;
  5731. /**
  5732. * The l1,1 coefficients of the spherical harmonics
  5733. */
  5734. l11: Vector3;
  5735. /**
  5736. * The l2,-2 coefficients of the spherical harmonics
  5737. */
  5738. l2_2: Vector3;
  5739. /**
  5740. * The l2,-1 coefficients of the spherical harmonics
  5741. */
  5742. l2_1: Vector3;
  5743. /**
  5744. * The l2,0 coefficients of the spherical harmonics
  5745. */
  5746. l20: Vector3;
  5747. /**
  5748. * The l2,1 coefficients of the spherical harmonics
  5749. */
  5750. l21: Vector3;
  5751. /**
  5752. * The l2,2 coefficients of the spherical harmonics
  5753. */
  5754. lL22: Vector3;
  5755. /**
  5756. * Adds a light to the spherical harmonics
  5757. * @param direction the direction of the light
  5758. * @param color the color of the light
  5759. * @param deltaSolidAngle the delta solid angle of the light
  5760. */
  5761. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5762. /**
  5763. * Scales the spherical harmonics by the given amount
  5764. * @param scale the amount to scale
  5765. */
  5766. scale(scale: number): void;
  5767. /**
  5768. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5769. *
  5770. * ```
  5771. * E_lm = A_l * L_lm
  5772. * ```
  5773. *
  5774. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5775. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5776. * the scaling factors are given in equation 9.
  5777. */
  5778. convertIncidentRadianceToIrradiance(): void;
  5779. /**
  5780. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5781. *
  5782. * ```
  5783. * L = (1/pi) * E * rho
  5784. * ```
  5785. *
  5786. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5787. */
  5788. convertIrradianceToLambertianRadiance(): void;
  5789. /**
  5790. * Gets the spherical harmonics from polynomial
  5791. * @param polynomial the spherical polynomial
  5792. * @returns the spherical harmonics
  5793. */
  5794. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5795. /**
  5796. * Constructs a spherical harmonics from an array.
  5797. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5798. * @returns the spherical harmonics
  5799. */
  5800. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5801. }
  5802. }
  5803. declare module BABYLON {
  5804. /**
  5805. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5806. */
  5807. export interface CubeMapInfo {
  5808. /**
  5809. * The pixel array for the front face.
  5810. * This is stored in format, left to right, up to down format.
  5811. */
  5812. front: Nullable<ArrayBufferView>;
  5813. /**
  5814. * The pixel array for the back face.
  5815. * This is stored in format, left to right, up to down format.
  5816. */
  5817. back: Nullable<ArrayBufferView>;
  5818. /**
  5819. * The pixel array for the left face.
  5820. * This is stored in format, left to right, up to down format.
  5821. */
  5822. left: Nullable<ArrayBufferView>;
  5823. /**
  5824. * The pixel array for the right face.
  5825. * This is stored in format, left to right, up to down format.
  5826. */
  5827. right: Nullable<ArrayBufferView>;
  5828. /**
  5829. * The pixel array for the up face.
  5830. * This is stored in format, left to right, up to down format.
  5831. */
  5832. up: Nullable<ArrayBufferView>;
  5833. /**
  5834. * The pixel array for the down face.
  5835. * This is stored in format, left to right, up to down format.
  5836. */
  5837. down: Nullable<ArrayBufferView>;
  5838. /**
  5839. * The size of the cubemap stored.
  5840. *
  5841. * Each faces will be size * size pixels.
  5842. */
  5843. size: number;
  5844. /**
  5845. * The format of the texture.
  5846. *
  5847. * RGBA, RGB.
  5848. */
  5849. format: number;
  5850. /**
  5851. * The type of the texture data.
  5852. *
  5853. * UNSIGNED_INT, FLOAT.
  5854. */
  5855. type: number;
  5856. /**
  5857. * Specifies whether the texture is in gamma space.
  5858. */
  5859. gammaSpace: boolean;
  5860. }
  5861. /**
  5862. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5863. */
  5864. export class PanoramaToCubeMapTools {
  5865. private static FACE_FRONT;
  5866. private static FACE_BACK;
  5867. private static FACE_RIGHT;
  5868. private static FACE_LEFT;
  5869. private static FACE_DOWN;
  5870. private static FACE_UP;
  5871. /**
  5872. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5873. *
  5874. * @param float32Array The source data.
  5875. * @param inputWidth The width of the input panorama.
  5876. * @param inputHeight The height of the input panorama.
  5877. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5878. * @return The cubemap data
  5879. */
  5880. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5881. private static CreateCubemapTexture;
  5882. private static CalcProjectionSpherical;
  5883. }
  5884. }
  5885. declare module BABYLON {
  5886. /**
  5887. * Helper class dealing with the extraction of spherical polynomial dataArray
  5888. * from a cube map.
  5889. */
  5890. export class CubeMapToSphericalPolynomialTools {
  5891. private static FileFaces;
  5892. /**
  5893. * Converts a texture to the according Spherical Polynomial data.
  5894. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5895. *
  5896. * @param texture The texture to extract the information from.
  5897. * @return The Spherical Polynomial data.
  5898. */
  5899. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5900. /**
  5901. * Converts a cubemap to the according Spherical Polynomial data.
  5902. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5903. *
  5904. * @param cubeInfo The Cube map to extract the information from.
  5905. * @return The Spherical Polynomial data.
  5906. */
  5907. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5908. }
  5909. }
  5910. declare module BABYLON {
  5911. /**
  5912. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5913. * during the life time of the application.
  5914. */
  5915. export class EngineStore {
  5916. /** Gets the list of created engines */
  5917. static Instances: Engine[];
  5918. /**
  5919. * Gets the latest created engine
  5920. */
  5921. static readonly LastCreatedEngine: Nullable<Engine>;
  5922. /**
  5923. * Gets the latest created scene
  5924. */
  5925. static readonly LastCreatedScene: Nullable<Scene>;
  5926. }
  5927. }
  5928. declare module BABYLON {
  5929. /**
  5930. * Define options used to create a render target texture
  5931. */
  5932. export class RenderTargetCreationOptions {
  5933. /**
  5934. * Specifies is mipmaps must be generated
  5935. */
  5936. generateMipMaps?: boolean;
  5937. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5938. generateDepthBuffer?: boolean;
  5939. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5940. generateStencilBuffer?: boolean;
  5941. /** Defines texture type (int by default) */
  5942. type?: number;
  5943. /** Defines sampling mode (trilinear by default) */
  5944. samplingMode?: number;
  5945. /** Defines format (RGBA by default) */
  5946. format?: number;
  5947. }
  5948. }
  5949. declare module BABYLON {
  5950. /**
  5951. * @hidden
  5952. **/
  5953. export class _AlphaState {
  5954. private _isAlphaBlendDirty;
  5955. private _isBlendFunctionParametersDirty;
  5956. private _isBlendEquationParametersDirty;
  5957. private _isBlendConstantsDirty;
  5958. private _alphaBlend;
  5959. private _blendFunctionParameters;
  5960. private _blendEquationParameters;
  5961. private _blendConstants;
  5962. /**
  5963. * Initializes the state.
  5964. */
  5965. constructor();
  5966. readonly isDirty: boolean;
  5967. alphaBlend: boolean;
  5968. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5969. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5970. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5971. reset(): void;
  5972. apply(gl: WebGLRenderingContext): void;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * @hidden
  5978. **/
  5979. export class _DepthCullingState {
  5980. private _isDepthTestDirty;
  5981. private _isDepthMaskDirty;
  5982. private _isDepthFuncDirty;
  5983. private _isCullFaceDirty;
  5984. private _isCullDirty;
  5985. private _isZOffsetDirty;
  5986. private _isFrontFaceDirty;
  5987. private _depthTest;
  5988. private _depthMask;
  5989. private _depthFunc;
  5990. private _cull;
  5991. private _cullFace;
  5992. private _zOffset;
  5993. private _frontFace;
  5994. /**
  5995. * Initializes the state.
  5996. */
  5997. constructor();
  5998. readonly isDirty: boolean;
  5999. zOffset: number;
  6000. cullFace: Nullable<number>;
  6001. cull: Nullable<boolean>;
  6002. depthFunc: Nullable<number>;
  6003. depthMask: boolean;
  6004. depthTest: boolean;
  6005. frontFace: Nullable<number>;
  6006. reset(): void;
  6007. apply(gl: WebGLRenderingContext): void;
  6008. }
  6009. }
  6010. declare module BABYLON {
  6011. /**
  6012. * @hidden
  6013. **/
  6014. export class _StencilState {
  6015. /** 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 */
  6016. static readonly ALWAYS: number;
  6017. /** Passed to stencilOperation to specify that stencil value must be kept */
  6018. static readonly KEEP: number;
  6019. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6020. static readonly REPLACE: number;
  6021. private _isStencilTestDirty;
  6022. private _isStencilMaskDirty;
  6023. private _isStencilFuncDirty;
  6024. private _isStencilOpDirty;
  6025. private _stencilTest;
  6026. private _stencilMask;
  6027. private _stencilFunc;
  6028. private _stencilFuncRef;
  6029. private _stencilFuncMask;
  6030. private _stencilOpStencilFail;
  6031. private _stencilOpDepthFail;
  6032. private _stencilOpStencilDepthPass;
  6033. readonly isDirty: boolean;
  6034. stencilFunc: number;
  6035. stencilFuncRef: number;
  6036. stencilFuncMask: number;
  6037. stencilOpStencilFail: number;
  6038. stencilOpDepthFail: number;
  6039. stencilOpStencilDepthPass: number;
  6040. stencilMask: number;
  6041. stencilTest: boolean;
  6042. constructor();
  6043. reset(): void;
  6044. apply(gl: WebGLRenderingContext): void;
  6045. }
  6046. }
  6047. declare module BABYLON {
  6048. /**
  6049. * @hidden
  6050. **/
  6051. export class _TimeToken { startTimeQuery: Nullable<WebGLQuery>; endTimeQuery: Nullable<WebGLQuery>; timeElapsedQuery: Nullable<WebGLQuery>; timeElapsedQueryEnded: boolean;
  6052. }
  6053. }
  6054. declare module BABYLON {
  6055. /**
  6056. * Internal interface used to track InternalTexture already bound to the GL context
  6057. */
  6058. export interface IInternalTextureTracker {
  6059. /**
  6060. * Gets or set the previous tracker in the list
  6061. */
  6062. previous: Nullable<IInternalTextureTracker>;
  6063. /**
  6064. * Gets or set the next tracker in the list
  6065. */
  6066. next: Nullable<IInternalTextureTracker>;
  6067. }
  6068. /**
  6069. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6070. */
  6071. export class DummyInternalTextureTracker {
  6072. /**
  6073. * Gets or set the previous tracker in the list
  6074. */
  6075. previous: Nullable<IInternalTextureTracker>;
  6076. /**
  6077. * Gets or set the next tracker in the list
  6078. */
  6079. next: Nullable<IInternalTextureTracker>;
  6080. }
  6081. }
  6082. declare module BABYLON {
  6083. /**
  6084. * Class used to store data associated with WebGL texture data for the engine
  6085. * This class should not be used directly
  6086. */
  6087. export class InternalTexture implements IInternalTextureTracker {
  6088. /** hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6089. /**
  6090. * The source of the texture data is unknown
  6091. */
  6092. static DATASOURCE_UNKNOWN: number;
  6093. /**
  6094. * Texture data comes from an URL
  6095. */
  6096. static DATASOURCE_URL: number;
  6097. /**
  6098. * Texture data is only used for temporary storage
  6099. */
  6100. static DATASOURCE_TEMP: number;
  6101. /**
  6102. * Texture data comes from raw data (ArrayBuffer)
  6103. */
  6104. static DATASOURCE_RAW: number;
  6105. /**
  6106. * Texture content is dynamic (video or dynamic texture)
  6107. */
  6108. static DATASOURCE_DYNAMIC: number;
  6109. /**
  6110. * Texture content is generated by rendering to it
  6111. */
  6112. static DATASOURCE_RENDERTARGET: number;
  6113. /**
  6114. * Texture content is part of a multi render target process
  6115. */
  6116. static DATASOURCE_MULTIRENDERTARGET: number;
  6117. /**
  6118. * Texture data comes from a cube data file
  6119. */
  6120. static DATASOURCE_CUBE: number;
  6121. /**
  6122. * Texture data comes from a raw cube data
  6123. */
  6124. static DATASOURCE_CUBERAW: number;
  6125. /**
  6126. * Texture data come from a prefiltered cube data file
  6127. */
  6128. static DATASOURCE_CUBEPREFILTERED: number;
  6129. /**
  6130. * Texture content is raw 3D data
  6131. */
  6132. static DATASOURCE_RAW3D: number;
  6133. /**
  6134. * Texture content is a depth texture
  6135. */
  6136. static DATASOURCE_DEPTHTEXTURE: number;
  6137. /**
  6138. * Texture data comes from a raw cube data encoded with RGBD
  6139. */
  6140. static DATASOURCE_CUBERAW_RGBD: number;
  6141. /**
  6142. * Defines if the texture is ready
  6143. */
  6144. isReady: boolean;
  6145. /**
  6146. * Defines if the texture is a cube texture
  6147. */
  6148. isCube: boolean;
  6149. /**
  6150. * Defines if the texture contains 3D data
  6151. */
  6152. is3D: boolean;
  6153. /**
  6154. * Gets the URL used to load this texture
  6155. */
  6156. url: string;
  6157. /**
  6158. * Gets the sampling mode of the texture
  6159. */
  6160. samplingMode: number;
  6161. /**
  6162. * Gets a boolean indicating if the texture needs mipmaps generation
  6163. */
  6164. generateMipMaps: boolean;
  6165. /**
  6166. * Gets the number of samples used by the texture (WebGL2+ only)
  6167. */
  6168. samples: number;
  6169. /**
  6170. * Gets the type of the texture (int, float...)
  6171. */
  6172. type: number;
  6173. /**
  6174. * Gets the format of the texture (RGB, RGBA...)
  6175. */
  6176. format: number;
  6177. /**
  6178. * Observable called when the texture is loaded
  6179. */
  6180. onLoadedObservable: Observable<InternalTexture>;
  6181. /**
  6182. * Gets the width of the texture
  6183. */
  6184. width: number;
  6185. /**
  6186. * Gets the height of the texture
  6187. */
  6188. height: number;
  6189. /**
  6190. * Gets the depth of the texture
  6191. */
  6192. depth: number;
  6193. /**
  6194. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6195. */
  6196. baseWidth: number;
  6197. /**
  6198. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6199. */
  6200. baseHeight: number;
  6201. /**
  6202. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6203. */
  6204. baseDepth: number;
  6205. /**
  6206. * Gets a boolean indicating if the texture is inverted on Y axis
  6207. */
  6208. invertY: boolean;
  6209. /**
  6210. * Gets or set the previous tracker in the list
  6211. */
  6212. previous: Nullable<IInternalTextureTracker>;
  6213. /**
  6214. * Gets or set the next tracker in the list
  6215. */
  6216. next: Nullable<IInternalTextureTracker>;
  6217. /** @hidden */ invertVScale: boolean;
  6218. /** @hidden */ initialSlot: number;
  6219. /** @hidden */ designatedSlot: number;
  6220. /** @hidden */ dataSource: number;
  6221. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6222. /** @hidden */ bufferView: Nullable<ArrayBufferView>;
  6223. /** @hidden */ bufferViewArray: Nullable<ArrayBufferView[]>;
  6224. /** @hidden */ bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6225. /** @hidden */ size: number;
  6226. /** @hidden */ extension: string;
  6227. /** @hidden */ files: Nullable<string[]>;
  6228. /** @hidden */ workingCanvas: HTMLCanvasElement;
  6229. /** @hidden */ workingContext: CanvasRenderingContext2D;
  6230. /** @hidden */ framebuffer: Nullable<WebGLFramebuffer>;
  6231. /** @hidden */ depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6232. /** @hidden */ MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6233. /** @hidden */ MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6234. /** @hidden */ attachments: Nullable<number[]>;
  6235. /** @hidden */ cachedCoordinatesMode: Nullable<number>;
  6236. /** @hidden */ cachedWrapU: Nullable<number>;
  6237. /** @hidden */ cachedWrapV: Nullable<number>;
  6238. /** @hidden */ cachedWrapR: Nullable<number>;
  6239. /** @hidden */ cachedAnisotropicFilteringLevel: Nullable<number>;
  6240. /** @hidden */ isDisabled: boolean;
  6241. /** @hidden */ compression: Nullable<string>;
  6242. /** @hidden */ generateStencilBuffer: boolean;
  6243. /** @hidden */ generateDepthBuffer: boolean;
  6244. /** @hidden */ comparisonFunction: number;
  6245. /** @hidden */ sphericalPolynomial: Nullable<SphericalPolynomial>;
  6246. /** @hidden */ lodGenerationScale: number;
  6247. /** @hidden */ lodGenerationOffset: number;
  6248. /** @hidden */ lodTextureHigh: BaseTexture;
  6249. /** @hidden */ lodTextureMid: BaseTexture;
  6250. /** @hidden */ lodTextureLow: BaseTexture;
  6251. /** @hidden */ isRGBD: boolean;
  6252. /** @hidden */ webGLTexture: Nullable<WebGLTexture>;
  6253. /** @hidden */ references: number;
  6254. private _engine;
  6255. /**
  6256. * Gets the Engine the texture belongs to.
  6257. * @returns The babylon engine
  6258. */
  6259. getEngine(): Engine;
  6260. /**
  6261. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6262. */
  6263. readonly dataSource: number;
  6264. /**
  6265. * Creates a new InternalTexture
  6266. * @param engine defines the engine to use
  6267. * @param dataSource defines the type of data that will be used
  6268. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6269. */
  6270. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6271. /**
  6272. * Increments the number of references (ie. the number of Texture that point to it)
  6273. */
  6274. incrementReferences(): void;
  6275. /**
  6276. * Change the size of the texture (not the size of the content)
  6277. * @param width defines the new width
  6278. * @param height defines the new height
  6279. * @param depth defines the new depth (1 by default)
  6280. */
  6281. updateSize(width: int, height: int, depth?: int): void;
  6282. /** @hidden */ rebuild(): void;
  6283. /** @hidden */ swapAndDie(target: InternalTexture): void;
  6284. /**
  6285. * Dispose the current allocated resources
  6286. */
  6287. dispose(): void;
  6288. }
  6289. }
  6290. declare module BABYLON {
  6291. /**
  6292. * This represents the main contract an easing function should follow.
  6293. * Easing functions are used throughout the animation system.
  6294. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6295. */
  6296. export interface IEasingFunction {
  6297. /**
  6298. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6299. * of the easing function.
  6300. * The link below provides some of the most common examples of easing functions.
  6301. * @see https://easings.net/
  6302. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6303. * @returns the corresponding value on the curve defined by the easing function
  6304. */
  6305. ease(gradient: number): number;
  6306. }
  6307. /**
  6308. * Base class used for every default easing function.
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class EasingFunction implements IEasingFunction {
  6312. /**
  6313. * Interpolation follows the mathematical formula associated with the easing function.
  6314. */
  6315. static readonly EASINGMODE_EASEIN: number;
  6316. /**
  6317. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6318. */
  6319. static readonly EASINGMODE_EASEOUT: number;
  6320. /**
  6321. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6322. */
  6323. static readonly EASINGMODE_EASEINOUT: number;
  6324. private _easingMode;
  6325. /**
  6326. * Sets the easing mode of the current function.
  6327. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6328. */
  6329. setEasingMode(easingMode: number): void;
  6330. /**
  6331. * Gets the current easing mode.
  6332. * @returns the easing mode
  6333. */
  6334. getEasingMode(): number;
  6335. /**
  6336. * @hidden
  6337. */
  6338. easeInCore(gradient: number): number;
  6339. /**
  6340. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6341. * of the easing function.
  6342. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6343. * @returns the corresponding value on the curve defined by the easing function
  6344. */
  6345. ease(gradient: number): number;
  6346. }
  6347. /**
  6348. * Easing function with a circle shape (see link below).
  6349. * @see https://easings.net/#easeInCirc
  6350. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6351. */
  6352. export class CircleEase extends EasingFunction implements IEasingFunction {
  6353. /** @hidden */
  6354. easeInCore(gradient: number): number;
  6355. }
  6356. /**
  6357. * Easing function with a ease back shape (see link below).
  6358. * @see https://easings.net/#easeInBack
  6359. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6360. */
  6361. export class BackEase extends EasingFunction implements IEasingFunction {
  6362. /** Defines the amplitude of the function */
  6363. amplitude: number;
  6364. /**
  6365. * Instantiates a back ease easing
  6366. * @see https://easings.net/#easeInBack
  6367. * @param amplitude Defines the amplitude of the function
  6368. */
  6369. constructor(
  6370. /** Defines the amplitude of the function */
  6371. amplitude?: number);
  6372. /** @hidden */
  6373. easeInCore(gradient: number): number;
  6374. }
  6375. /**
  6376. * Easing function with a bouncing shape (see link below).
  6377. * @see https://easings.net/#easeInBounce
  6378. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6379. */
  6380. export class BounceEase extends EasingFunction implements IEasingFunction {
  6381. /** Defines the number of bounces */
  6382. bounces: number;
  6383. /** Defines the amplitude of the bounce */
  6384. bounciness: number;
  6385. /**
  6386. * Instantiates a bounce easing
  6387. * @see https://easings.net/#easeInBounce
  6388. * @param bounces Defines the number of bounces
  6389. * @param bounciness Defines the amplitude of the bounce
  6390. */
  6391. constructor(
  6392. /** Defines the number of bounces */
  6393. bounces?: number,
  6394. /** Defines the amplitude of the bounce */
  6395. bounciness?: number);
  6396. /** @hidden */
  6397. easeInCore(gradient: number): number;
  6398. }
  6399. /**
  6400. * Easing function with a power of 3 shape (see link below).
  6401. * @see https://easings.net/#easeInCubic
  6402. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6403. */
  6404. export class CubicEase extends EasingFunction implements IEasingFunction {
  6405. /** @hidden */
  6406. easeInCore(gradient: number): number;
  6407. }
  6408. /**
  6409. * Easing function with an elastic shape (see link below).
  6410. * @see https://easings.net/#easeInElastic
  6411. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6412. */
  6413. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6414. /** Defines the number of oscillations*/
  6415. oscillations: number;
  6416. /** Defines the amplitude of the oscillations*/
  6417. springiness: number;
  6418. /**
  6419. * Instantiates an elastic easing function
  6420. * @see https://easings.net/#easeInElastic
  6421. * @param oscillations Defines the number of oscillations
  6422. * @param springiness Defines the amplitude of the oscillations
  6423. */
  6424. constructor(
  6425. /** Defines the number of oscillations*/
  6426. oscillations?: number,
  6427. /** Defines the amplitude of the oscillations*/
  6428. springiness?: number);
  6429. /** @hidden */
  6430. easeInCore(gradient: number): number;
  6431. }
  6432. /**
  6433. * Easing function with an exponential shape (see link below).
  6434. * @see https://easings.net/#easeInExpo
  6435. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6436. */
  6437. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6438. /** Defines the exponent of the function */
  6439. exponent: number;
  6440. /**
  6441. * Instantiates an exponential easing function
  6442. * @see https://easings.net/#easeInExpo
  6443. * @param exponent Defines the exponent of the function
  6444. */
  6445. constructor(
  6446. /** Defines the exponent of the function */
  6447. exponent?: number);
  6448. /** @hidden */
  6449. easeInCore(gradient: number): number;
  6450. }
  6451. /**
  6452. * Easing function with a power shape (see link below).
  6453. * @see https://easings.net/#easeInQuad
  6454. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6455. */
  6456. export class PowerEase extends EasingFunction implements IEasingFunction {
  6457. /** Defines the power of the function */
  6458. power: number;
  6459. /**
  6460. * Instantiates an power base easing function
  6461. * @see https://easings.net/#easeInQuad
  6462. * @param power Defines the power of the function
  6463. */
  6464. constructor(
  6465. /** Defines the power of the function */
  6466. power?: number);
  6467. /** @hidden */
  6468. easeInCore(gradient: number): number;
  6469. }
  6470. /**
  6471. * Easing function with a power of 2 shape (see link below).
  6472. * @see https://easings.net/#easeInQuad
  6473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6474. */
  6475. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6476. /** @hidden */
  6477. easeInCore(gradient: number): number;
  6478. }
  6479. /**
  6480. * Easing function with a power of 4 shape (see link below).
  6481. * @see https://easings.net/#easeInQuart
  6482. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6483. */
  6484. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6485. /** @hidden */
  6486. easeInCore(gradient: number): number;
  6487. }
  6488. /**
  6489. * Easing function with a power of 5 shape (see link below).
  6490. * @see https://easings.net/#easeInQuint
  6491. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6492. */
  6493. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6494. /** @hidden */
  6495. easeInCore(gradient: number): number;
  6496. }
  6497. /**
  6498. * Easing function with a sin shape (see link below).
  6499. * @see https://easings.net/#easeInSine
  6500. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6501. */
  6502. export class SineEase extends EasingFunction implements IEasingFunction {
  6503. /** @hidden */
  6504. easeInCore(gradient: number): number;
  6505. }
  6506. /**
  6507. * Easing function with a bezier shape (see link below).
  6508. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6509. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6510. */
  6511. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6512. /** Defines the x component of the start tangent in the bezier curve */
  6513. x1: number;
  6514. /** Defines the y component of the start tangent in the bezier curve */
  6515. y1: number;
  6516. /** Defines the x component of the end tangent in the bezier curve */
  6517. x2: number;
  6518. /** Defines the y component of the end tangent in the bezier curve */
  6519. y2: number;
  6520. /**
  6521. * Instantiates a bezier function
  6522. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6523. * @param x1 Defines the x component of the start tangent in the bezier curve
  6524. * @param y1 Defines the y component of the start tangent in the bezier curve
  6525. * @param x2 Defines the x component of the end tangent in the bezier curve
  6526. * @param y2 Defines the y component of the end tangent in the bezier curve
  6527. */
  6528. constructor(
  6529. /** Defines the x component of the start tangent in the bezier curve */
  6530. x1?: number,
  6531. /** Defines the y component of the start tangent in the bezier curve */
  6532. y1?: number,
  6533. /** Defines the x component of the end tangent in the bezier curve */
  6534. x2?: number,
  6535. /** Defines the y component of the end tangent in the bezier curve */
  6536. y2?: number);
  6537. /** @hidden */
  6538. easeInCore(gradient: number): number;
  6539. }
  6540. }
  6541. declare module BABYLON {
  6542. /**
  6543. * Defines an interface which represents an animation key frame
  6544. */
  6545. export interface IAnimationKey {
  6546. /**
  6547. * Frame of the key frame
  6548. */
  6549. frame: number;
  6550. /**
  6551. * Value at the specifies key frame
  6552. */
  6553. value: any;
  6554. /**
  6555. * The input tangent for the cubic hermite spline
  6556. */
  6557. inTangent?: any;
  6558. /**
  6559. * The output tangent for the cubic hermite spline
  6560. */
  6561. outTangent?: any;
  6562. /**
  6563. * The animation interpolation type
  6564. */
  6565. interpolation?: AnimationKeyInterpolation;
  6566. }
  6567. /**
  6568. * Enum for the animation key frame interpolation type
  6569. */
  6570. export enum AnimationKeyInterpolation {
  6571. /**
  6572. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6573. */
  6574. STEP = 1
  6575. }
  6576. }
  6577. declare module BABYLON {
  6578. /**
  6579. * Represents the range of an animation
  6580. */
  6581. export class AnimationRange {
  6582. /**The name of the animation range**/
  6583. name: string;
  6584. /**The starting frame of the animation */
  6585. from: number;
  6586. /**The ending frame of the animation*/
  6587. to: number;
  6588. /**
  6589. * Initializes the range of an animation
  6590. * @param name The name of the animation range
  6591. * @param from The starting frame of the animation
  6592. * @param to The ending frame of the animation
  6593. */
  6594. constructor(
  6595. /**The name of the animation range**/
  6596. name: string,
  6597. /**The starting frame of the animation */
  6598. from: number,
  6599. /**The ending frame of the animation*/
  6600. to: number);
  6601. /**
  6602. * Makes a copy of the animation range
  6603. * @returns A copy of the animation range
  6604. */
  6605. clone(): AnimationRange;
  6606. }
  6607. }
  6608. declare module BABYLON {
  6609. /**
  6610. * Composed of a frame, and an action function
  6611. */
  6612. export class AnimationEvent {
  6613. /** The frame for which the event is triggered **/
  6614. frame: number;
  6615. /** The event to perform when triggered **/
  6616. action: (currentFrame: number) => void;
  6617. /** Specifies if the event should be triggered only once**/
  6618. onlyOnce?: boolean | undefined;
  6619. /**
  6620. * Specifies if the animation event is done
  6621. */
  6622. isDone: boolean;
  6623. /**
  6624. * Initializes the animation event
  6625. * @param frame The frame for which the event is triggered
  6626. * @param action The event to perform when triggered
  6627. * @param onlyOnce Specifies if the event should be triggered only once
  6628. */
  6629. constructor(
  6630. /** The frame for which the event is triggered **/
  6631. frame: number,
  6632. /** The event to perform when triggered **/
  6633. action: (currentFrame: number) => void,
  6634. /** Specifies if the event should be triggered only once**/
  6635. onlyOnce?: boolean | undefined);
  6636. /** @hidden */ clone(): AnimationEvent;
  6637. }
  6638. }
  6639. declare module BABYLON {
  6640. /**
  6641. * Interface used to define a behavior
  6642. */
  6643. export interface Behavior<T> {
  6644. /** gets or sets behavior's name */
  6645. name: string;
  6646. /**
  6647. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6648. */
  6649. init(): void;
  6650. /**
  6651. * Called when the behavior is attached to a target
  6652. * @param target defines the target where the behavior is attached to
  6653. */
  6654. attach(target: T): void;
  6655. /**
  6656. * Called when the behavior is detached from its target
  6657. */
  6658. detach(): void;
  6659. }
  6660. /**
  6661. * Interface implemented by classes supporting behaviors
  6662. */
  6663. export interface IBehaviorAware<T> {
  6664. /**
  6665. * Attach a behavior
  6666. * @param behavior defines the behavior to attach
  6667. * @returns the current host
  6668. */
  6669. addBehavior(behavior: Behavior<T>): T;
  6670. /**
  6671. * Remove a behavior from the current object
  6672. * @param behavior defines the behavior to detach
  6673. * @returns the current host
  6674. */
  6675. removeBehavior(behavior: Behavior<T>): T;
  6676. /**
  6677. * Gets a behavior using its name to search
  6678. * @param name defines the name to search
  6679. * @returns the behavior or null if not found
  6680. */
  6681. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6682. }
  6683. }
  6684. declare module BABYLON {
  6685. /**
  6686. * Defines a runtime animation
  6687. */
  6688. export class RuntimeAnimation {
  6689. private _events;
  6690. /**
  6691. * The current frame of the runtime animation
  6692. */
  6693. private _currentFrame;
  6694. /**
  6695. * The animation used by the runtime animation
  6696. */
  6697. private _animation;
  6698. /**
  6699. * The target of the runtime animation
  6700. */
  6701. private _target;
  6702. /**
  6703. * The initiating animatable
  6704. */
  6705. private _host;
  6706. /**
  6707. * The original value of the runtime animation
  6708. */
  6709. private _originalValue;
  6710. /**
  6711. * The original blend value of the runtime animation
  6712. */
  6713. private _originalBlendValue;
  6714. /**
  6715. * The offsets cache of the runtime animation
  6716. */
  6717. private _offsetsCache;
  6718. /**
  6719. * The high limits cache of the runtime animation
  6720. */
  6721. private _highLimitsCache;
  6722. /**
  6723. * Specifies if the runtime animation has been stopped
  6724. */
  6725. private _stopped;
  6726. /**
  6727. * The blending factor of the runtime animation
  6728. */
  6729. private _blendingFactor;
  6730. /**
  6731. * The BabylonJS scene
  6732. */
  6733. private _scene;
  6734. /**
  6735. * The current value of the runtime animation
  6736. */
  6737. private _currentValue;
  6738. /** @hidden */ workValue: any;
  6739. /**
  6740. * The active target of the runtime animation
  6741. */
  6742. private _activeTarget;
  6743. /**
  6744. * The target path of the runtime animation
  6745. */
  6746. private _targetPath;
  6747. /**
  6748. * The weight of the runtime animation
  6749. */
  6750. private _weight;
  6751. /**
  6752. * The ratio offset of the runtime animation
  6753. */
  6754. private _ratioOffset;
  6755. /**
  6756. * The previous delay of the runtime animation
  6757. */
  6758. private _previousDelay;
  6759. /**
  6760. * The previous ratio of the runtime animation
  6761. */
  6762. private _previousRatio;
  6763. /**
  6764. * Gets the current frame of the runtime animation
  6765. */
  6766. readonly currentFrame: number;
  6767. /**
  6768. * Gets the weight of the runtime animation
  6769. */
  6770. readonly weight: number;
  6771. /**
  6772. * Gets the current value of the runtime animation
  6773. */
  6774. readonly currentValue: any;
  6775. /**
  6776. * Gets the target path of the runtime animation
  6777. */
  6778. readonly targetPath: string;
  6779. /**
  6780. * Gets the actual target of the runtime animation
  6781. */
  6782. readonly target: any;
  6783. /**
  6784. * Create a new RuntimeAnimation object
  6785. * @param target defines the target of the animation
  6786. * @param animation defines the source animation object
  6787. * @param scene defines the hosting scene
  6788. * @param host defines the initiating Animatable
  6789. */
  6790. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6791. /**
  6792. * Gets the animation from the runtime animation
  6793. */
  6794. readonly animation: Animation;
  6795. /**
  6796. * Resets the runtime animation to the beginning
  6797. * @param restoreOriginal defines whether to restore the target property to the original value
  6798. */
  6799. reset(restoreOriginal?: boolean): void;
  6800. /**
  6801. * Specifies if the runtime animation is stopped
  6802. * @returns Boolean specifying if the runtime animation is stopped
  6803. */
  6804. isStopped(): boolean;
  6805. /**
  6806. * Disposes of the runtime animation
  6807. */
  6808. dispose(): void;
  6809. /**
  6810. * Interpolates the animation from the current frame
  6811. * @param currentFrame The frame to interpolate the animation to
  6812. * @param repeatCount The number of times that the animation should loop
  6813. * @param loopMode The type of looping mode to use
  6814. * @param offsetValue Animation offset value
  6815. * @param highLimitValue The high limit value
  6816. * @returns The interpolated value
  6817. */
  6818. private _interpolate;
  6819. /**
  6820. * Apply the interpolated value to the target
  6821. * @param currentValue defines the value computed by the animation
  6822. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6823. */
  6824. setValue(currentValue: any, weight?: number): void;
  6825. private _setValue;
  6826. /**
  6827. * Gets the loop pmode of the runtime animation
  6828. * @returns Loop Mode
  6829. */
  6830. private _getCorrectLoopMode;
  6831. /**
  6832. * Move the current animation to a given frame
  6833. * @param frame defines the frame to move to
  6834. */
  6835. goToFrame(frame: number): void;
  6836. /**
  6837. * @hidden Internal use only
  6838. */ prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6839. /**
  6840. * Execute the current animation
  6841. * @param delay defines the delay to add to the current frame
  6842. * @param from defines the lower bound of the animation range
  6843. * @param to defines the upper bound of the animation range
  6844. * @param loop defines if the current animation must loop
  6845. * @param speedRatio defines the current speed ratio
  6846. * @param weight defines the weight of the animation (default is -1 so no weight)
  6847. * @param onLoop optional callback called when animation loops
  6848. * @returns a boolean indicating if the animation is running
  6849. */
  6850. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6851. }
  6852. }
  6853. declare module BABYLON {
  6854. /**
  6855. * @hidden
  6856. */
  6857. export class IntersectionInfo {
  6858. bu: Nullable<number>;
  6859. bv: Nullable<number>;
  6860. distance: number;
  6861. faceId: number;
  6862. subMeshId: number;
  6863. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6864. }
  6865. }
  6866. declare module BABYLON {
  6867. /**
  6868. * Class used to store bounding sphere information
  6869. */
  6870. export class BoundingSphere {
  6871. /**
  6872. * Gets the center of the bounding sphere in local space
  6873. */
  6874. readonly center: Vector3;
  6875. /**
  6876. * Radius of the bounding sphere in local space
  6877. */
  6878. radius: number;
  6879. /**
  6880. * Gets the center of the bounding sphere in world space
  6881. */
  6882. readonly centerWorld: Vector3;
  6883. /**
  6884. * Radius of the bounding sphere in world space
  6885. */
  6886. radiusWorld: number;
  6887. /**
  6888. * Gets the minimum vector in local space
  6889. */
  6890. readonly minimum: Vector3;
  6891. /**
  6892. * Gets the maximum vector in local space
  6893. */
  6894. readonly maximum: Vector3;
  6895. private _worldMatrix;
  6896. private static readonly TmpVector3;
  6897. /**
  6898. * Creates a new bounding sphere
  6899. * @param min defines the minimum vector (in local space)
  6900. * @param max defines the maximum vector (in local space)
  6901. * @param worldMatrix defines the new world matrix
  6902. */
  6903. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6904. /**
  6905. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6906. * @param min defines the new minimum vector (in local space)
  6907. * @param max defines the new maximum vector (in local space)
  6908. * @param worldMatrix defines the new world matrix
  6909. */
  6910. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6911. /**
  6912. * Scale the current bounding sphere by applying a scale factor
  6913. * @param factor defines the scale factor to apply
  6914. * @returns the current bounding box
  6915. */
  6916. scale(factor: number): BoundingSphere;
  6917. /**
  6918. * Gets the world matrix of the bounding box
  6919. * @returns a matrix
  6920. */
  6921. getWorldMatrix(): DeepImmutable<Matrix>;
  6922. /** @hidden */ update(worldMatrix: DeepImmutable<Matrix>): void;
  6923. /**
  6924. * Tests if the bounding sphere is intersecting the frustum planes
  6925. * @param frustumPlanes defines the frustum planes to test
  6926. * @returns true if there is an intersection
  6927. */
  6928. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6929. /**
  6930. * Tests if the bounding sphere center is in between the frustum planes.
  6931. * Used for optimistic fast inclusion.
  6932. * @param frustumPlanes defines the frustum planes to test
  6933. * @returns true if the sphere center is in between the frustum planes
  6934. */
  6935. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6936. /**
  6937. * Tests if a point is inside the bounding sphere
  6938. * @param point defines the point to test
  6939. * @returns true if the point is inside the bounding sphere
  6940. */
  6941. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6942. /**
  6943. * Checks if two sphere intersct
  6944. * @param sphere0 sphere 0
  6945. * @param sphere1 sphere 1
  6946. * @returns true if the speres intersect
  6947. */
  6948. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6949. }
  6950. }
  6951. declare module BABYLON {
  6952. /**
  6953. * Class used to store bounding box information
  6954. */
  6955. export class BoundingBox implements ICullable {
  6956. /**
  6957. * Gets the 8 vectors representing the bounding box in local space
  6958. */
  6959. readonly vectors: Vector3[];
  6960. /**
  6961. * Gets the center of the bounding box in local space
  6962. */
  6963. readonly center: Vector3;
  6964. /**
  6965. * Gets the center of the bounding box in world space
  6966. */
  6967. readonly centerWorld: Vector3;
  6968. /**
  6969. * Gets the extend size in local space
  6970. */
  6971. readonly extendSize: Vector3;
  6972. /**
  6973. * Gets the extend size in world space
  6974. */
  6975. readonly extendSizeWorld: Vector3;
  6976. /**
  6977. * Gets the OBB (object bounding box) directions
  6978. */
  6979. readonly directions: Vector3[];
  6980. /**
  6981. * Gets the 8 vectors representing the bounding box in world space
  6982. */
  6983. readonly vectorsWorld: Vector3[];
  6984. /**
  6985. * Gets the minimum vector in world space
  6986. */
  6987. readonly minimumWorld: Vector3;
  6988. /**
  6989. * Gets the maximum vector in world space
  6990. */
  6991. readonly maximumWorld: Vector3;
  6992. /**
  6993. * Gets the minimum vector in local space
  6994. */
  6995. readonly minimum: Vector3;
  6996. /**
  6997. * Gets the maximum vector in local space
  6998. */
  6999. readonly maximum: Vector3;
  7000. private _worldMatrix;
  7001. private static readonly TmpVector3;
  7002. /**
  7003. * @hidden
  7004. */ tag: number;
  7005. /**
  7006. * Creates a new bounding box
  7007. * @param min defines the minimum vector (in local space)
  7008. * @param max defines the maximum vector (in local space)
  7009. * @param worldMatrix defines the new world matrix
  7010. */
  7011. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7012. /**
  7013. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7014. * @param min defines the new minimum vector (in local space)
  7015. * @param max defines the new maximum vector (in local space)
  7016. * @param worldMatrix defines the new world matrix
  7017. */
  7018. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7019. /**
  7020. * Scale the current bounding box by applying a scale factor
  7021. * @param factor defines the scale factor to apply
  7022. * @returns the current bounding box
  7023. */
  7024. scale(factor: number): BoundingBox;
  7025. /**
  7026. * Gets the world matrix of the bounding box
  7027. * @returns a matrix
  7028. */
  7029. getWorldMatrix(): DeepImmutable<Matrix>;
  7030. /** @hidden */ update(world: DeepImmutable<Matrix>): void;
  7031. /**
  7032. * Tests if the bounding box is intersecting the frustum planes
  7033. * @param frustumPlanes defines the frustum planes to test
  7034. * @returns true if there is an intersection
  7035. */
  7036. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7037. /**
  7038. * Tests if the bounding box is entirely inside the frustum planes
  7039. * @param frustumPlanes defines the frustum planes to test
  7040. * @returns true if there is an inclusion
  7041. */
  7042. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7043. /**
  7044. * Tests if a point is inside the bounding box
  7045. * @param point defines the point to test
  7046. * @returns true if the point is inside the bounding box
  7047. */
  7048. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7049. /**
  7050. * Tests if the bounding box intersects with a bounding sphere
  7051. * @param sphere defines the sphere to test
  7052. * @returns true if there is an intersection
  7053. */
  7054. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7055. /**
  7056. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7057. * @param min defines the min vector to use
  7058. * @param max defines the max vector to use
  7059. * @returns true if there is an intersection
  7060. */
  7061. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7062. /**
  7063. * Tests if two bounding boxes are intersections
  7064. * @param box0 defines the first box to test
  7065. * @param box1 defines the second box to test
  7066. * @returns true if there is an intersection
  7067. */
  7068. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7069. /**
  7070. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7071. * @param minPoint defines the minimum vector of the bounding box
  7072. * @param maxPoint defines the maximum vector of the bounding box
  7073. * @param sphereCenter defines the sphere center
  7074. * @param sphereRadius defines the sphere radius
  7075. * @returns true if there is an intersection
  7076. */
  7077. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7078. /**
  7079. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7080. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7081. * @param frustumPlanes defines the frustum planes to test
  7082. * @return true if there is an inclusion
  7083. */
  7084. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7085. /**
  7086. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7087. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7088. * @param frustumPlanes defines the frustum planes to test
  7089. * @return true if there is an intersection
  7090. */
  7091. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7092. }
  7093. }
  7094. declare module BABYLON {
  7095. /** @hidden */
  7096. export class Collider {
  7097. /** Define if a collision was found */
  7098. collisionFound: boolean;
  7099. /**
  7100. * Define last intersection point in local space
  7101. */
  7102. intersectionPoint: Vector3;
  7103. /**
  7104. * Define last collided mesh
  7105. */
  7106. collidedMesh: Nullable<AbstractMesh>;
  7107. private _collisionPoint;
  7108. private _planeIntersectionPoint;
  7109. private _tempVector;
  7110. private _tempVector2;
  7111. private _tempVector3;
  7112. private _tempVector4;
  7113. private _edge;
  7114. private _baseToVertex;
  7115. private _destinationPoint;
  7116. private _slidePlaneNormal;
  7117. private _displacementVector;
  7118. /** @hidden */ radius: Vector3;
  7119. /** @hidden */ retry: number;
  7120. private _velocity;
  7121. private _basePoint;
  7122. private _epsilon;
  7123. /** @hidden */ velocityWorldLength: number;
  7124. /** @hidden */ basePointWorld: Vector3;
  7125. private _velocityWorld;
  7126. private _normalizedVelocity;
  7127. /** @hidden */ initialVelocity: Vector3;
  7128. /** @hidden */ initialPosition: Vector3;
  7129. private _nearestDistance;
  7130. private _collisionMask;
  7131. collisionMask: number;
  7132. /**
  7133. * Gets the plane normal used to compute the sliding response (in local space)
  7134. */
  7135. readonly slidePlaneNormal: Vector3;
  7136. /** @hidden */ initialize(source: Vector3, dir: Vector3, e: number): void;
  7137. /** @hidden */ checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7138. /** @hidden */ canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7139. /** @hidden */ testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7140. /** @hidden */ collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7141. /** @hidden */ getResponse(pos: Vector3, vel: Vector3): void;
  7142. }
  7143. }
  7144. declare module BABYLON {
  7145. /**
  7146. * Interface for cullable objects
  7147. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7148. */
  7149. export interface ICullable {
  7150. /**
  7151. * Checks if the object or part of the object is in the frustum
  7152. * @param frustumPlanes Camera near/planes
  7153. * @returns true if the object is in frustum otherwise false
  7154. */
  7155. isInFrustum(frustumPlanes: Plane[]): boolean;
  7156. /**
  7157. * Checks if a cullable object (mesh...) is in the camera frustum
  7158. * Unlike isInFrustum this cheks the full bounding box
  7159. * @param frustumPlanes Camera near/planes
  7160. * @returns true if the object is in frustum otherwise false
  7161. */
  7162. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7163. }
  7164. /**
  7165. * Info for a bounding data of a mesh
  7166. */
  7167. export class BoundingInfo implements ICullable {
  7168. /**
  7169. * Bounding box for the mesh
  7170. */
  7171. readonly boundingBox: BoundingBox;
  7172. /**
  7173. * Bounding sphere for the mesh
  7174. */
  7175. readonly boundingSphere: BoundingSphere;
  7176. private _isLocked;
  7177. private static readonly TmpVector3;
  7178. /**
  7179. * Constructs bounding info
  7180. * @param minimum min vector of the bounding box/sphere
  7181. * @param maximum max vector of the bounding box/sphere
  7182. * @param worldMatrix defines the new world matrix
  7183. */
  7184. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7185. /**
  7186. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7187. * @param min defines the new minimum vector (in local space)
  7188. * @param max defines the new maximum vector (in local space)
  7189. * @param worldMatrix defines the new world matrix
  7190. */
  7191. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7192. /**
  7193. * min vector of the bounding box/sphere
  7194. */
  7195. readonly minimum: Vector3;
  7196. /**
  7197. * max vector of the bounding box/sphere
  7198. */
  7199. readonly maximum: Vector3;
  7200. /**
  7201. * If the info is locked and won't be updated to avoid perf overhead
  7202. */
  7203. isLocked: boolean;
  7204. /**
  7205. * Updates the bounding sphere and box
  7206. * @param world world matrix to be used to update
  7207. */
  7208. update(world: DeepImmutable<Matrix>): void;
  7209. /**
  7210. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7211. * @param center New center of the bounding info
  7212. * @param extend New extend of the bounding info
  7213. * @returns the current bounding info
  7214. */
  7215. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7216. /**
  7217. * Scale the current bounding info by applying a scale factor
  7218. * @param factor defines the scale factor to apply
  7219. * @returns the current bounding info
  7220. */
  7221. scale(factor: number): BoundingInfo;
  7222. /**
  7223. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7224. * @param frustumPlanes defines the frustum to test
  7225. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7226. * @returns true if the bounding info is in the frustum planes
  7227. */
  7228. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7229. /**
  7230. * Gets the world distance between the min and max points of the bounding box
  7231. */
  7232. readonly diagonalLength: number;
  7233. /**
  7234. * Checks if a cullable object (mesh...) is in the camera frustum
  7235. * Unlike isInFrustum this cheks the full bounding box
  7236. * @param frustumPlanes Camera near/planes
  7237. * @returns true if the object is in frustum otherwise false
  7238. */
  7239. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7240. /** @hidden */ checkCollision(collider: Collider): boolean;
  7241. /**
  7242. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7243. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7244. * @param point the point to check intersection with
  7245. * @returns if the point intersects
  7246. */
  7247. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7248. /**
  7249. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7250. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7251. * @param boundingInfo the bounding info to check intersection with
  7252. * @param precise if the intersection should be done using OBB
  7253. * @returns if the bounding info intersects
  7254. */
  7255. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7256. }
  7257. }
  7258. declare module BABYLON {
  7259. /**
  7260. * Defines an array and its length.
  7261. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7262. */
  7263. export interface ISmartArrayLike<T> {
  7264. /**
  7265. * The data of the array.
  7266. */
  7267. data: Array<T>;
  7268. /**
  7269. * The active length of the array.
  7270. */
  7271. length: number;
  7272. }
  7273. /**
  7274. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7275. */
  7276. export class SmartArray<T> implements ISmartArrayLike<T> {
  7277. /**
  7278. * The full set of data from the array.
  7279. */
  7280. data: Array<T>;
  7281. /**
  7282. * The active length of the array.
  7283. */
  7284. length: number;
  7285. protected _id: number;
  7286. /**
  7287. * Instantiates a Smart Array.
  7288. * @param capacity defines the default capacity of the array.
  7289. */
  7290. constructor(capacity: number);
  7291. /**
  7292. * Pushes a value at the end of the active data.
  7293. * @param value defines the object to push in the array.
  7294. */
  7295. push(value: T): void;
  7296. /**
  7297. * Iterates over the active data and apply the lambda to them.
  7298. * @param func defines the action to apply on each value.
  7299. */
  7300. forEach(func: (content: T) => void): void;
  7301. /**
  7302. * Sorts the full sets of data.
  7303. * @param compareFn defines the comparison function to apply.
  7304. */
  7305. sort(compareFn: (a: T, b: T) => number): void;
  7306. /**
  7307. * Resets the active data to an empty array.
  7308. */
  7309. reset(): void;
  7310. /**
  7311. * Releases all the data from the array as well as the array.
  7312. */
  7313. dispose(): void;
  7314. /**
  7315. * Concats the active data with a given array.
  7316. * @param array defines the data to concatenate with.
  7317. */
  7318. concat(array: any): void;
  7319. /**
  7320. * Returns the position of a value in the active data.
  7321. * @param value defines the value to find the index for
  7322. * @returns the index if found in the active data otherwise -1
  7323. */
  7324. indexOf(value: T): number;
  7325. /**
  7326. * Returns whether an element is part of the active data.
  7327. * @param value defines the value to look for
  7328. * @returns true if found in the active data otherwise false
  7329. */
  7330. contains(value: T): boolean;
  7331. private static _GlobalId;
  7332. }
  7333. /**
  7334. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7335. * The data in this array can only be present once
  7336. */
  7337. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7338. private _duplicateId;
  7339. /**
  7340. * Pushes a value at the end of the active data.
  7341. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7342. * @param value defines the object to push in the array.
  7343. */
  7344. push(value: T): void;
  7345. /**
  7346. * Pushes a value at the end of the active data.
  7347. * If the data is already present, it won t be added again
  7348. * @param value defines the object to push in the array.
  7349. * @returns true if added false if it was already present
  7350. */
  7351. pushNoDuplicate(value: T): boolean;
  7352. /**
  7353. * Resets the active data to an empty array.
  7354. */
  7355. reset(): void;
  7356. /**
  7357. * Concats the active data with a given array.
  7358. * This ensures no dupplicate will be present in the result.
  7359. * @param array defines the data to concatenate with.
  7360. */
  7361. concatWithNoDuplicate(array: any): void;
  7362. }
  7363. }
  7364. declare module BABYLON {
  7365. /**
  7366. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7367. * separate meshes. This can be use to improve performances.
  7368. * @see http://doc.babylonjs.com/how_to/multi_materials
  7369. */
  7370. export class MultiMaterial extends Material {
  7371. private _subMaterials;
  7372. /**
  7373. * Gets or Sets the list of Materials used within the multi material.
  7374. * They need to be ordered according to the submeshes order in the associated mesh
  7375. */
  7376. subMaterials: Nullable<Material>[];
  7377. /**
  7378. * Function used to align with Node.getChildren()
  7379. * @returns the list of Materials used within the multi material
  7380. */
  7381. getChildren(): Nullable<Material>[];
  7382. /**
  7383. * Instantiates a new Multi Material
  7384. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7385. * separate meshes. This can be use to improve performances.
  7386. * @see http://doc.babylonjs.com/how_to/multi_materials
  7387. * @param name Define the name in the scene
  7388. * @param scene Define the scene the material belongs to
  7389. */
  7390. constructor(name: string, scene: Scene);
  7391. private _hookArray;
  7392. /**
  7393. * Get one of the submaterial by its index in the submaterials array
  7394. * @param index The index to look the sub material at
  7395. * @returns The Material if the index has been defined
  7396. */
  7397. getSubMaterial(index: number): Nullable<Material>;
  7398. /**
  7399. * Get the list of active textures for the whole sub materials list.
  7400. * @returns All the textures that will be used during the rendering
  7401. */
  7402. getActiveTextures(): BaseTexture[];
  7403. /**
  7404. * Gets the current class name of the material e.g. "MultiMaterial"
  7405. * Mainly use in serialization.
  7406. * @returns the class name
  7407. */
  7408. getClassName(): string;
  7409. /**
  7410. * Checks if the material is ready to render the requested sub mesh
  7411. * @param mesh Define the mesh the submesh belongs to
  7412. * @param subMesh Define the sub mesh to look readyness for
  7413. * @param useInstances Define whether or not the material is used with instances
  7414. * @returns true if ready, otherwise false
  7415. */
  7416. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7417. /**
  7418. * Clones the current material and its related sub materials
  7419. * @param name Define the name of the newly cloned material
  7420. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7421. * @returns the cloned material
  7422. */
  7423. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7424. /**
  7425. * Serializes the materials into a JSON representation.
  7426. * @returns the JSON representation
  7427. */
  7428. serialize(): any;
  7429. /**
  7430. * Dispose the material and release its associated resources
  7431. * @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)
  7432. * @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)
  7433. * @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)
  7434. */
  7435. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7436. /**
  7437. * Creates a MultiMaterial from parsed MultiMaterial data.
  7438. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7439. * @param scene defines the hosting scene
  7440. * @returns a new MultiMaterial
  7441. */
  7442. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7443. }
  7444. }
  7445. declare module BABYLON {
  7446. /**
  7447. * Class used to represent data loading progression
  7448. */
  7449. export class SceneLoaderFlags {
  7450. private static _ForceFullSceneLoadingForIncremental;
  7451. private static _ShowLoadingScreen;
  7452. private static _CleanBoneMatrixWeights;
  7453. private static _loggingLevel;
  7454. /**
  7455. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7456. */
  7457. static ForceFullSceneLoadingForIncremental: boolean;
  7458. /**
  7459. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7460. */
  7461. static ShowLoadingScreen: boolean;
  7462. /**
  7463. * Defines the current logging level (while loading the scene)
  7464. * @ignorenaming
  7465. */
  7466. static loggingLevel: number;
  7467. /**
  7468. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7469. */
  7470. static CleanBoneMatrixWeights: boolean;
  7471. }
  7472. }
  7473. declare module BABYLON {
  7474. /**
  7475. * Class used to override all child animations of a given target
  7476. */
  7477. export class AnimationPropertiesOverride {
  7478. /**
  7479. * Gets or sets a value indicating if animation blending must be used
  7480. */
  7481. enableBlending: boolean;
  7482. /**
  7483. * Gets or sets the blending speed to use when enableBlending is true
  7484. */
  7485. blendingSpeed: number;
  7486. /**
  7487. * Gets or sets the default loop mode to use
  7488. */
  7489. loopMode: number;
  7490. }
  7491. }
  7492. declare module BABYLON {
  7493. /**
  7494. * Defines a target to use with MorphTargetManager
  7495. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  7496. */
  7497. export class MorphTarget implements IAnimatable {
  7498. /** defines the name of the target */
  7499. name: string;
  7500. /**
  7501. * Gets or sets the list of animations
  7502. */
  7503. animations: Animation[];
  7504. private _scene;
  7505. private _positions;
  7506. private _normals;
  7507. private _tangents;
  7508. private _influence;
  7509. /**
  7510. * Observable raised when the influence changes
  7511. */
  7512. onInfluenceChanged: Observable<boolean>;
  7513. /** @hidden */ onDataLayoutChanged: Observable<void>;
  7514. /**
  7515. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  7516. */
  7517. influence: number;
  7518. /**
  7519. * Gets or sets the id of the morph Target
  7520. */
  7521. id: string;
  7522. private _animationPropertiesOverride;
  7523. /**
  7524. * Gets or sets the animation properties override
  7525. */
  7526. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7527. /**
  7528. * Creates a new MorphTarget
  7529. * @param name defines the name of the target
  7530. * @param influence defines the influence to use
  7531. * @param scene defines the scene the morphtarget belongs to
  7532. */
  7533. constructor(
  7534. /** defines the name of the target */
  7535. name: string, influence?: number, scene?: Nullable<Scene>);
  7536. /**
  7537. * Gets a boolean defining if the target contains position data
  7538. */
  7539. readonly hasPositions: boolean;
  7540. /**
  7541. * Gets a boolean defining if the target contains normal data
  7542. */
  7543. readonly hasNormals: boolean;
  7544. /**
  7545. * Gets a boolean defining if the target contains tangent data
  7546. */
  7547. readonly hasTangents: boolean;
  7548. /**
  7549. * Affects position data to this target
  7550. * @param data defines the position data to use
  7551. */
  7552. setPositions(data: Nullable<FloatArray>): void;
  7553. /**
  7554. * Gets the position data stored in this target
  7555. * @returns a FloatArray containing the position data (or null if not present)
  7556. */
  7557. getPositions(): Nullable<FloatArray>;
  7558. /**
  7559. * Affects normal data to this target
  7560. * @param data defines the normal data to use
  7561. */
  7562. setNormals(data: Nullable<FloatArray>): void;
  7563. /**
  7564. * Gets the normal data stored in this target
  7565. * @returns a FloatArray containing the normal data (or null if not present)
  7566. */
  7567. getNormals(): Nullable<FloatArray>;
  7568. /**
  7569. * Affects tangent data to this target
  7570. * @param data defines the tangent data to use
  7571. */
  7572. setTangents(data: Nullable<FloatArray>): void;
  7573. /**
  7574. * Gets the tangent data stored in this target
  7575. * @returns a FloatArray containing the tangent data (or null if not present)
  7576. */
  7577. getTangents(): Nullable<FloatArray>;
  7578. /**
  7579. * Serializes the current target into a Serialization object
  7580. * @returns the serialized object
  7581. */
  7582. serialize(): any;
  7583. /**
  7584. * Returns the string "MorphTarget"
  7585. * @returns "MorphTarget"
  7586. */
  7587. getClassName(): string;
  7588. /**
  7589. * Creates a new target from serialized data
  7590. * @param serializationObject defines the serialized data to use
  7591. * @returns a new MorphTarget
  7592. */
  7593. static Parse(serializationObject: any): MorphTarget;
  7594. /**
  7595. * Creates a MorphTarget from mesh data
  7596. * @param mesh defines the source mesh
  7597. * @param name defines the name to use for the new target
  7598. * @param influence defines the influence to attach to the target
  7599. * @returns a new MorphTarget
  7600. */
  7601. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  7602. }
  7603. }
  7604. declare module BABYLON {
  7605. /**
  7606. * This class is used to deform meshes using morphing between different targets
  7607. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  7608. */
  7609. export class MorphTargetManager {
  7610. private _targets;
  7611. private _targetInfluenceChangedObservers;
  7612. private _targetDataLayoutChangedObservers;
  7613. private _activeTargets;
  7614. private _scene;
  7615. private _influences;
  7616. private _supportsNormals;
  7617. private _supportsTangents;
  7618. private _vertexCount;
  7619. private _uniqueId;
  7620. private _tempInfluences;
  7621. /**
  7622. * Creates a new MorphTargetManager
  7623. * @param scene defines the current scene
  7624. */
  7625. constructor(scene?: Nullable<Scene>);
  7626. /**
  7627. * Gets the unique ID of this manager
  7628. */
  7629. readonly uniqueId: number;
  7630. /**
  7631. * Gets the number of vertices handled by this manager
  7632. */
  7633. readonly vertexCount: number;
  7634. /**
  7635. * Gets a boolean indicating if this manager supports morphing of normals
  7636. */
  7637. readonly supportsNormals: boolean;
  7638. /**
  7639. * Gets a boolean indicating if this manager supports morphing of tangents
  7640. */
  7641. readonly supportsTangents: boolean;
  7642. /**
  7643. * Gets the number of targets stored in this manager
  7644. */
  7645. readonly numTargets: number;
  7646. /**
  7647. * Gets the number of influencers (ie. the number of targets with influences > 0)
  7648. */
  7649. readonly numInfluencers: number;
  7650. /**
  7651. * Gets the list of influences (one per target)
  7652. */
  7653. readonly influences: Float32Array;
  7654. /**
  7655. * Gets the active target at specified index. An active target is a target with an influence > 0
  7656. * @param index defines the index to check
  7657. * @returns the requested target
  7658. */
  7659. getActiveTarget(index: number): MorphTarget;
  7660. /**
  7661. * Gets the target at specified index
  7662. * @param index defines the index to check
  7663. * @returns the requested target
  7664. */
  7665. getTarget(index: number): MorphTarget;
  7666. /**
  7667. * Add a new target to this manager
  7668. * @param target defines the target to add
  7669. */
  7670. addTarget(target: MorphTarget): void;
  7671. /**
  7672. * Removes a target from the manager
  7673. * @param target defines the target to remove
  7674. */
  7675. removeTarget(target: MorphTarget): void;
  7676. /**
  7677. * Serializes the current manager into a Serialization object
  7678. * @returns the serialized object
  7679. */
  7680. serialize(): any;
  7681. private _syncActiveTargets;
  7682. /**
  7683. * Syncrhonize the targets with all the meshes using this morph target manager
  7684. */
  7685. synchronize(): void;
  7686. /**
  7687. * Creates a new MorphTargetManager from serialized data
  7688. * @param serializationObject defines the serialized data
  7689. * @param scene defines the hosting scene
  7690. * @returns the new MorphTargetManager
  7691. */
  7692. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  7693. }
  7694. }
  7695. declare module BABYLON {
  7696. /**
  7697. * Creates an instance based on a source mesh.
  7698. */
  7699. export class InstancedMesh extends AbstractMesh {
  7700. private _sourceMesh;
  7701. private _currentLOD;
  7702. /** @hidden */ indexInSourceMeshInstanceArray: number;
  7703. constructor(name: string, source: Mesh);
  7704. /**
  7705. * Returns the string "InstancedMesh".
  7706. */
  7707. getClassName(): string;
  7708. /**
  7709. * If the source mesh receives shadows
  7710. */
  7711. readonly receiveShadows: boolean;
  7712. /**
  7713. * The material of the source mesh
  7714. */
  7715. readonly material: Nullable<Material>;
  7716. /**
  7717. * Visibility of the source mesh
  7718. */
  7719. readonly visibility: number;
  7720. /**
  7721. * Skeleton of the source mesh
  7722. */
  7723. readonly skeleton: Nullable<Skeleton>;
  7724. /**
  7725. * Rendering ground id of the source mesh
  7726. */
  7727. renderingGroupId: number;
  7728. /**
  7729. * Returns the total number of vertices (integer).
  7730. */
  7731. getTotalVertices(): number;
  7732. /**
  7733. * Returns a positive integer : the total number of indices in this mesh geometry.
  7734. * @returns the numner of indices or zero if the mesh has no geometry.
  7735. */
  7736. getTotalIndices(): number;
  7737. /**
  7738. * The source mesh of the instance
  7739. */
  7740. readonly sourceMesh: Mesh;
  7741. /**
  7742. * Is this node ready to be used/rendered
  7743. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  7744. * @return {boolean} is it ready
  7745. */
  7746. isReady(completeCheck?: boolean): boolean;
  7747. /**
  7748. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  7749. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  7750. * @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.
  7751. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  7752. */
  7753. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  7754. /**
  7755. * Sets the vertex data of the mesh geometry for the requested `kind`.
  7756. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  7757. * The `data` are either a numeric array either a Float32Array.
  7758. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  7759. * 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).
  7760. * Note that a new underlying VertexBuffer object is created each call.
  7761. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  7762. *
  7763. * Possible `kind` values :
  7764. * - VertexBuffer.PositionKind
  7765. * - VertexBuffer.UVKind
  7766. * - VertexBuffer.UV2Kind
  7767. * - VertexBuffer.UV3Kind
  7768. * - VertexBuffer.UV4Kind
  7769. * - VertexBuffer.UV5Kind
  7770. * - VertexBuffer.UV6Kind
  7771. * - VertexBuffer.ColorKind
  7772. * - VertexBuffer.MatricesIndicesKind
  7773. * - VertexBuffer.MatricesIndicesExtraKind
  7774. * - VertexBuffer.MatricesWeightsKind
  7775. * - VertexBuffer.MatricesWeightsExtraKind
  7776. *
  7777. * Returns the Mesh.
  7778. */
  7779. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  7780. /**
  7781. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  7782. * If the mesh has no geometry, it is simply returned as it is.
  7783. * The `data` are either a numeric array either a Float32Array.
  7784. * No new underlying VertexBuffer object is created.
  7785. * 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.
  7786. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  7787. *
  7788. * Possible `kind` values :
  7789. * - VertexBuffer.PositionKind
  7790. * - VertexBuffer.UVKind
  7791. * - VertexBuffer.UV2Kind
  7792. * - VertexBuffer.UV3Kind
  7793. * - VertexBuffer.UV4Kind
  7794. * - VertexBuffer.UV5Kind
  7795. * - VertexBuffer.UV6Kind
  7796. * - VertexBuffer.ColorKind
  7797. * - VertexBuffer.MatricesIndicesKind
  7798. * - VertexBuffer.MatricesIndicesExtraKind
  7799. * - VertexBuffer.MatricesWeightsKind
  7800. * - VertexBuffer.MatricesWeightsExtraKind
  7801. *
  7802. * Returns the Mesh.
  7803. */
  7804. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  7805. /**
  7806. * Sets the mesh indices.
  7807. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  7808. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  7809. * This method creates a new index buffer each call.
  7810. * Returns the Mesh.
  7811. */
  7812. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  7813. /**
  7814. * Boolean : True if the mesh owns the requested kind of data.
  7815. */
  7816. isVerticesDataPresent(kind: string): boolean;
  7817. /**
  7818. * Returns an array of indices (IndicesArray).
  7819. */
  7820. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  7821. /**
  7822. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  7823. * This means the mesh underlying bounding box and sphere are recomputed.
  7824. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  7825. * @returns the current mesh
  7826. */
  7827. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  7828. /** @hidden */ preActivate(): InstancedMesh;
  7829. /** @hidden */ activate(renderId: number): InstancedMesh;
  7830. /**
  7831. * Returns the current associated LOD AbstractMesh.
  7832. */
  7833. getLOD(camera: Camera): AbstractMesh;
  7834. /** @hidden */ syncSubMeshes(): InstancedMesh;
  7835. /** @hidden */ generatePointsArray(): boolean;
  7836. /**
  7837. * Creates a new InstancedMesh from the current mesh.
  7838. * - name (string) : the cloned mesh name
  7839. * - newParent (optional Node) : the optional Node to parent the clone to.
  7840. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  7841. *
  7842. * Returns the clone.
  7843. */
  7844. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  7845. /**
  7846. * Disposes the InstancedMesh.
  7847. * Returns nothing.
  7848. */
  7849. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7850. }
  7851. }
  7852. declare module BABYLON {
  7853. /**
  7854. * Class for creating a cube texture
  7855. */
  7856. export class CubeTexture extends BaseTexture {
  7857. private _delayedOnLoad;
  7858. /**
  7859. * The url of the texture
  7860. */
  7861. url: string;
  7862. /**
  7863. * Gets or sets the center of the bounding box associated with the cube texture.
  7864. * It must define where the camera used to render the texture was set
  7865. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7866. */
  7867. boundingBoxPosition: Vector3;
  7868. private _boundingBoxSize;
  7869. /**
  7870. * Gets or sets the size of the bounding box associated with the cube texture
  7871. * When defined, the cubemap will switch to local mode
  7872. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7873. * @example https://www.babylonjs-playground.com/#RNASML
  7874. */
  7875. /**
  7876. * Returns the bounding box size
  7877. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7878. */
  7879. boundingBoxSize: Vector3;
  7880. protected _rotationY: number;
  7881. /**
  7882. * Sets texture matrix rotation angle around Y axis in radians.
  7883. */
  7884. /**
  7885. * Gets texture matrix rotation angle around Y axis radians.
  7886. */
  7887. rotationY: number;
  7888. /**
  7889. * Are mip maps generated for this texture or not.
  7890. */
  7891. readonly noMipmap: boolean;
  7892. private _noMipmap;
  7893. private _files;
  7894. private _extensions;
  7895. private _textureMatrix;
  7896. private _format;
  7897. private _createPolynomials;
  7898. /** @hidden */ prefiltered: boolean;
  7899. /**
  7900. * Creates a cube texture from an array of image urls
  7901. * @param files defines an array of image urls
  7902. * @param scene defines the hosting scene
  7903. * @param noMipmap specifies if mip maps are not used
  7904. * @returns a cube texture
  7905. */
  7906. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7907. /**
  7908. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7909. * @param url defines the url of the prefiltered texture
  7910. * @param scene defines the scene the texture is attached to
  7911. * @param forcedExtension defines the extension of the file if different from the url
  7912. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7913. * @return the prefiltered texture
  7914. */
  7915. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7916. /**
  7917. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7918. * as prefiltered data.
  7919. * @param rootUrl defines the url of the texture or the root name of the six images
  7920. * @param scene defines the scene the texture is attached to
  7921. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7922. * @param noMipmap defines if mipmaps should be created or not
  7923. * @param files defines the six files to load for the different faces
  7924. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7925. * @param onError defines a callback triggered in case of error during load
  7926. * @param format defines the internal format to use for the texture once loaded
  7927. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7928. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7929. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7930. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7931. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7932. * @return the cube texture
  7933. */
  7934. 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);
  7935. /**
  7936. * Get the current class name of the texture useful for serialization or dynamic coding.
  7937. * @returns "CubeTexture"
  7938. */
  7939. getClassName(): string;
  7940. /**
  7941. * Update the url (and optional buffer) of this texture if url was null during construction.
  7942. * @param url the url of the texture
  7943. * @param forcedExtension defines the extension to use
  7944. * @param onLoad callback called when the texture is loaded (defaults to null)
  7945. */
  7946. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7947. /**
  7948. * Delays loading of the cube texture
  7949. * @param forcedExtension defines the extension to use
  7950. */
  7951. delayLoad(forcedExtension?: string): void;
  7952. /**
  7953. * Returns the reflection texture matrix
  7954. * @returns the reflection texture matrix
  7955. */
  7956. getReflectionTextureMatrix(): Matrix;
  7957. /**
  7958. * Sets the reflection texture matrix
  7959. * @param value Reflection texture matrix
  7960. */
  7961. setReflectionTextureMatrix(value: Matrix): void;
  7962. /**
  7963. * Parses text to create a cube texture
  7964. * @param parsedTexture define the serialized text to read from
  7965. * @param scene defines the hosting scene
  7966. * @param rootUrl defines the root url of the cube texture
  7967. * @returns a cube texture
  7968. */
  7969. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7970. /**
  7971. * Makes a clone, or deep copy, of the cube texture
  7972. * @returns a new cube texture
  7973. */
  7974. clone(): CubeTexture;
  7975. }
  7976. }
  7977. declare module BABYLON {
  7978. /** @hidden */
  7979. export var postprocessVertexShader: {
  7980. name: string;
  7981. shader: string;
  7982. };
  7983. }
  7984. declare module BABYLON {
  7985. /**
  7986. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7987. * This is the base of the follow, arc rotate cameras and Free camera
  7988. * @see http://doc.babylonjs.com/features/cameras
  7989. */
  7990. export class TargetCamera extends Camera {
  7991. private static _RigCamTransformMatrix;
  7992. private static _TargetTransformMatrix;
  7993. private static _TargetFocalPoint;
  7994. /**
  7995. * Define the current direction the camera is moving to
  7996. */
  7997. cameraDirection: Vector3;
  7998. /**
  7999. * Define the current rotation the camera is rotating to
  8000. */
  8001. cameraRotation: Vector2;
  8002. /**
  8003. * When set, the up vector of the camera will be updated by the rotation of the camera
  8004. */
  8005. updateUpVectorFromRotation: boolean;
  8006. private _tmpQuaternion;
  8007. /**
  8008. * Define the current rotation of the camera
  8009. */
  8010. rotation: Vector3;
  8011. /**
  8012. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8013. */
  8014. rotationQuaternion: Quaternion;
  8015. /**
  8016. * Define the current speed of the camera
  8017. */
  8018. speed: number;
  8019. /**
  8020. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8021. * around all axis.
  8022. */
  8023. noRotationConstraint: boolean;
  8024. /**
  8025. * Define the current target of the camera as an object or a position.
  8026. */
  8027. lockedTarget: any;
  8028. /** @hidden */ currentTarget: Vector3;
  8029. /** @hidden */ initialFocalDistance: number;
  8030. /** @hidden */ viewMatrix: Matrix;
  8031. /** @hidden */ camMatrix: Matrix;
  8032. /** @hidden */ cameraTransformMatrix: Matrix;
  8033. /** @hidden */ cameraRotationMatrix: Matrix;
  8034. /** @hidden */ referencePoint: Vector3;
  8035. /** @hidden */ transformedReferencePoint: Vector3;
  8036. protected _globalCurrentTarget: Vector3;
  8037. protected _globalCurrentUpVector: Vector3;
  8038. /** @hidden */ reset: () => void;
  8039. private _defaultUp;
  8040. /**
  8041. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8042. * This is the base of the follow, arc rotate cameras and Free camera
  8043. * @see http://doc.babylonjs.com/features/cameras
  8044. * @param name Defines the name of the camera in the scene
  8045. * @param position Defines the start position of the camera in the scene
  8046. * @param scene Defines the scene the camera belongs to
  8047. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8048. */
  8049. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8050. /**
  8051. * Gets the position in front of the camera at a given distance.
  8052. * @param distance The distance from the camera we want the position to be
  8053. * @returns the position
  8054. */
  8055. getFrontPosition(distance: number): Vector3;
  8056. /** @hidden */ getLockedTargetPosition(): Nullable<Vector3>;
  8057. private _storedPosition;
  8058. private _storedRotation;
  8059. private _storedRotationQuaternion;
  8060. /**
  8061. * Store current camera state of the camera (fov, position, rotation, etc..)
  8062. * @returns the camera
  8063. */
  8064. storeState(): Camera;
  8065. /**
  8066. * Restored camera state. You must call storeState() first
  8067. * @returns whether it was successful or not
  8068. * @hidden
  8069. */ restoreStateValues(): boolean;
  8070. /** @hidden */ initCache(): void;
  8071. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  8072. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  8073. /** @hidden */ computeLocalCameraSpeed(): number;
  8074. /** @hidden */
  8075. setTarget(target: Vector3): void;
  8076. /**
  8077. * Return the current target position of the camera. This value is expressed in local space.
  8078. * @returns the target position
  8079. */
  8080. getTarget(): Vector3;
  8081. /** @hidden */ decideIfNeedsToMove(): boolean;
  8082. /** @hidden */ updatePosition(): void;
  8083. /** @hidden */ checkInputs(): void;
  8084. protected _updateCameraRotationMatrix(): void;
  8085. /**
  8086. * 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)
  8087. * @returns the current camera
  8088. */
  8089. private _rotateUpVectorWithCameraRotationMatrix;
  8090. private _cachedRotationZ;
  8091. private _cachedQuaternionRotationZ;
  8092. /** @hidden */ getViewMatrix(): Matrix;
  8093. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8094. /**
  8095. * @hidden
  8096. */
  8097. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8098. /**
  8099. * @hidden
  8100. */ updateRigCameras(): void;
  8101. private _getRigCamPositionAndTarget;
  8102. /**
  8103. * Gets the current object class name.
  8104. * @return the class name
  8105. */
  8106. getClassName(): string;
  8107. }
  8108. }
  8109. declare module BABYLON {
  8110. /**
  8111. * @ignore
  8112. * This is a list of all the different input types that are available in the application.
  8113. * Fo instance: ArcRotateCameraGamepadInput...
  8114. */
  8115. export var CameraInputTypes: {};
  8116. /**
  8117. * This is the contract to implement in order to create a new input class.
  8118. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8119. */
  8120. export interface ICameraInput<TCamera extends Camera> {
  8121. /**
  8122. * Defines the camera the input is attached to.
  8123. */
  8124. camera: Nullable<TCamera>;
  8125. /**
  8126. * Gets the class name of the current intput.
  8127. * @returns the class name
  8128. */
  8129. getClassName(): string;
  8130. /**
  8131. * Get the friendly name associated with the input class.
  8132. * @returns the input friendly name
  8133. */
  8134. getSimpleName(): string;
  8135. /**
  8136. * Attach the input controls to a specific dom element to get the input from.
  8137. * @param element Defines the element the controls should be listened from
  8138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8139. */
  8140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8141. /**
  8142. * Detach the current controls from the specified dom element.
  8143. * @param element Defines the element to stop listening the inputs from
  8144. */
  8145. detachControl(element: Nullable<HTMLElement>): void;
  8146. /**
  8147. * Update the current camera state depending on the inputs that have been used this frame.
  8148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8149. */
  8150. checkInputs?: () => void;
  8151. }
  8152. /**
  8153. * Represents a map of input types to input instance or input index to input instance.
  8154. */
  8155. export interface CameraInputsMap<TCamera extends Camera> {
  8156. /**
  8157. * Accessor to the input by input type.
  8158. */
  8159. [name: string]: ICameraInput<TCamera>;
  8160. /**
  8161. * Accessor to the input by input index.
  8162. */
  8163. [idx: number]: ICameraInput<TCamera>;
  8164. }
  8165. /**
  8166. * This represents the input manager used within a camera.
  8167. * It helps dealing with all the different kind of input attached to a camera.
  8168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8169. */
  8170. export class CameraInputsManager<TCamera extends Camera> {
  8171. /**
  8172. * Defines the list of inputs attahed to the camera.
  8173. */
  8174. attached: CameraInputsMap<TCamera>;
  8175. /**
  8176. * Defines the dom element the camera is collecting inputs from.
  8177. * This is null if the controls have not been attached.
  8178. */
  8179. attachedElement: Nullable<HTMLElement>;
  8180. /**
  8181. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8182. */
  8183. noPreventDefault: boolean;
  8184. /**
  8185. * Defined the camera the input manager belongs to.
  8186. */
  8187. camera: TCamera;
  8188. /**
  8189. * Update the current camera state depending on the inputs that have been used this frame.
  8190. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8191. */
  8192. checkInputs: () => void;
  8193. /**
  8194. * Instantiate a new Camera Input Manager.
  8195. * @param camera Defines the camera the input manager blongs to
  8196. */
  8197. constructor(camera: TCamera);
  8198. /**
  8199. * Add an input method to a camera
  8200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8201. * @param input camera input method
  8202. */
  8203. add(input: ICameraInput<TCamera>): void;
  8204. /**
  8205. * Remove a specific input method from a camera
  8206. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8207. * @param inputToRemove camera input method
  8208. */
  8209. remove(inputToRemove: ICameraInput<TCamera>): void;
  8210. /**
  8211. * Remove a specific input type from a camera
  8212. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8213. * @param inputType the type of the input to remove
  8214. */
  8215. removeByType(inputType: string): void;
  8216. private _addCheckInputs;
  8217. /**
  8218. * Attach the input controls to the currently attached dom element to listen the events from.
  8219. * @param input Defines the input to attach
  8220. */
  8221. attachInput(input: ICameraInput<TCamera>): void;
  8222. /**
  8223. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8224. * @param element Defines the dom element to collect the events from
  8225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8226. */
  8227. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8228. /**
  8229. * Detach the current manager inputs controls from a specific dom element.
  8230. * @param element Defines the dom element to collect the events from
  8231. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8232. */
  8233. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8234. /**
  8235. * Rebuild the dynamic inputCheck function from the current list of
  8236. * defined inputs in the manager.
  8237. */
  8238. rebuildInputCheck(): void;
  8239. /**
  8240. * Remove all attached input methods from a camera
  8241. */
  8242. clear(): void;
  8243. /**
  8244. * Serialize the current input manager attached to a camera.
  8245. * This ensures than once parsed,
  8246. * the input associated to the camera will be identical to the current ones
  8247. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8248. */
  8249. serialize(serializedCamera: any): void;
  8250. /**
  8251. * Parses an input manager serialized JSON to restore the previous list of inputs
  8252. * and states associated to a camera.
  8253. * @param parsedCamera Defines the JSON to parse
  8254. */
  8255. parse(parsedCamera: any): void;
  8256. }
  8257. }
  8258. declare module BABYLON {
  8259. /**
  8260. * Gather the list of keyboard event types as constants.
  8261. */
  8262. export class KeyboardEventTypes {
  8263. /**
  8264. * The keydown event is fired when a key becomes active (pressed).
  8265. */
  8266. static readonly KEYDOWN: number;
  8267. /**
  8268. * The keyup event is fired when a key has been released.
  8269. */
  8270. static readonly KEYUP: number;
  8271. }
  8272. /**
  8273. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8274. */
  8275. export class KeyboardInfo {
  8276. /**
  8277. * Defines the type of event (KeyboardEventTypes)
  8278. */
  8279. type: number;
  8280. /**
  8281. * Defines the related dom event
  8282. */
  8283. event: KeyboardEvent;
  8284. /**
  8285. * Instantiates a new keyboard info.
  8286. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8287. * @param type Defines the type of event (KeyboardEventTypes)
  8288. * @param event Defines the related dom event
  8289. */
  8290. constructor(
  8291. /**
  8292. * Defines the type of event (KeyboardEventTypes)
  8293. */
  8294. type: number,
  8295. /**
  8296. * Defines the related dom event
  8297. */
  8298. event: KeyboardEvent);
  8299. }
  8300. /**
  8301. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8302. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8303. */
  8304. export class KeyboardInfoPre extends KeyboardInfo {
  8305. /**
  8306. * Defines the type of event (KeyboardEventTypes)
  8307. */
  8308. type: number;
  8309. /**
  8310. * Defines the related dom event
  8311. */
  8312. event: KeyboardEvent;
  8313. /**
  8314. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8315. */
  8316. skipOnPointerObservable: boolean;
  8317. /**
  8318. * Instantiates a new keyboard pre info.
  8319. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8320. * @param type Defines the type of event (KeyboardEventTypes)
  8321. * @param event Defines the related dom event
  8322. */
  8323. constructor(
  8324. /**
  8325. * Defines the type of event (KeyboardEventTypes)
  8326. */
  8327. type: number,
  8328. /**
  8329. * Defines the related dom event
  8330. */
  8331. event: KeyboardEvent);
  8332. }
  8333. }
  8334. declare module BABYLON {
  8335. /**
  8336. * Manage the keyboard inputs to control the movement of a free camera.
  8337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8338. */
  8339. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8340. /**
  8341. * Defines the camera the input is attached to.
  8342. */
  8343. camera: FreeCamera;
  8344. /**
  8345. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8346. */
  8347. keysUp: number[];
  8348. /**
  8349. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8350. */
  8351. keysDown: number[];
  8352. /**
  8353. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8354. */
  8355. keysLeft: number[];
  8356. /**
  8357. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8358. */
  8359. keysRight: number[];
  8360. private _keys;
  8361. private _onCanvasBlurObserver;
  8362. private _onKeyboardObserver;
  8363. private _engine;
  8364. private _scene;
  8365. /**
  8366. * Attach the input controls to a specific dom element to get the input from.
  8367. * @param element Defines the element the controls should be listened from
  8368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8369. */
  8370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8371. /**
  8372. * Detach the current controls from the specified dom element.
  8373. * @param element Defines the element to stop listening the inputs from
  8374. */
  8375. detachControl(element: Nullable<HTMLElement>): void;
  8376. /**
  8377. * Update the current camera state depending on the inputs that have been used this frame.
  8378. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8379. */
  8380. checkInputs(): void;
  8381. /**
  8382. * Gets the class name of the current intput.
  8383. * @returns the class name
  8384. */
  8385. getClassName(): string;
  8386. /** @hidden */ onLostFocus(): void;
  8387. /**
  8388. * Get the friendly name associated with the input class.
  8389. * @returns the input friendly name
  8390. */
  8391. getSimpleName(): string;
  8392. }
  8393. }
  8394. declare module BABYLON {
  8395. /**
  8396. * Interface used to define ActionEvent
  8397. */
  8398. export interface IActionEvent {
  8399. /** The mesh or sprite that triggered the action */
  8400. source: any;
  8401. /** The X mouse cursor position at the time of the event */
  8402. pointerX: number;
  8403. /** The Y mouse cursor position at the time of the event */
  8404. pointerY: number;
  8405. /** The mesh that is currently pointed at (can be null) */
  8406. meshUnderPointer: Nullable<AbstractMesh>;
  8407. /** the original (browser) event that triggered the ActionEvent */
  8408. sourceEvent?: any;
  8409. /** additional data for the event */
  8410. additionalData?: any;
  8411. }
  8412. /**
  8413. * ActionEvent is the event being sent when an action is triggered.
  8414. */
  8415. export class ActionEvent implements IActionEvent {
  8416. /** The mesh or sprite that triggered the action */
  8417. source: any;
  8418. /** The X mouse cursor position at the time of the event */
  8419. pointerX: number;
  8420. /** The Y mouse cursor position at the time of the event */
  8421. pointerY: number;
  8422. /** The mesh that is currently pointed at (can be null) */
  8423. meshUnderPointer: Nullable<AbstractMesh>;
  8424. /** the original (browser) event that triggered the ActionEvent */
  8425. sourceEvent?: any;
  8426. /** additional data for the event */
  8427. additionalData?: any;
  8428. /**
  8429. * Creates a new ActionEvent
  8430. * @param source The mesh or sprite that triggered the action
  8431. * @param pointerX The X mouse cursor position at the time of the event
  8432. * @param pointerY The Y mouse cursor position at the time of the event
  8433. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  8434. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  8435. * @param additionalData additional data for the event
  8436. */
  8437. constructor(
  8438. /** The mesh or sprite that triggered the action */
  8439. source: any,
  8440. /** The X mouse cursor position at the time of the event */
  8441. pointerX: number,
  8442. /** The Y mouse cursor position at the time of the event */
  8443. pointerY: number,
  8444. /** The mesh that is currently pointed at (can be null) */
  8445. meshUnderPointer: Nullable<AbstractMesh>,
  8446. /** the original (browser) event that triggered the ActionEvent */
  8447. sourceEvent?: any,
  8448. /** additional data for the event */
  8449. additionalData?: any);
  8450. /**
  8451. * Helper function to auto-create an ActionEvent from a source mesh.
  8452. * @param source The source mesh that triggered the event
  8453. * @param evt The original (browser) event
  8454. * @param additionalData additional data for the event
  8455. * @returns the new ActionEvent
  8456. */
  8457. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  8458. /**
  8459. * Helper function to auto-create an ActionEvent from a source sprite
  8460. * @param source The source sprite that triggered the event
  8461. * @param scene Scene associated with the sprite
  8462. * @param evt The original (browser) event
  8463. * @param additionalData additional data for the event
  8464. * @returns the new ActionEvent
  8465. */
  8466. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  8467. /**
  8468. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  8469. * @param scene the scene where the event occurred
  8470. * @param evt The original (browser) event
  8471. * @returns the new ActionEvent
  8472. */
  8473. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  8474. /**
  8475. * Helper function to auto-create an ActionEvent from a primitive
  8476. * @param prim defines the target primitive
  8477. * @param pointerPos defines the pointer position
  8478. * @param evt The original (browser) event
  8479. * @param additionalData additional data for the event
  8480. * @returns the new ActionEvent
  8481. */
  8482. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  8483. }
  8484. }
  8485. declare module BABYLON {
  8486. /**
  8487. * Interface describing all the common properties and methods a shadow light needs to implement.
  8488. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8489. * as well as binding the different shadow properties to the effects.
  8490. */
  8491. export interface IShadowLight extends Light {
  8492. /**
  8493. * The light id in the scene (used in scene.findLighById for instance)
  8494. */
  8495. id: string;
  8496. /**
  8497. * The position the shdow will be casted from.
  8498. */
  8499. position: Vector3;
  8500. /**
  8501. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8502. */
  8503. direction: Vector3;
  8504. /**
  8505. * The transformed position. Position of the light in world space taking parenting in account.
  8506. */
  8507. transformedPosition: Vector3;
  8508. /**
  8509. * The transformed direction. Direction of the light in world space taking parenting in account.
  8510. */
  8511. transformedDirection: Vector3;
  8512. /**
  8513. * The friendly name of the light in the scene.
  8514. */
  8515. name: string;
  8516. /**
  8517. * Defines the shadow projection clipping minimum z value.
  8518. */
  8519. shadowMinZ: number;
  8520. /**
  8521. * Defines the shadow projection clipping maximum z value.
  8522. */
  8523. shadowMaxZ: number;
  8524. /**
  8525. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8526. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8527. */
  8528. computeTransformedInformation(): boolean;
  8529. /**
  8530. * Gets the scene the light belongs to.
  8531. * @returns The scene
  8532. */
  8533. getScene(): Scene;
  8534. /**
  8535. * Callback defining a custom Projection Matrix Builder.
  8536. * This can be used to override the default projection matrix computation.
  8537. */
  8538. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8539. /**
  8540. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8541. * @param matrix The materix to updated with the projection information
  8542. * @param viewMatrix The transform matrix of the light
  8543. * @param renderList The list of mesh to render in the map
  8544. * @returns The current light
  8545. */
  8546. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8547. /**
  8548. * Gets the current depth scale used in ESM.
  8549. * @returns The scale
  8550. */
  8551. getDepthScale(): number;
  8552. /**
  8553. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8554. * @returns true if a cube texture needs to be use
  8555. */
  8556. needCube(): boolean;
  8557. /**
  8558. * Detects if the projection matrix requires to be recomputed this frame.
  8559. * @returns true if it requires to be recomputed otherwise, false.
  8560. */
  8561. needProjectionMatrixCompute(): boolean;
  8562. /**
  8563. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8564. */
  8565. forceProjectionMatrixCompute(): void;
  8566. /**
  8567. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8568. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8569. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8570. */
  8571. getShadowDirection(faceIndex?: number): Vector3;
  8572. /**
  8573. * Gets the minZ used for shadow according to both the scene and the light.
  8574. * @param activeCamera The camera we are returning the min for
  8575. * @returns the depth min z
  8576. */
  8577. getDepthMinZ(activeCamera: Camera): number;
  8578. /**
  8579. * Gets the maxZ used for shadow according to both the scene and the light.
  8580. * @param activeCamera The camera we are returning the max for
  8581. * @returns the depth max z
  8582. */
  8583. getDepthMaxZ(activeCamera: Camera): number;
  8584. }
  8585. /**
  8586. * Base implementation IShadowLight
  8587. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8588. */
  8589. export abstract class ShadowLight extends Light implements IShadowLight {
  8590. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8591. protected _position: Vector3;
  8592. protected _setPosition(value: Vector3): void;
  8593. /**
  8594. * Sets the position the shadow will be casted from. Also use as the light position for both
  8595. * point and spot lights.
  8596. */
  8597. /**
  8598. * Sets the position the shadow will be casted from. Also use as the light position for both
  8599. * point and spot lights.
  8600. */
  8601. position: Vector3;
  8602. protected _direction: Vector3;
  8603. protected _setDirection(value: Vector3): void;
  8604. /**
  8605. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8606. * Also use as the light direction on spot and directional lights.
  8607. */
  8608. /**
  8609. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8610. * Also use as the light direction on spot and directional lights.
  8611. */
  8612. direction: Vector3;
  8613. private _shadowMinZ;
  8614. /**
  8615. * Gets the shadow projection clipping minimum z value.
  8616. */
  8617. /**
  8618. * Sets the shadow projection clipping minimum z value.
  8619. */
  8620. shadowMinZ: number;
  8621. private _shadowMaxZ;
  8622. /**
  8623. * Sets the shadow projection clipping maximum z value.
  8624. */
  8625. /**
  8626. * Gets the shadow projection clipping maximum z value.
  8627. */
  8628. shadowMaxZ: number;
  8629. /**
  8630. * Callback defining a custom Projection Matrix Builder.
  8631. * This can be used to override the default projection matrix computation.
  8632. */
  8633. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8634. /**
  8635. * The transformed position. Position of the light in world space taking parenting in account.
  8636. */
  8637. transformedPosition: Vector3;
  8638. /**
  8639. * The transformed direction. Direction of the light in world space taking parenting in account.
  8640. */
  8641. transformedDirection: Vector3;
  8642. private _needProjectionMatrixCompute;
  8643. /**
  8644. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8645. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8646. */
  8647. computeTransformedInformation(): boolean;
  8648. /**
  8649. * Return the depth scale used for the shadow map.
  8650. * @returns the depth scale.
  8651. */
  8652. getDepthScale(): number;
  8653. /**
  8654. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8655. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8656. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8657. */
  8658. getShadowDirection(faceIndex?: number): Vector3;
  8659. /**
  8660. * Returns the ShadowLight absolute position in the World.
  8661. * @returns the position vector in world space
  8662. */
  8663. getAbsolutePosition(): Vector3;
  8664. /**
  8665. * Sets the ShadowLight direction toward the passed target.
  8666. * @param target The point to target in local space
  8667. * @returns the updated ShadowLight direction
  8668. */
  8669. setDirectionToTarget(target: Vector3): Vector3;
  8670. /**
  8671. * Returns the light rotation in euler definition.
  8672. * @returns the x y z rotation in local space.
  8673. */
  8674. getRotation(): Vector3;
  8675. /**
  8676. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8677. * @returns true if a cube texture needs to be use
  8678. */
  8679. needCube(): boolean;
  8680. /**
  8681. * Detects if the projection matrix requires to be recomputed this frame.
  8682. * @returns true if it requires to be recomputed otherwise, false.
  8683. */
  8684. needProjectionMatrixCompute(): boolean;
  8685. /**
  8686. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8687. */
  8688. forceProjectionMatrixCompute(): void;
  8689. /** @hidden */ initCache(): void;
  8690. /** @hidden */ isSynchronized(): boolean;
  8691. /**
  8692. * Computes the world matrix of the node
  8693. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8694. * @returns the world matrix
  8695. */
  8696. computeWorldMatrix(force?: boolean): Matrix;
  8697. /**
  8698. * Gets the minZ used for shadow according to both the scene and the light.
  8699. * @param activeCamera The camera we are returning the min for
  8700. * @returns the depth min z
  8701. */
  8702. getDepthMinZ(activeCamera: Camera): number;
  8703. /**
  8704. * Gets the maxZ used for shadow according to both the scene and the light.
  8705. * @param activeCamera The camera we are returning the max for
  8706. * @returns the depth max z
  8707. */
  8708. getDepthMaxZ(activeCamera: Camera): number;
  8709. /**
  8710. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8711. * @param matrix The materix to updated with the projection information
  8712. * @param viewMatrix The transform matrix of the light
  8713. * @param renderList The list of mesh to render in the map
  8714. * @returns The current light
  8715. */
  8716. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8717. }
  8718. }
  8719. declare module BABYLON {
  8720. /**
  8721. * "Static Class" containing the most commonly used helper while dealing with material for
  8722. * rendering purpose.
  8723. *
  8724. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8725. *
  8726. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8727. */
  8728. export class MaterialHelper {
  8729. /**
  8730. * Bind the current view position to an effect.
  8731. * @param effect The effect to be bound
  8732. * @param scene The scene the eyes position is used from
  8733. */
  8734. static BindEyePosition(effect: Effect, scene: Scene): void;
  8735. /**
  8736. * Helps preparing the defines values about the UVs in used in the effect.
  8737. * UVs are shared as much as we can accross channels in the shaders.
  8738. * @param texture The texture we are preparing the UVs for
  8739. * @param defines The defines to update
  8740. * @param key The channel key "diffuse", "specular"... used in the shader
  8741. */
  8742. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8743. /**
  8744. * Binds a texture matrix value to its corrsponding uniform
  8745. * @param texture The texture to bind the matrix for
  8746. * @param uniformBuffer The uniform buffer receivin the data
  8747. * @param key The channel key "diffuse", "specular"... used in the shader
  8748. */
  8749. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8750. /**
  8751. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8752. * @param mesh defines the current mesh
  8753. * @param scene defines the current scene
  8754. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8755. * @param pointsCloud defines if point cloud rendering has to be turned on
  8756. * @param fogEnabled defines if fog has to be turned on
  8757. * @param alphaTest defines if alpha testing has to be turned on
  8758. * @param defines defines the current list of defines
  8759. */
  8760. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8761. /**
  8762. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8763. * @param scene defines the current scene
  8764. * @param engine defines the current engine
  8765. * @param defines specifies the list of active defines
  8766. * @param useInstances defines if instances have to be turned on
  8767. * @param useClipPlane defines if clip plane have to be turned on
  8768. */
  8769. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8770. /**
  8771. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8772. * @param mesh The mesh containing the geometry data we will draw
  8773. * @param defines The defines to update
  8774. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8775. * @param useBones Precise whether bones should be used or not (override mesh info)
  8776. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8777. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8778. * @returns false if defines are considered not dirty and have not been checked
  8779. */
  8780. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8781. /**
  8782. * Prepares the defines related to the light information passed in parameter
  8783. * @param scene The scene we are intending to draw
  8784. * @param mesh The mesh the effect is compiling for
  8785. * @param defines The defines to update
  8786. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8787. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8788. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8789. * @returns true if normals will be required for the rest of the effect
  8790. */
  8791. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8792. /**
  8793. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  8794. * that won t be acctive due to defines being turned off.
  8795. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8796. * @param samplersList The samplers list
  8797. * @param defines The defines helping in the list generation
  8798. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8799. */
  8800. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8801. /**
  8802. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8803. * @param defines The defines to update while falling back
  8804. * @param fallbacks The authorized effect fallbacks
  8805. * @param maxSimultaneousLights The maximum number of lights allowed
  8806. * @param rank the current rank of the Effect
  8807. * @returns The newly affected rank
  8808. */
  8809. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8810. /**
  8811. * Prepares the list of attributes required for morph targets according to the effect defines.
  8812. * @param attribs The current list of supported attribs
  8813. * @param mesh The mesh to prepare the morph targets attributes for
  8814. * @param defines The current Defines of the effect
  8815. */
  8816. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8817. /**
  8818. * Prepares the list of attributes required for bones according to the effect defines.
  8819. * @param attribs The current list of supported attribs
  8820. * @param mesh The mesh to prepare the bones attributes for
  8821. * @param defines The current Defines of the effect
  8822. * @param fallbacks The current efffect fallback strategy
  8823. */
  8824. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8825. /**
  8826. * Prepares the list of attributes required for instances according to the effect defines.
  8827. * @param attribs The current list of supported attribs
  8828. * @param defines The current Defines of the effect
  8829. */
  8830. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  8831. /**
  8832. * Binds the light shadow information to the effect for the given mesh.
  8833. * @param light The light containing the generator
  8834. * @param scene The scene the lights belongs to
  8835. * @param mesh The mesh we are binding the information to render
  8836. * @param lightIndex The light index in the effect used to render the mesh
  8837. * @param effect The effect we are binding the data to
  8838. */
  8839. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8840. /**
  8841. * Binds the light information to the effect.
  8842. * @param light The light containing the generator
  8843. * @param effect The effect we are binding the data to
  8844. * @param lightIndex The light index in the effect used to render
  8845. */
  8846. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8847. /**
  8848. * Binds the lights information from the scene to the effect for the given mesh.
  8849. * @param scene The scene the lights belongs to
  8850. * @param mesh The mesh we are binding the information to render
  8851. * @param effect The effect we are binding the data to
  8852. * @param defines The generated defines for the effect
  8853. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8854. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8855. */
  8856. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8857. private static _tempFogColor;
  8858. /**
  8859. * Binds the fog information from the scene to the effect for the given mesh.
  8860. * @param scene The scene the lights belongs to
  8861. * @param mesh The mesh we are binding the information to render
  8862. * @param effect The effect we are binding the data to
  8863. * @param linearSpace Defines if the fog effect is applied in linear space
  8864. */
  8865. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8866. /**
  8867. * Binds the bones information from the mesh to the effect.
  8868. * @param mesh The mesh we are binding the information to render
  8869. * @param effect The effect we are binding the data to
  8870. */
  8871. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8872. /**
  8873. * Binds the morph targets information from the mesh to the effect.
  8874. * @param abstractMesh The mesh we are binding the information to render
  8875. * @param effect The effect we are binding the data to
  8876. */
  8877. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8878. /**
  8879. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8880. * @param defines The generated defines used in the effect
  8881. * @param effect The effect we are binding the data to
  8882. * @param scene The scene we are willing to render with logarithmic scale for
  8883. */
  8884. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8885. /**
  8886. * Binds the clip plane information from the scene to the effect.
  8887. * @param scene The scene the clip plane information are extracted from
  8888. * @param effect The effect we are binding the data to
  8889. */
  8890. static BindClipPlane(effect: Effect, scene: Scene): void;
  8891. }
  8892. }
  8893. declare module BABYLON {
  8894. /** @hidden */
  8895. export var kernelBlurVaryingDeclaration: {
  8896. name: string;
  8897. shader: string;
  8898. };
  8899. }
  8900. declare module BABYLON {
  8901. /** @hidden */
  8902. export var kernelBlurFragment: {
  8903. name: string;
  8904. shader: string;
  8905. };
  8906. }
  8907. declare module BABYLON {
  8908. /** @hidden */
  8909. export var kernelBlurFragment2: {
  8910. name: string;
  8911. shader: string;
  8912. };
  8913. }
  8914. declare module BABYLON {
  8915. /** @hidden */
  8916. export var kernelBlurPixelShader: {
  8917. name: string;
  8918. shader: string;
  8919. };
  8920. }
  8921. declare module BABYLON {
  8922. /** @hidden */
  8923. export var kernelBlurVertex: {
  8924. name: string;
  8925. shader: string;
  8926. };
  8927. }
  8928. declare module BABYLON {
  8929. /** @hidden */
  8930. export var kernelBlurVertexShader: {
  8931. name: string;
  8932. shader: string;
  8933. };
  8934. }
  8935. declare module BABYLON {
  8936. /**
  8937. * The Blur Post Process which blurs an image based on a kernel and direction.
  8938. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  8939. */
  8940. export class BlurPostProcess extends PostProcess {
  8941. /** The direction in which to blur the image. */
  8942. direction: Vector2;
  8943. private blockCompilation;
  8944. protected _kernel: number;
  8945. protected _idealKernel: number;
  8946. protected _packedFloat: boolean;
  8947. private _staticDefines;
  8948. /**
  8949. * Sets the length in pixels of the blur sample region
  8950. */
  8951. /**
  8952. * Gets the length in pixels of the blur sample region
  8953. */
  8954. kernel: number;
  8955. /**
  8956. * Sets wether or not the blur needs to unpack/repack floats
  8957. */
  8958. /**
  8959. * Gets wether or not the blur is unpacking/repacking floats
  8960. */
  8961. packedFloat: boolean;
  8962. /**
  8963. * Creates a new instance BlurPostProcess
  8964. * @param name The name of the effect.
  8965. * @param direction The direction in which to blur the image.
  8966. * @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.
  8967. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  8968. * @param camera The camera to apply the render pass to.
  8969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  8970. * @param engine The engine which the post process will be applied. (default: current engine)
  8971. * @param reusable If the post process can be reused on the same frame. (default: false)
  8972. * @param textureType Type of textures used when performing the post process. (default: 0)
  8973. * @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)
  8974. */
  8975. constructor(name: string,
  8976. /** The direction in which to blur the image. */
  8977. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  8978. /**
  8979. * Updates the effect with the current post process compile time values and recompiles the shader.
  8980. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  8981. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  8982. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  8983. * @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
  8984. * @param onCompiled Called when the shader has been compiled.
  8985. * @param onError Called if there is an error when compiling a shader.
  8986. */
  8987. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  8988. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  8989. /**
  8990. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  8991. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  8992. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  8993. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  8994. * The gaps between physical kernels are compensated for in the weighting of the samples
  8995. * @param idealKernel Ideal blur kernel.
  8996. * @return Nearest best kernel.
  8997. */
  8998. protected _nearestBestKernel(idealKernel: number): number;
  8999. /**
  9000. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9001. * @param x The point on the Gaussian distribution to sample.
  9002. * @return the value of the Gaussian function at x.
  9003. */
  9004. protected _gaussianWeight(x: number): number;
  9005. /**
  9006. * Generates a string that can be used as a floating point number in GLSL.
  9007. * @param x Value to print.
  9008. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9009. * @return GLSL float string.
  9010. */
  9011. protected _glslFloat(x: number, decimalFigures?: number): string;
  9012. }
  9013. }
  9014. declare module BABYLON {
  9015. /** @hidden */
  9016. export var shadowMapPixelShader: {
  9017. name: string;
  9018. shader: string;
  9019. };
  9020. }
  9021. declare module BABYLON {
  9022. /** @hidden */
  9023. export var bonesDeclaration: {
  9024. name: string;
  9025. shader: string;
  9026. };
  9027. }
  9028. declare module BABYLON {
  9029. /** @hidden */
  9030. export var morphTargetsVertexGlobalDeclaration: {
  9031. name: string;
  9032. shader: string;
  9033. };
  9034. }
  9035. declare module BABYLON {
  9036. /** @hidden */
  9037. export var morphTargetsVertexDeclaration: {
  9038. name: string;
  9039. shader: string;
  9040. };
  9041. }
  9042. declare module BABYLON {
  9043. /** @hidden */
  9044. export var instancesDeclaration: {
  9045. name: string;
  9046. shader: string;
  9047. };
  9048. }
  9049. declare module BABYLON {
  9050. /** @hidden */
  9051. export var helperFunctions: {
  9052. name: string;
  9053. shader: string;
  9054. };
  9055. }
  9056. declare module BABYLON {
  9057. /** @hidden */
  9058. export var morphTargetsVertex: {
  9059. name: string;
  9060. shader: string;
  9061. };
  9062. }
  9063. declare module BABYLON {
  9064. /** @hidden */
  9065. export var instancesVertex: {
  9066. name: string;
  9067. shader: string;
  9068. };
  9069. }
  9070. declare module BABYLON {
  9071. /** @hidden */
  9072. export var bonesVertex: {
  9073. name: string;
  9074. shader: string;
  9075. };
  9076. }
  9077. declare module BABYLON {
  9078. /** @hidden */
  9079. export var shadowMapVertexShader: {
  9080. name: string;
  9081. shader: string;
  9082. };
  9083. }
  9084. declare module BABYLON {
  9085. /** @hidden */
  9086. export var depthBoxBlurPixelShader: {
  9087. name: string;
  9088. shader: string;
  9089. };
  9090. }
  9091. declare module BABYLON {
  9092. /**
  9093. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9094. */
  9095. export interface ICustomShaderOptions {
  9096. /**
  9097. * Gets or sets the custom shader name to use
  9098. */
  9099. shaderName: string;
  9100. /**
  9101. * The list of attribute names used in the shader
  9102. */
  9103. attributes?: string[];
  9104. /**
  9105. * The list of unifrom names used in the shader
  9106. */
  9107. uniforms?: string[];
  9108. /**
  9109. * The list of sampler names used in the shader
  9110. */
  9111. samplers?: string[];
  9112. /**
  9113. * The list of defines used in the shader
  9114. */
  9115. defines?: string[];
  9116. }
  9117. /**
  9118. * Interface to implement to create a shadow generator compatible with BJS.
  9119. */
  9120. export interface IShadowGenerator {
  9121. /**
  9122. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9123. * @returns The render target texture if present otherwise, null
  9124. */
  9125. getShadowMap(): Nullable<RenderTargetTexture>;
  9126. /**
  9127. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9128. * @returns The render target texture if the shadow map is present otherwise, null
  9129. */
  9130. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9131. /**
  9132. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9133. * @param subMesh The submesh we want to render in the shadow map
  9134. * @param useInstances Defines wether will draw in the map using instances
  9135. * @returns true if ready otherwise, false
  9136. */
  9137. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9138. /**
  9139. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9140. * @param defines Defines of the material we want to update
  9141. * @param lightIndex Index of the light in the enabled light list of the material
  9142. */
  9143. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9144. /**
  9145. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9146. * defined in the generator but impacting the effect).
  9147. * It implies the unifroms available on the materials are the standard BJS ones.
  9148. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9149. * @param effect The effect we are binfing the information for
  9150. */
  9151. bindShadowLight(lightIndex: string, effect: Effect): void;
  9152. /**
  9153. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9154. * (eq to shadow prjection matrix * light transform matrix)
  9155. * @returns The transform matrix used to create the shadow map
  9156. */
  9157. getTransformMatrix(): Matrix;
  9158. /**
  9159. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9160. * Cube and 2D textures for instance.
  9161. */
  9162. recreateShadowMap(): void;
  9163. /**
  9164. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9165. * @param onCompiled Callback triggered at the and of the effects compilation
  9166. * @param options Sets of optional options forcing the compilation with different modes
  9167. */
  9168. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9169. useInstances: boolean;
  9170. }>): void;
  9171. /**
  9172. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9173. * @param options Sets of optional options forcing the compilation with different modes
  9174. * @returns A promise that resolves when the compilation completes
  9175. */
  9176. forceCompilationAsync(options?: Partial<{
  9177. useInstances: boolean;
  9178. }>): Promise<void>;
  9179. /**
  9180. * Serializes the shadow generator setup to a json object.
  9181. * @returns The serialized JSON object
  9182. */
  9183. serialize(): any;
  9184. /**
  9185. * Disposes the Shadow map and related Textures and effects.
  9186. */
  9187. dispose(): void;
  9188. }
  9189. /**
  9190. * Default implementation IShadowGenerator.
  9191. * This is the main object responsible of generating shadows in the framework.
  9192. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9193. */
  9194. export class ShadowGenerator implements IShadowGenerator {
  9195. /**
  9196. * Shadow generator mode None: no filtering applied.
  9197. */
  9198. static readonly FILTER_NONE: number;
  9199. /**
  9200. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9201. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9202. */
  9203. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9204. /**
  9205. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9206. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9207. */
  9208. static readonly FILTER_POISSONSAMPLING: number;
  9209. /**
  9210. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9211. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9212. */
  9213. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9214. /**
  9215. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9216. * edge artifacts on steep falloff.
  9217. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9218. */
  9219. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9220. /**
  9221. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9222. * edge artifacts on steep falloff.
  9223. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9224. */
  9225. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9226. /**
  9227. * Shadow generator mode PCF: Percentage Closer Filtering
  9228. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9229. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9230. */
  9231. static readonly FILTER_PCF: number;
  9232. /**
  9233. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9234. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9235. * Contact Hardening
  9236. */
  9237. static readonly FILTER_PCSS: number;
  9238. /**
  9239. * Reserved for PCF and PCSS
  9240. * Highest Quality.
  9241. *
  9242. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9243. *
  9244. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9245. */
  9246. static readonly QUALITY_HIGH: number;
  9247. /**
  9248. * Reserved for PCF and PCSS
  9249. * Good tradeoff for quality/perf cross devices
  9250. *
  9251. * Execute PCF on a 3*3 kernel.
  9252. *
  9253. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9254. */
  9255. static readonly QUALITY_MEDIUM: number;
  9256. /**
  9257. * Reserved for PCF and PCSS
  9258. * The lowest quality but the fastest.
  9259. *
  9260. * Execute PCF on a 1*1 kernel.
  9261. *
  9262. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9263. */
  9264. static readonly QUALITY_LOW: number;
  9265. /** Gets or sets the custom shader name to use */
  9266. customShaderOptions: ICustomShaderOptions;
  9267. /**
  9268. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9269. */
  9270. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9271. private _bias;
  9272. /**
  9273. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9274. */
  9275. /**
  9276. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9277. */
  9278. bias: number;
  9279. private _normalBias;
  9280. /**
  9281. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9282. */
  9283. /**
  9284. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9285. */
  9286. normalBias: number;
  9287. private _blurBoxOffset;
  9288. /**
  9289. * Gets the blur box offset: offset applied during the blur pass.
  9290. * Only useful if useKernelBlur = false
  9291. */
  9292. /**
  9293. * Sets the blur box offset: offset applied during the blur pass.
  9294. * Only useful if useKernelBlur = false
  9295. */
  9296. blurBoxOffset: number;
  9297. private _blurScale;
  9298. /**
  9299. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9300. * 2 means half of the size.
  9301. */
  9302. /**
  9303. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9304. * 2 means half of the size.
  9305. */
  9306. blurScale: number;
  9307. private _blurKernel;
  9308. /**
  9309. * Gets the blur kernel: kernel size of the blur pass.
  9310. * Only useful if useKernelBlur = true
  9311. */
  9312. /**
  9313. * Sets the blur kernel: kernel size of the blur pass.
  9314. * Only useful if useKernelBlur = true
  9315. */
  9316. blurKernel: number;
  9317. private _useKernelBlur;
  9318. /**
  9319. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9320. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9321. */
  9322. /**
  9323. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9324. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9325. */
  9326. useKernelBlur: boolean;
  9327. private _depthScale;
  9328. /**
  9329. * Gets the depth scale used in ESM mode.
  9330. */
  9331. /**
  9332. * Sets the depth scale used in ESM mode.
  9333. * This can override the scale stored on the light.
  9334. */
  9335. depthScale: number;
  9336. private _filter;
  9337. /**
  9338. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9339. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9340. */
  9341. /**
  9342. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9343. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9344. */
  9345. filter: number;
  9346. /**
  9347. * Gets if the current filter is set to Poisson Sampling.
  9348. */
  9349. /**
  9350. * Sets the current filter to Poisson Sampling.
  9351. */
  9352. usePoissonSampling: boolean;
  9353. /**
  9354. * Gets if the current filter is set to ESM.
  9355. */
  9356. /**
  9357. * Sets the current filter is to ESM.
  9358. */
  9359. useExponentialShadowMap: boolean;
  9360. /**
  9361. * Gets if the current filter is set to filtered ESM.
  9362. */
  9363. /**
  9364. * Gets if the current filter is set to filtered ESM.
  9365. */
  9366. useBlurExponentialShadowMap: boolean;
  9367. /**
  9368. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9369. * exponential to prevent steep falloff artifacts).
  9370. */
  9371. /**
  9372. * Sets the current filter to "close ESM" (using the inverse of the
  9373. * exponential to prevent steep falloff artifacts).
  9374. */
  9375. useCloseExponentialShadowMap: boolean;
  9376. /**
  9377. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9378. * exponential to prevent steep falloff artifacts).
  9379. */
  9380. /**
  9381. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9382. * exponential to prevent steep falloff artifacts).
  9383. */
  9384. useBlurCloseExponentialShadowMap: boolean;
  9385. /**
  9386. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9387. */
  9388. /**
  9389. * Sets the current filter to "PCF" (percentage closer filtering).
  9390. */
  9391. usePercentageCloserFiltering: boolean;
  9392. private _filteringQuality;
  9393. /**
  9394. * Gets the PCF or PCSS Quality.
  9395. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9396. */
  9397. /**
  9398. * Sets the PCF or PCSS Quality.
  9399. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9400. */
  9401. filteringQuality: number;
  9402. /**
  9403. * Gets if the current filter is set to "PCSS" (contact hardening).
  9404. */
  9405. /**
  9406. * Sets the current filter to "PCSS" (contact hardening).
  9407. */
  9408. useContactHardeningShadow: boolean;
  9409. private _contactHardeningLightSizeUVRatio;
  9410. /**
  9411. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9412. * Using a ratio helps keeping shape stability independently of the map size.
  9413. *
  9414. * It does not account for the light projection as it was having too much
  9415. * instability during the light setup or during light position changes.
  9416. *
  9417. * Only valid if useContactHardeningShadow is true.
  9418. */
  9419. /**
  9420. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9421. * Using a ratio helps keeping shape stability independently of the map size.
  9422. *
  9423. * It does not account for the light projection as it was having too much
  9424. * instability during the light setup or during light position changes.
  9425. *
  9426. * Only valid if useContactHardeningShadow is true.
  9427. */
  9428. contactHardeningLightSizeUVRatio: number;
  9429. private _darkness;
  9430. /**
  9431. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9432. * 0 means strongest and 1 would means no shadow.
  9433. * @returns the darkness.
  9434. */
  9435. getDarkness(): number;
  9436. /**
  9437. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9438. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9439. * @returns the shadow generator allowing fluent coding.
  9440. */
  9441. setDarkness(darkness: number): ShadowGenerator;
  9442. private _transparencyShadow;
  9443. /**
  9444. * Sets the ability to have transparent shadow (boolean).
  9445. * @param transparent True if transparent else False
  9446. * @returns the shadow generator allowing fluent coding
  9447. */
  9448. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9449. private _shadowMap;
  9450. private _shadowMap2;
  9451. /**
  9452. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9453. * @returns The render target texture if present otherwise, null
  9454. */
  9455. getShadowMap(): Nullable<RenderTargetTexture>;
  9456. /**
  9457. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9458. * @returns The render target texture if the shadow map is present otherwise, null
  9459. */
  9460. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9461. /**
  9462. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9463. * @param mesh Mesh to add
  9464. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9465. * @returns the Shadow Generator itself
  9466. */
  9467. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9468. /**
  9469. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9470. * @param mesh Mesh to remove
  9471. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9472. * @returns the Shadow Generator itself
  9473. */
  9474. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9475. /**
  9476. * Controls the extent to which the shadows fade out at the edge of the frustum
  9477. * Used only by directionals and spots
  9478. */
  9479. frustumEdgeFalloff: number;
  9480. private _light;
  9481. /**
  9482. * Returns the associated light object.
  9483. * @returns the light generating the shadow
  9484. */
  9485. getLight(): IShadowLight;
  9486. /**
  9487. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9488. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9489. * It might on the other hand introduce peter panning.
  9490. */
  9491. forceBackFacesOnly: boolean;
  9492. private _scene;
  9493. private _lightDirection;
  9494. private _effect;
  9495. private _viewMatrix;
  9496. private _projectionMatrix;
  9497. private _transformMatrix;
  9498. private _cachedPosition;
  9499. private _cachedDirection;
  9500. private _cachedDefines;
  9501. private _currentRenderID;
  9502. private _boxBlurPostprocess;
  9503. private _kernelBlurXPostprocess;
  9504. private _kernelBlurYPostprocess;
  9505. private _blurPostProcesses;
  9506. private _mapSize;
  9507. private _currentFaceIndex;
  9508. private _currentFaceIndexCache;
  9509. private _textureType;
  9510. private _defaultTextureMatrix;
  9511. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9512. /**
  9513. * Creates a ShadowGenerator object.
  9514. * A ShadowGenerator is the required tool to use the shadows.
  9515. * Each light casting shadows needs to use its own ShadowGenerator.
  9516. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9517. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9518. * @param light The light object generating the shadows.
  9519. * @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.
  9520. */
  9521. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9522. private _initializeGenerator;
  9523. private _initializeShadowMap;
  9524. private _initializeBlurRTTAndPostProcesses;
  9525. private _renderForShadowMap;
  9526. private _renderSubMeshForShadowMap;
  9527. private _applyFilterValues;
  9528. /**
  9529. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9530. * @param onCompiled Callback triggered at the and of the effects compilation
  9531. * @param options Sets of optional options forcing the compilation with different modes
  9532. */
  9533. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9534. useInstances: boolean;
  9535. }>): void;
  9536. /**
  9537. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9538. * @param options Sets of optional options forcing the compilation with different modes
  9539. * @returns A promise that resolves when the compilation completes
  9540. */
  9541. forceCompilationAsync(options?: Partial<{
  9542. useInstances: boolean;
  9543. }>): Promise<void>;
  9544. /**
  9545. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9546. * @param subMesh The submesh we want to render in the shadow map
  9547. * @param useInstances Defines wether will draw in the map using instances
  9548. * @returns true if ready otherwise, false
  9549. */
  9550. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9551. /**
  9552. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9553. * @param defines Defines of the material we want to update
  9554. * @param lightIndex Index of the light in the enabled light list of the material
  9555. */
  9556. prepareDefines(defines: any, lightIndex: number): void;
  9557. /**
  9558. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9559. * defined in the generator but impacting the effect).
  9560. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9561. * @param effect The effect we are binfing the information for
  9562. */
  9563. bindShadowLight(lightIndex: string, effect: Effect): void;
  9564. /**
  9565. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9566. * (eq to shadow prjection matrix * light transform matrix)
  9567. * @returns The transform matrix used to create the shadow map
  9568. */
  9569. getTransformMatrix(): Matrix;
  9570. /**
  9571. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9572. * Cube and 2D textures for instance.
  9573. */
  9574. recreateShadowMap(): void;
  9575. private _disposeBlurPostProcesses;
  9576. private _disposeRTTandPostProcesses;
  9577. /**
  9578. * Disposes the ShadowGenerator.
  9579. * Returns nothing.
  9580. */
  9581. dispose(): void;
  9582. /**
  9583. * Serializes the shadow generator setup to a json object.
  9584. * @returns The serialized JSON object
  9585. */
  9586. serialize(): any;
  9587. /**
  9588. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9589. * @param parsedShadowGenerator The JSON object to parse
  9590. * @param scene The scene to create the shadow map for
  9591. * @returns The parsed shadow generator
  9592. */
  9593. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9594. }
  9595. }
  9596. declare module BABYLON {
  9597. /**
  9598. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9599. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9600. * 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.
  9601. */
  9602. export abstract class Light extends Node {
  9603. /**
  9604. * Falloff Default: light is falling off following the material specification:
  9605. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9606. */
  9607. static readonly FALLOFF_DEFAULT: number;
  9608. /**
  9609. * Falloff Physical: light is falling off following the inverse squared distance law.
  9610. */
  9611. static readonly FALLOFF_PHYSICAL: number;
  9612. /**
  9613. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9614. * to enhance interoperability with other engines.
  9615. */
  9616. static readonly FALLOFF_GLTF: number;
  9617. /**
  9618. * Falloff Standard: light is falling off like in the standard material
  9619. * to enhance interoperability with other materials.
  9620. */
  9621. static readonly FALLOFF_STANDARD: number;
  9622. /**
  9623. * If every light affecting the material is in this lightmapMode,
  9624. * material.lightmapTexture adds or multiplies
  9625. * (depends on material.useLightmapAsShadowmap)
  9626. * after every other light calculations.
  9627. */
  9628. static readonly LIGHTMAP_DEFAULT: number;
  9629. /**
  9630. * material.lightmapTexture as only diffuse lighting from this light
  9631. * adds only specular lighting from this light
  9632. * adds dynamic shadows
  9633. */
  9634. static readonly LIGHTMAP_SPECULAR: number;
  9635. /**
  9636. * material.lightmapTexture as only lighting
  9637. * no light calculation from this light
  9638. * only adds dynamic shadows from this light
  9639. */
  9640. static readonly LIGHTMAP_SHADOWSONLY: number;
  9641. /**
  9642. * Each light type uses the default quantity according to its type:
  9643. * point/spot lights use luminous intensity
  9644. * directional lights use illuminance
  9645. */
  9646. static readonly INTENSITYMODE_AUTOMATIC: number;
  9647. /**
  9648. * lumen (lm)
  9649. */
  9650. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9651. /**
  9652. * candela (lm/sr)
  9653. */
  9654. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9655. /**
  9656. * lux (lm/m^2)
  9657. */
  9658. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9659. /**
  9660. * nit (cd/m^2)
  9661. */
  9662. static readonly INTENSITYMODE_LUMINANCE: number;
  9663. /**
  9664. * Light type const id of the point light.
  9665. */
  9666. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9667. /**
  9668. * Light type const id of the directional light.
  9669. */
  9670. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9671. /**
  9672. * Light type const id of the spot light.
  9673. */
  9674. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9675. /**
  9676. * Light type const id of the hemispheric light.
  9677. */
  9678. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9679. /**
  9680. * Diffuse gives the basic color to an object.
  9681. */
  9682. diffuse: Color3;
  9683. /**
  9684. * Specular produces a highlight color on an object.
  9685. * Note: This is note affecting PBR materials.
  9686. */
  9687. specular: Color3;
  9688. /**
  9689. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9690. * falling off base on range or angle.
  9691. * This can be set to any values in Light.FALLOFF_x.
  9692. *
  9693. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9694. * other types of materials.
  9695. */
  9696. falloffType: number;
  9697. /**
  9698. * Strength of the light.
  9699. * Note: By default it is define in the framework own unit.
  9700. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9701. */
  9702. intensity: number;
  9703. private _range;
  9704. protected _inverseSquaredRange: number;
  9705. /**
  9706. * Defines how far from the source the light is impacting in scene units.
  9707. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9708. */
  9709. /**
  9710. * Defines how far from the source the light is impacting in scene units.
  9711. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9712. */
  9713. range: number;
  9714. /**
  9715. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9716. * of light.
  9717. */
  9718. private _photometricScale;
  9719. private _intensityMode;
  9720. /**
  9721. * Gets the photometric scale used to interpret the intensity.
  9722. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9723. */
  9724. /**
  9725. * Sets the photometric scale used to interpret the intensity.
  9726. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9727. */
  9728. intensityMode: number;
  9729. private _radius;
  9730. /**
  9731. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9732. */
  9733. /**
  9734. * sets the light radius used by PBR Materials to simulate soft area lights.
  9735. */
  9736. radius: number;
  9737. private _renderPriority;
  9738. /**
  9739. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9740. * exceeding the number allowed of the materials.
  9741. */
  9742. renderPriority: number;
  9743. private _shadowEnabled;
  9744. /**
  9745. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9746. * the current shadow generator.
  9747. */
  9748. /**
  9749. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9750. * the current shadow generator.
  9751. */
  9752. shadowEnabled: boolean;
  9753. private _includedOnlyMeshes;
  9754. /**
  9755. * Gets the only meshes impacted by this light.
  9756. */
  9757. /**
  9758. * Sets the only meshes impacted by this light.
  9759. */
  9760. includedOnlyMeshes: AbstractMesh[];
  9761. private _excludedMeshes;
  9762. /**
  9763. * Gets the meshes not impacted by this light.
  9764. */
  9765. /**
  9766. * Sets the meshes not impacted by this light.
  9767. */
  9768. excludedMeshes: AbstractMesh[];
  9769. private _excludeWithLayerMask;
  9770. /**
  9771. * Gets the layer id use to find what meshes are not impacted by the light.
  9772. * Inactive if 0
  9773. */
  9774. /**
  9775. * Sets the layer id use to find what meshes are not impacted by the light.
  9776. * Inactive if 0
  9777. */
  9778. excludeWithLayerMask: number;
  9779. private _includeOnlyWithLayerMask;
  9780. /**
  9781. * Gets the layer id use to find what meshes are impacted by the light.
  9782. * Inactive if 0
  9783. */
  9784. /**
  9785. * Sets the layer id use to find what meshes are impacted by the light.
  9786. * Inactive if 0
  9787. */
  9788. includeOnlyWithLayerMask: number;
  9789. private _lightmapMode;
  9790. /**
  9791. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9792. */
  9793. /**
  9794. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9795. */
  9796. lightmapMode: number;
  9797. /**
  9798. * Shadow generator associted to the light.
  9799. * @hidden Internal use only.
  9800. */ shadowGenerator: Nullable<IShadowGenerator>;
  9801. /**
  9802. * @hidden Internal use only.
  9803. */ excludedMeshesIds: string[];
  9804. /**
  9805. * @hidden Internal use only.
  9806. */ includedOnlyMeshesIds: string[];
  9807. /**
  9808. * The current light unifom buffer.
  9809. * @hidden Internal use only.
  9810. */ uniformBuffer: UniformBuffer;
  9811. /**
  9812. * Creates a Light object in the scene.
  9813. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9814. * @param name The firendly name of the light
  9815. * @param scene The scene the light belongs too
  9816. */
  9817. constructor(name: string, scene: Scene);
  9818. protected abstract _buildUniformLayout(): void;
  9819. /**
  9820. * Sets the passed Effect "effect" with the Light information.
  9821. * @param effect The effect to update
  9822. * @param lightIndex The index of the light in the effect to update
  9823. * @returns The light
  9824. */
  9825. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9826. /**
  9827. * Returns the string "Light".
  9828. * @returns the class name
  9829. */
  9830. getClassName(): string;
  9831. /** @hidden */ protected readonly _isLight: boolean;
  9832. /**
  9833. * Converts the light information to a readable string for debug purpose.
  9834. * @param fullDetails Supports for multiple levels of logging within scene loading
  9835. * @returns the human readable light info
  9836. */
  9837. toString(fullDetails?: boolean): string;
  9838. /** @hidden */
  9839. protected _syncParentEnabledState(): void;
  9840. /**
  9841. * Set the enabled state of this node.
  9842. * @param value - the new enabled state
  9843. */
  9844. setEnabled(value: boolean): void;
  9845. /**
  9846. * Returns the Light associated shadow generator if any.
  9847. * @return the associated shadow generator.
  9848. */
  9849. getShadowGenerator(): Nullable<IShadowGenerator>;
  9850. /**
  9851. * Returns a Vector3, the absolute light position in the World.
  9852. * @returns the world space position of the light
  9853. */
  9854. getAbsolutePosition(): Vector3;
  9855. /**
  9856. * Specifies if the light will affect the passed mesh.
  9857. * @param mesh The mesh to test against the light
  9858. * @return true the mesh is affected otherwise, false.
  9859. */
  9860. canAffectMesh(mesh: AbstractMesh): boolean;
  9861. /**
  9862. * Sort function to order lights for rendering.
  9863. * @param a First Light object to compare to second.
  9864. * @param b Second Light object to compare first.
  9865. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9866. */
  9867. static CompareLightsPriority(a: Light, b: Light): number;
  9868. /**
  9869. * Releases resources associated with this node.
  9870. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9871. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9872. */
  9873. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9874. /**
  9875. * Returns the light type ID (integer).
  9876. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9877. */
  9878. getTypeID(): number;
  9879. /**
  9880. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9881. * @returns the scaled intensity in intensity mode unit
  9882. */
  9883. getScaledIntensity(): number;
  9884. /**
  9885. * Returns a new Light object, named "name", from the current one.
  9886. * @param name The name of the cloned light
  9887. * @returns the new created light
  9888. */
  9889. clone(name: string): Nullable<Light>;
  9890. /**
  9891. * Serializes the current light into a Serialization object.
  9892. * @returns the serialized object.
  9893. */
  9894. serialize(): any;
  9895. /**
  9896. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9897. * This new light is named "name" and added to the passed scene.
  9898. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9899. * @param name The friendly name of the light
  9900. * @param scene The scene the new light will belong to
  9901. * @returns the constructor function
  9902. */
  9903. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9904. /**
  9905. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9906. * @param parsedLight The JSON representation of the light
  9907. * @param scene The scene to create the parsed light in
  9908. * @returns the created light after parsing
  9909. */
  9910. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9911. private _hookArrayForExcluded;
  9912. private _hookArrayForIncludedOnly;
  9913. private _resyncMeshes;
  9914. /**
  9915. * Forces the meshes to update their light related information in their rendering used effects
  9916. * @hidden Internal Use Only
  9917. */ markMeshesAsLightDirty(): void;
  9918. /**
  9919. * Recomputes the cached photometric scale if needed.
  9920. */
  9921. private _computePhotometricScale;
  9922. /**
  9923. * Returns the Photometric Scale according to the light type and intensity mode.
  9924. */
  9925. private _getPhotometricScale;
  9926. /**
  9927. * Reorder the light in the scene according to their defined priority.
  9928. * @hidden Internal Use Only
  9929. */ reorderLightsInScene(): void;
  9930. /**
  9931. * Prepares the list of defines specific to the light type.
  9932. * @param defines the list of defines
  9933. * @param lightIndex defines the index of the light for the effect
  9934. */
  9935. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9936. }
  9937. }
  9938. declare module BABYLON {
  9939. /**
  9940. * Interface used to define Action
  9941. */
  9942. export interface IAction {
  9943. /**
  9944. * Trigger for the action
  9945. */
  9946. trigger: number;
  9947. /** the trigger, with or without parameters, for the action */
  9948. triggerOptions: any;
  9949. /**
  9950. * Gets the trigger parameters
  9951. * @returns the trigger parameters
  9952. */
  9953. getTriggerParameter(): any;
  9954. /**
  9955. * Internal only - executes current action event
  9956. * @hidden
  9957. */ executeCurrent(evt?: ActionEvent): void;
  9958. /**
  9959. * Serialize placeholder for child classes
  9960. * @param parent of child
  9961. * @returns the serialized object
  9962. */
  9963. serialize(parent: any): any;
  9964. }
  9965. /**
  9966. * The action to be carried out following a trigger
  9967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9968. */
  9969. export class Action implements IAction {
  9970. /** the trigger, with or without parameters, for the action */
  9971. triggerOptions: any;
  9972. /**
  9973. * Trigger for the action
  9974. */
  9975. trigger: number;
  9976. /**
  9977. * Internal only - manager for action
  9978. * @hidden
  9979. */ actionManager: ActionManager;
  9980. private _nextActiveAction;
  9981. private _child;
  9982. private _condition?;
  9983. private _triggerParameter;
  9984. /**
  9985. * An event triggered prior to action being executed.
  9986. */
  9987. onBeforeExecuteObservable: Observable<Action>;
  9988. /**
  9989. * Creates a new Action
  9990. * @param triggerOptions the trigger, with or without parameters, for the action
  9991. * @param condition an optional determinant of action
  9992. */
  9993. constructor(
  9994. /** the trigger, with or without parameters, for the action */
  9995. triggerOptions: any, condition?: Condition);
  9996. /**
  9997. * Internal only
  9998. * @hidden
  9999. */ prepare(): void;
  10000. /**
  10001. * Gets the trigger parameters
  10002. * @returns the trigger parameters
  10003. */
  10004. getTriggerParameter(): any;
  10005. /**
  10006. * Internal only - executes current action event
  10007. * @hidden
  10008. */ executeCurrent(evt?: ActionEvent): void;
  10009. /**
  10010. * Execute placeholder for child classes
  10011. * @param evt optional action event
  10012. */
  10013. execute(evt?: ActionEvent): void;
  10014. /**
  10015. * Skips to next active action
  10016. */
  10017. skipToNextActiveAction(): void;
  10018. /**
  10019. * Adds action to chain of actions, may be a DoNothingAction
  10020. * @param action defines the next action to execute
  10021. * @returns The action passed in
  10022. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10023. */
  10024. then(action: Action): Action;
  10025. /**
  10026. * Internal only
  10027. * @hidden
  10028. */ getProperty(propertyPath: string): string;
  10029. /**
  10030. * Internal only
  10031. * @hidden
  10032. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10033. /**
  10034. * Serialize placeholder for child classes
  10035. * @param parent of child
  10036. * @returns the serialized object
  10037. */
  10038. serialize(parent: any): any;
  10039. /**
  10040. * Internal only called by serialize
  10041. * @hidden
  10042. */
  10043. protected _serialize(serializedAction: any, parent?: any): any;
  10044. /**
  10045. * Internal only
  10046. * @hidden
  10047. */ private static _SerializeValueAsString: (value: any) => string;
  10048. /**
  10049. * Internal only
  10050. * @hidden
  10051. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10052. name: string;
  10053. targetType: string;
  10054. value: string;
  10055. };
  10056. }
  10057. }
  10058. declare module BABYLON {
  10059. /**
  10060. * A Condition applied to an Action
  10061. */
  10062. export class Condition {
  10063. /**
  10064. * Internal only - manager for action
  10065. * @hidden
  10066. */ actionManager: ActionManager;
  10067. /**
  10068. * Internal only
  10069. * @hidden
  10070. */ evaluationId: number;
  10071. /**
  10072. * Internal only
  10073. * @hidden
  10074. */ currentResult: boolean;
  10075. /**
  10076. * Creates a new Condition
  10077. * @param actionManager the manager of the action the condition is applied to
  10078. */
  10079. constructor(actionManager: ActionManager);
  10080. /**
  10081. * Check if the current condition is valid
  10082. * @returns a boolean
  10083. */
  10084. isValid(): boolean;
  10085. /**
  10086. * Internal only
  10087. * @hidden
  10088. */ getProperty(propertyPath: string): string;
  10089. /**
  10090. * Internal only
  10091. * @hidden
  10092. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10093. /**
  10094. * Serialize placeholder for child classes
  10095. * @returns the serialized object
  10096. */
  10097. serialize(): any;
  10098. /**
  10099. * Internal only
  10100. * @hidden
  10101. */
  10102. protected _serialize(serializedCondition: any): any;
  10103. }
  10104. /**
  10105. * Defines specific conditional operators as extensions of Condition
  10106. */
  10107. export class ValueCondition extends Condition {
  10108. /** path to specify the property of the target the conditional operator uses */
  10109. propertyPath: string;
  10110. /** the value compared by the conditional operator against the current value of the property */
  10111. value: any;
  10112. /** the conditional operator, default ValueCondition.IsEqual */
  10113. operator: number;
  10114. /**
  10115. * Internal only
  10116. * @hidden
  10117. */
  10118. private static _IsEqual;
  10119. /**
  10120. * Internal only
  10121. * @hidden
  10122. */
  10123. private static _IsDifferent;
  10124. /**
  10125. * Internal only
  10126. * @hidden
  10127. */
  10128. private static _IsGreater;
  10129. /**
  10130. * Internal only
  10131. * @hidden
  10132. */
  10133. private static _IsLesser;
  10134. /**
  10135. * returns the number for IsEqual
  10136. */
  10137. static readonly IsEqual: number;
  10138. /**
  10139. * Returns the number for IsDifferent
  10140. */
  10141. static readonly IsDifferent: number;
  10142. /**
  10143. * Returns the number for IsGreater
  10144. */
  10145. static readonly IsGreater: number;
  10146. /**
  10147. * Returns the number for IsLesser
  10148. */
  10149. static readonly IsLesser: number;
  10150. /**
  10151. * Internal only The action manager for the condition
  10152. * @hidden
  10153. */ actionManager: ActionManager;
  10154. /**
  10155. * Internal only
  10156. * @hidden
  10157. */
  10158. private _target;
  10159. /**
  10160. * Internal only
  10161. * @hidden
  10162. */
  10163. private _effectiveTarget;
  10164. /**
  10165. * Internal only
  10166. * @hidden
  10167. */
  10168. private _property;
  10169. /**
  10170. * Creates a new ValueCondition
  10171. * @param actionManager manager for the action the condition applies to
  10172. * @param target for the action
  10173. * @param propertyPath path to specify the property of the target the conditional operator uses
  10174. * @param value the value compared by the conditional operator against the current value of the property
  10175. * @param operator the conditional operator, default ValueCondition.IsEqual
  10176. */
  10177. constructor(actionManager: ActionManager, target: any,
  10178. /** path to specify the property of the target the conditional operator uses */
  10179. propertyPath: string,
  10180. /** the value compared by the conditional operator against the current value of the property */
  10181. value: any,
  10182. /** the conditional operator, default ValueCondition.IsEqual */
  10183. operator?: number);
  10184. /**
  10185. * Compares the given value with the property value for the specified conditional operator
  10186. * @returns the result of the comparison
  10187. */
  10188. isValid(): boolean;
  10189. /**
  10190. * Serialize the ValueCondition into a JSON compatible object
  10191. * @returns serialization object
  10192. */
  10193. serialize(): any;
  10194. /**
  10195. * Gets the name of the conditional operator for the ValueCondition
  10196. * @param operator the conditional operator
  10197. * @returns the name
  10198. */
  10199. static GetOperatorName(operator: number): string;
  10200. }
  10201. /**
  10202. * Defines a predicate condition as an extension of Condition
  10203. */
  10204. export class PredicateCondition extends Condition {
  10205. /** defines the predicate function used to validate the condition */
  10206. predicate: () => boolean;
  10207. /**
  10208. * Internal only - manager for action
  10209. * @hidden
  10210. */ actionManager: ActionManager;
  10211. /**
  10212. * Creates a new PredicateCondition
  10213. * @param actionManager manager for the action the condition applies to
  10214. * @param predicate defines the predicate function used to validate the condition
  10215. */
  10216. constructor(actionManager: ActionManager,
  10217. /** defines the predicate function used to validate the condition */
  10218. predicate: () => boolean);
  10219. /**
  10220. * @returns the validity of the predicate condition
  10221. */
  10222. isValid(): boolean;
  10223. }
  10224. /**
  10225. * Defines a state condition as an extension of Condition
  10226. */
  10227. export class StateCondition extends Condition {
  10228. /** Value to compare with target state */
  10229. value: string;
  10230. /**
  10231. * Internal only - manager for action
  10232. * @hidden
  10233. */ actionManager: ActionManager;
  10234. /**
  10235. * Internal only
  10236. * @hidden
  10237. */
  10238. private _target;
  10239. /**
  10240. * Creates a new StateCondition
  10241. * @param actionManager manager for the action the condition applies to
  10242. * @param target of the condition
  10243. * @param value to compare with target state
  10244. */
  10245. constructor(actionManager: ActionManager, target: any,
  10246. /** Value to compare with target state */
  10247. value: string);
  10248. /**
  10249. * Gets a boolean indicating if the current condition is met
  10250. * @returns the validity of the state
  10251. */
  10252. isValid(): boolean;
  10253. /**
  10254. * Serialize the StateCondition into a JSON compatible object
  10255. * @returns serialization object
  10256. */
  10257. serialize(): any;
  10258. }
  10259. }
  10260. declare module BABYLON {
  10261. /**
  10262. * This defines an action responsible to toggle a boolean once triggered.
  10263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10264. */
  10265. export class SwitchBooleanAction extends Action {
  10266. /**
  10267. * The path to the boolean property in the target object
  10268. */
  10269. propertyPath: string;
  10270. private _target;
  10271. private _effectiveTarget;
  10272. private _property;
  10273. /**
  10274. * Instantiate the action
  10275. * @param triggerOptions defines the trigger options
  10276. * @param target defines the object containing the boolean
  10277. * @param propertyPath defines the path to the boolean property in the target object
  10278. * @param condition defines the trigger related conditions
  10279. */
  10280. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10281. /** @hidden */ prepare(): void;
  10282. /**
  10283. * Execute the action toggle the boolean value.
  10284. */
  10285. execute(): void;
  10286. /**
  10287. * Serializes the actions and its related information.
  10288. * @param parent defines the object to serialize in
  10289. * @returns the serialized object
  10290. */
  10291. serialize(parent: any): any;
  10292. }
  10293. /**
  10294. * This defines an action responsible to set a the state field of the target
  10295. * to a desired value once triggered.
  10296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10297. */
  10298. export class SetStateAction extends Action {
  10299. /**
  10300. * The value to store in the state field.
  10301. */
  10302. value: string;
  10303. private _target;
  10304. /**
  10305. * Instantiate the action
  10306. * @param triggerOptions defines the trigger options
  10307. * @param target defines the object containing the state property
  10308. * @param value defines the value to store in the state field
  10309. * @param condition defines the trigger related conditions
  10310. */
  10311. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10312. /**
  10313. * Execute the action and store the value on the target state property.
  10314. */
  10315. execute(): void;
  10316. /**
  10317. * Serializes the actions and its related information.
  10318. * @param parent defines the object to serialize in
  10319. * @returns the serialized object
  10320. */
  10321. serialize(parent: any): any;
  10322. }
  10323. /**
  10324. * This defines an action responsible to set a property of the target
  10325. * to a desired value once triggered.
  10326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10327. */
  10328. export class SetValueAction extends Action {
  10329. /**
  10330. * The path of the property to set in the target.
  10331. */
  10332. propertyPath: string;
  10333. /**
  10334. * The value to set in the property
  10335. */
  10336. value: any;
  10337. private _target;
  10338. private _effectiveTarget;
  10339. private _property;
  10340. /**
  10341. * Instantiate the action
  10342. * @param triggerOptions defines the trigger options
  10343. * @param target defines the object containing the property
  10344. * @param propertyPath defines the path of the property to set in the target
  10345. * @param value defines the value to set in the property
  10346. * @param condition defines the trigger related conditions
  10347. */
  10348. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10349. /** @hidden */ prepare(): void;
  10350. /**
  10351. * Execute the action and set the targetted property to the desired value.
  10352. */
  10353. execute(): void;
  10354. /**
  10355. * Serializes the actions and its related information.
  10356. * @param parent defines the object to serialize in
  10357. * @returns the serialized object
  10358. */
  10359. serialize(parent: any): any;
  10360. }
  10361. /**
  10362. * This defines an action responsible to increment the target value
  10363. * to a desired value once triggered.
  10364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10365. */
  10366. export class IncrementValueAction extends Action {
  10367. /**
  10368. * The path of the property to increment in the target.
  10369. */
  10370. propertyPath: string;
  10371. /**
  10372. * The value we should increment the property by.
  10373. */
  10374. value: any;
  10375. private _target;
  10376. private _effectiveTarget;
  10377. private _property;
  10378. /**
  10379. * Instantiate the action
  10380. * @param triggerOptions defines the trigger options
  10381. * @param target defines the object containing the property
  10382. * @param propertyPath defines the path of the property to increment in the target
  10383. * @param value defines the value value we should increment the property by
  10384. * @param condition defines the trigger related conditions
  10385. */
  10386. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10387. /** @hidden */ prepare(): void;
  10388. /**
  10389. * Execute the action and increment the target of the value amount.
  10390. */
  10391. execute(): void;
  10392. /**
  10393. * Serializes the actions and its related information.
  10394. * @param parent defines the object to serialize in
  10395. * @returns the serialized object
  10396. */
  10397. serialize(parent: any): any;
  10398. }
  10399. /**
  10400. * This defines an action responsible to start an animation once triggered.
  10401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10402. */
  10403. export class PlayAnimationAction extends Action {
  10404. /**
  10405. * Where the animation should start (animation frame)
  10406. */
  10407. from: number;
  10408. /**
  10409. * Where the animation should stop (animation frame)
  10410. */
  10411. to: number;
  10412. /**
  10413. * Define if the animation should loop or stop after the first play.
  10414. */
  10415. loop?: boolean;
  10416. private _target;
  10417. /**
  10418. * Instantiate the action
  10419. * @param triggerOptions defines the trigger options
  10420. * @param target defines the target animation or animation name
  10421. * @param from defines from where the animation should start (animation frame)
  10422. * @param end defines where the animation should stop (animation frame)
  10423. * @param loop defines if the animation should loop or stop after the first play
  10424. * @param condition defines the trigger related conditions
  10425. */
  10426. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10427. /** @hidden */ prepare(): void;
  10428. /**
  10429. * Execute the action and play the animation.
  10430. */
  10431. execute(): void;
  10432. /**
  10433. * Serializes the actions and its related information.
  10434. * @param parent defines the object to serialize in
  10435. * @returns the serialized object
  10436. */
  10437. serialize(parent: any): any;
  10438. }
  10439. /**
  10440. * This defines an action responsible to stop an animation once triggered.
  10441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10442. */
  10443. export class StopAnimationAction extends Action {
  10444. private _target;
  10445. /**
  10446. * Instantiate the action
  10447. * @param triggerOptions defines the trigger options
  10448. * @param target defines the target animation or animation name
  10449. * @param condition defines the trigger related conditions
  10450. */
  10451. constructor(triggerOptions: any, target: any, condition?: Condition);
  10452. /** @hidden */ prepare(): void;
  10453. /**
  10454. * Execute the action and stop the animation.
  10455. */
  10456. execute(): void;
  10457. /**
  10458. * Serializes the actions and its related information.
  10459. * @param parent defines the object to serialize in
  10460. * @returns the serialized object
  10461. */
  10462. serialize(parent: any): any;
  10463. }
  10464. /**
  10465. * This defines an action responsible that does nothing once triggered.
  10466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10467. */
  10468. export class DoNothingAction extends Action {
  10469. /**
  10470. * Instantiate the action
  10471. * @param triggerOptions defines the trigger options
  10472. * @param condition defines the trigger related conditions
  10473. */
  10474. constructor(triggerOptions?: any, condition?: Condition);
  10475. /**
  10476. * Execute the action and do nothing.
  10477. */
  10478. execute(): void;
  10479. /**
  10480. * Serializes the actions and its related information.
  10481. * @param parent defines the object to serialize in
  10482. * @returns the serialized object
  10483. */
  10484. serialize(parent: any): any;
  10485. }
  10486. /**
  10487. * This defines an action responsible to trigger several actions once triggered.
  10488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10489. */
  10490. export class CombineAction extends Action {
  10491. /**
  10492. * The list of aggregated animations to run.
  10493. */
  10494. children: Action[];
  10495. /**
  10496. * Instantiate the action
  10497. * @param triggerOptions defines the trigger options
  10498. * @param children defines the list of aggregated animations to run
  10499. * @param condition defines the trigger related conditions
  10500. */
  10501. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10502. /** @hidden */ prepare(): void;
  10503. /**
  10504. * Execute the action and executes all the aggregated actions.
  10505. */
  10506. execute(evt: ActionEvent): void;
  10507. /**
  10508. * Serializes the actions and its related information.
  10509. * @param parent defines the object to serialize in
  10510. * @returns the serialized object
  10511. */
  10512. serialize(parent: any): any;
  10513. }
  10514. /**
  10515. * This defines an action responsible to run code (external event) once triggered.
  10516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10517. */
  10518. export class ExecuteCodeAction extends Action {
  10519. /**
  10520. * The callback function to run.
  10521. */
  10522. func: (evt: ActionEvent) => void;
  10523. /**
  10524. * Instantiate the action
  10525. * @param triggerOptions defines the trigger options
  10526. * @param func defines the callback function to run
  10527. * @param condition defines the trigger related conditions
  10528. */
  10529. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10530. /**
  10531. * Execute the action and run the attached code.
  10532. */
  10533. execute(evt: ActionEvent): void;
  10534. }
  10535. /**
  10536. * This defines an action responsible to set the parent property of the target once triggered.
  10537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10538. */
  10539. export class SetParentAction extends Action {
  10540. private _parent;
  10541. private _target;
  10542. /**
  10543. * Instantiate the action
  10544. * @param triggerOptions defines the trigger options
  10545. * @param target defines the target containing the parent property
  10546. * @param parent defines from where the animation should start (animation frame)
  10547. * @param condition defines the trigger related conditions
  10548. */
  10549. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10550. /** @hidden */ prepare(): void;
  10551. /**
  10552. * Execute the action and set the parent property.
  10553. */
  10554. execute(): void;
  10555. /**
  10556. * Serializes the actions and its related information.
  10557. * @param parent defines the object to serialize in
  10558. * @returns the serialized object
  10559. */
  10560. serialize(parent: any): any;
  10561. }
  10562. }
  10563. declare module BABYLON {
  10564. /**
  10565. * Abstract class used to decouple action Manager from scene and meshes.
  10566. * Do not instantiate.
  10567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10568. */
  10569. export abstract class AbstractActionManager implements IDisposable {
  10570. /** Gets the list of active triggers */
  10571. static Triggers: {
  10572. [key: string]: number;
  10573. };
  10574. /** Gets the cursor to use when hovering items */
  10575. hoverCursor: string;
  10576. /** Gets the list of actions */
  10577. actions: IAction[];
  10578. /**
  10579. * Releases all associated resources
  10580. */
  10581. abstract dispose(): void;
  10582. /**
  10583. * Does this action manager has pointer triggers
  10584. */
  10585. abstract readonly hasPointerTriggers: boolean;
  10586. /**
  10587. * Does this action manager has pick triggers
  10588. */
  10589. abstract readonly hasPickTriggers: boolean;
  10590. /**
  10591. * Process a specific trigger
  10592. * @param trigger defines the trigger to process
  10593. * @param evt defines the event details to be processed
  10594. */
  10595. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  10596. /**
  10597. * Does this action manager handles actions of any of the given triggers
  10598. * @param triggers defines the triggers to be tested
  10599. * @return a boolean indicating whether one (or more) of the triggers is handled
  10600. */
  10601. abstract hasSpecificTriggers(triggers: number[]): boolean;
  10602. /**
  10603. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10604. * speed.
  10605. * @param triggerA defines the trigger to be tested
  10606. * @param triggerB defines the trigger to be tested
  10607. * @return a boolean indicating whether one (or more) of the triggers is handled
  10608. */
  10609. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10610. /**
  10611. * Does this action manager handles actions of a given trigger
  10612. * @param trigger defines the trigger to be tested
  10613. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10614. * @return whether the trigger is handled
  10615. */
  10616. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10617. /**
  10618. * Serialize this manager to a JSON object
  10619. * @param name defines the property name to store this manager
  10620. * @returns a JSON representation of this manager
  10621. */
  10622. abstract serialize(name: string): any;
  10623. /**
  10624. * Does exist one action manager with at least one trigger
  10625. **/
  10626. static readonly HasTriggers: boolean;
  10627. /**
  10628. * Does exist one action manager with at least one pick trigger
  10629. **/
  10630. static readonly HasPickTriggers: boolean;
  10631. /**
  10632. * Does exist one action manager that handles actions of a given trigger
  10633. * @param trigger defines the trigger to be tested
  10634. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  10635. **/
  10636. static HasSpecificTrigger(trigger: number): boolean;
  10637. }
  10638. }
  10639. declare module BABYLON {
  10640. /**
  10641. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10642. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10644. */
  10645. export class ActionManager extends AbstractActionManager {
  10646. /**
  10647. * Nothing
  10648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10649. */
  10650. static readonly NothingTrigger: number;
  10651. /**
  10652. * On pick
  10653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10654. */
  10655. static readonly OnPickTrigger: number;
  10656. /**
  10657. * On left pick
  10658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10659. */
  10660. static readonly OnLeftPickTrigger: number;
  10661. /**
  10662. * On right pick
  10663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10664. */
  10665. static readonly OnRightPickTrigger: number;
  10666. /**
  10667. * On center pick
  10668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10669. */
  10670. static readonly OnCenterPickTrigger: number;
  10671. /**
  10672. * On pick down
  10673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10674. */
  10675. static readonly OnPickDownTrigger: number;
  10676. /**
  10677. * On double pick
  10678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10679. */
  10680. static readonly OnDoublePickTrigger: number;
  10681. /**
  10682. * On pick up
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10684. */
  10685. static readonly OnPickUpTrigger: number;
  10686. /**
  10687. * On pick out.
  10688. * This trigger will only be raised if you also declared a OnPickDown
  10689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10690. */
  10691. static readonly OnPickOutTrigger: number;
  10692. /**
  10693. * On long press
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10695. */
  10696. static readonly OnLongPressTrigger: number;
  10697. /**
  10698. * On pointer over
  10699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10700. */
  10701. static readonly OnPointerOverTrigger: number;
  10702. /**
  10703. * On pointer out
  10704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10705. */
  10706. static readonly OnPointerOutTrigger: number;
  10707. /**
  10708. * On every frame
  10709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10710. */
  10711. static readonly OnEveryFrameTrigger: number;
  10712. /**
  10713. * On intersection enter
  10714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10715. */
  10716. static readonly OnIntersectionEnterTrigger: number;
  10717. /**
  10718. * On intersection exit
  10719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10720. */
  10721. static readonly OnIntersectionExitTrigger: number;
  10722. /**
  10723. * On key down
  10724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10725. */
  10726. static readonly OnKeyDownTrigger: number;
  10727. /**
  10728. * On key up
  10729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10730. */
  10731. static readonly OnKeyUpTrigger: number;
  10732. private _scene;
  10733. /**
  10734. * Creates a new action manager
  10735. * @param scene defines the hosting scene
  10736. */
  10737. constructor(scene: Scene);
  10738. /**
  10739. * Releases all associated resources
  10740. */
  10741. dispose(): void;
  10742. /**
  10743. * Gets hosting scene
  10744. * @returns the hosting scene
  10745. */
  10746. getScene(): Scene;
  10747. /**
  10748. * Does this action manager handles actions of any of the given triggers
  10749. * @param triggers defines the triggers to be tested
  10750. * @return a boolean indicating whether one (or more) of the triggers is handled
  10751. */
  10752. hasSpecificTriggers(triggers: number[]): boolean;
  10753. /**
  10754. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10755. * speed.
  10756. * @param triggerA defines the trigger to be tested
  10757. * @param triggerB defines the trigger to be tested
  10758. * @return a boolean indicating whether one (or more) of the triggers is handled
  10759. */
  10760. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10761. /**
  10762. * Does this action manager handles actions of a given trigger
  10763. * @param trigger defines the trigger to be tested
  10764. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10765. * @return whether the trigger is handled
  10766. */
  10767. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10768. /**
  10769. * Does this action manager has pointer triggers
  10770. */
  10771. readonly hasPointerTriggers: boolean;
  10772. /**
  10773. * Does this action manager has pick triggers
  10774. */
  10775. readonly hasPickTriggers: boolean;
  10776. /**
  10777. * Registers an action to this action manager
  10778. * @param action defines the action to be registered
  10779. * @return the action amended (prepared) after registration
  10780. */
  10781. registerAction(action: Action): Nullable<Action>;
  10782. /**
  10783. * Unregisters an action to this action manager
  10784. * @param action defines the action to be unregistered
  10785. * @return a boolean indicating whether the action has been unregistered
  10786. */
  10787. unregisterAction(action: Action): Boolean;
  10788. /**
  10789. * Process a specific trigger
  10790. * @param trigger defines the trigger to process
  10791. * @param evt defines the event details to be processed
  10792. */
  10793. processTrigger(trigger: number, evt?: IActionEvent): void;
  10794. /** @hidden */ getEffectiveTarget(target: any, propertyPath: string): any;
  10795. /** @hidden */ getProperty(propertyPath: string): string;
  10796. /**
  10797. * Serialize this manager to a JSON object
  10798. * @param name defines the property name to store this manager
  10799. * @returns a JSON representation of this manager
  10800. */
  10801. serialize(name: string): any;
  10802. /**
  10803. * Creates a new ActionManager from a JSON data
  10804. * @param parsedActions defines the JSON data to read from
  10805. * @param object defines the hosting mesh
  10806. * @param scene defines the hosting scene
  10807. */
  10808. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10809. /**
  10810. * Get a trigger name by index
  10811. * @param trigger defines the trigger index
  10812. * @returns a trigger name
  10813. */
  10814. static GetTriggerName(trigger: number): string;
  10815. }
  10816. }
  10817. declare module BABYLON {
  10818. /**
  10819. * Class representing a ray with position and direction
  10820. */
  10821. export class Ray {
  10822. /** origin point */
  10823. origin: Vector3;
  10824. /** direction */
  10825. direction: Vector3;
  10826. /** length of the ray */
  10827. length: number;
  10828. private static readonly TmpVector3;
  10829. private _tmpRay;
  10830. /**
  10831. * Creates a new ray
  10832. * @param origin origin point
  10833. * @param direction direction
  10834. * @param length length of the ray
  10835. */
  10836. constructor(
  10837. /** origin point */
  10838. origin: Vector3,
  10839. /** direction */
  10840. direction: Vector3,
  10841. /** length of the ray */
  10842. length?: number);
  10843. /**
  10844. * Checks if the ray intersects a box
  10845. * @param minimum bound of the box
  10846. * @param maximum bound of the box
  10847. * @param intersectionTreshold extra extend to be added to the box in all direction
  10848. * @returns if the box was hit
  10849. */
  10850. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10851. /**
  10852. * Checks if the ray intersects a box
  10853. * @param box the bounding box to check
  10854. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10855. * @returns if the box was hit
  10856. */
  10857. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10858. /**
  10859. * If the ray hits a sphere
  10860. * @param sphere the bounding sphere to check
  10861. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10862. * @returns true if it hits the sphere
  10863. */
  10864. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10865. /**
  10866. * If the ray hits a triange
  10867. * @param vertex0 triangle vertex
  10868. * @param vertex1 triangle vertex
  10869. * @param vertex2 triangle vertex
  10870. * @returns intersection information if hit
  10871. */
  10872. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10873. /**
  10874. * Checks if ray intersects a plane
  10875. * @param plane the plane to check
  10876. * @returns the distance away it was hit
  10877. */
  10878. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10879. /**
  10880. * Checks if ray intersects a mesh
  10881. * @param mesh the mesh to check
  10882. * @param fastCheck if only the bounding box should checked
  10883. * @returns picking info of the intersecton
  10884. */
  10885. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10886. /**
  10887. * Checks if ray intersects a mesh
  10888. * @param meshes the meshes to check
  10889. * @param fastCheck if only the bounding box should checked
  10890. * @param results array to store result in
  10891. * @returns Array of picking infos
  10892. */
  10893. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10894. private _comparePickingInfo;
  10895. private static smallnum;
  10896. private static rayl;
  10897. /**
  10898. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10899. * @param sega the first point of the segment to test the intersection against
  10900. * @param segb the second point of the segment to test the intersection against
  10901. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10902. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10903. */
  10904. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10905. /**
  10906. * Update the ray from viewport position
  10907. * @param x position
  10908. * @param y y position
  10909. * @param viewportWidth viewport width
  10910. * @param viewportHeight viewport height
  10911. * @param world world matrix
  10912. * @param view view matrix
  10913. * @param projection projection matrix
  10914. * @returns this ray updated
  10915. */
  10916. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10917. /**
  10918. * Creates a ray with origin and direction of 0,0,0
  10919. * @returns the new ray
  10920. */
  10921. static Zero(): Ray;
  10922. /**
  10923. * Creates a new ray from screen space and viewport
  10924. * @param x position
  10925. * @param y y position
  10926. * @param viewportWidth viewport width
  10927. * @param viewportHeight viewport height
  10928. * @param world world matrix
  10929. * @param view view matrix
  10930. * @param projection projection matrix
  10931. * @returns new ray
  10932. */
  10933. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10934. /**
  10935. * 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
  10936. * transformed to the given world matrix.
  10937. * @param origin The origin point
  10938. * @param end The end point
  10939. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10940. * @returns the new ray
  10941. */
  10942. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10943. /**
  10944. * Transforms a ray by a matrix
  10945. * @param ray ray to transform
  10946. * @param matrix matrix to apply
  10947. * @returns the resulting new ray
  10948. */
  10949. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10950. /**
  10951. * Transforms a ray by a matrix
  10952. * @param ray ray to transform
  10953. * @param matrix matrix to apply
  10954. * @param result ray to store result in
  10955. */
  10956. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10957. /**
  10958. * Unproject a ray from screen space to object space
  10959. * @param sourceX defines the screen space x coordinate to use
  10960. * @param sourceY defines the screen space y coordinate to use
  10961. * @param viewportWidth defines the current width of the viewport
  10962. * @param viewportHeight defines the current height of the viewport
  10963. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10964. * @param view defines the view matrix to use
  10965. * @param projection defines the projection matrix to use
  10966. */
  10967. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10968. }
  10969. interface Scene {
  10970. /** @hidden */ tempPickingRay: Nullable<Ray>;
  10971. /** @hidden */ cachedRayForTransform: Ray;
  10972. /** @hidden */ pickWithRayInverseMatrix: Matrix;
  10973. /** @hidden */ internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10974. /** @hidden */ internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  10975. }
  10976. }
  10977. declare module BABYLON {
  10978. /**
  10979. * Groups all the scene component constants in one place to ease maintenance.
  10980. * @hidden
  10981. */
  10982. export class SceneComponentConstants {
  10983. static readonly NAME_EFFECTLAYER: string;
  10984. static readonly NAME_LAYER: string;
  10985. static readonly NAME_LENSFLARESYSTEM: string;
  10986. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10987. static readonly NAME_PARTICLESYSTEM: string;
  10988. static readonly NAME_GAMEPAD: string;
  10989. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10990. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10991. static readonly NAME_DEPTHRENDERER: string;
  10992. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10993. static readonly NAME_SPRITE: string;
  10994. static readonly NAME_OUTLINERENDERER: string;
  10995. static readonly NAME_PROCEDURALTEXTURE: string;
  10996. static readonly NAME_SHADOWGENERATOR: string;
  10997. static readonly NAME_OCTREE: string;
  10998. static readonly NAME_PHYSICSENGINE: string;
  10999. static readonly NAME_AUDIO: string;
  11000. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11001. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11002. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11003. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11004. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11005. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11006. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11007. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11008. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11009. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11010. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11011. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11012. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11013. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11014. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11015. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11016. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11017. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11018. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11019. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11020. static readonly STEP_AFTERRENDER_AUDIO: number;
  11021. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11022. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11023. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11024. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11025. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11026. static readonly STEP_POINTERMOVE_SPRITE: number;
  11027. static readonly STEP_POINTERDOWN_SPRITE: number;
  11028. static readonly STEP_POINTERUP_SPRITE: number;
  11029. }
  11030. /**
  11031. * This represents a scene component.
  11032. *
  11033. * This is used to decouple the dependency the scene is having on the different workloads like
  11034. * layers, post processes...
  11035. */
  11036. export interface ISceneComponent {
  11037. /**
  11038. * The name of the component. Each component must have a unique name.
  11039. */
  11040. name: string;
  11041. /**
  11042. * The scene the component belongs to.
  11043. */
  11044. scene: Scene;
  11045. /**
  11046. * Register the component to one instance of a scene.
  11047. */
  11048. register(): void;
  11049. /**
  11050. * Rebuilds the elements related to this component in case of
  11051. * context lost for instance.
  11052. */
  11053. rebuild(): void;
  11054. /**
  11055. * Disposes the component and the associated ressources.
  11056. */
  11057. dispose(): void;
  11058. }
  11059. /**
  11060. * This represents a SERIALIZABLE scene component.
  11061. *
  11062. * This extends Scene Component to add Serialization methods on top.
  11063. */
  11064. export interface ISceneSerializableComponent extends ISceneComponent {
  11065. /**
  11066. * Adds all the element from the container to the scene
  11067. * @param container the container holding the elements
  11068. */
  11069. addFromContainer(container: AbstractScene): void;
  11070. /**
  11071. * Removes all the elements in the container from the scene
  11072. * @param container contains the elements to remove
  11073. */
  11074. removeFromContainer(container: AbstractScene): void;
  11075. /**
  11076. * Serializes the component data to the specified json object
  11077. * @param serializationObject The object to serialize to
  11078. */
  11079. serialize(serializationObject: any): void;
  11080. }
  11081. /**
  11082. * Strong typing of a Mesh related stage step action
  11083. */
  11084. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11085. /**
  11086. * Strong typing of a Evaluate Sub Mesh related stage step action
  11087. */
  11088. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11089. /**
  11090. * Strong typing of a Active Mesh related stage step action
  11091. */
  11092. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11093. /**
  11094. * Strong typing of a Camera related stage step action
  11095. */
  11096. export type CameraStageAction = (camera: Camera) => void;
  11097. /**
  11098. * Strong typing of a Render Target related stage step action
  11099. */
  11100. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11101. /**
  11102. * Strong typing of a RenderingGroup related stage step action
  11103. */
  11104. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11105. /**
  11106. * Strong typing of a Mesh Render related stage step action
  11107. */
  11108. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11109. /**
  11110. * Strong typing of a simple stage step action
  11111. */
  11112. export type SimpleStageAction = () => void;
  11113. /**
  11114. * Strong typing of a render target action.
  11115. */
  11116. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11117. /**
  11118. * Strong typing of a pointer move action.
  11119. */
  11120. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11121. /**
  11122. * Strong typing of a pointer up/down action.
  11123. */
  11124. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11125. /**
  11126. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11127. * @hidden
  11128. */
  11129. export class Stage<T extends Function> extends Array<{
  11130. index: number;
  11131. component: ISceneComponent;
  11132. action: T;
  11133. }> {
  11134. /**
  11135. * Hide ctor from the rest of the world.
  11136. * @param items The items to add.
  11137. */
  11138. private constructor();
  11139. /**
  11140. * Creates a new Stage.
  11141. * @returns A new instance of a Stage
  11142. */
  11143. static Create<T extends Function>(): Stage<T>;
  11144. /**
  11145. * Registers a step in an ordered way in the targeted stage.
  11146. * @param index Defines the position to register the step in
  11147. * @param component Defines the component attached to the step
  11148. * @param action Defines the action to launch during the step
  11149. */
  11150. registerStep(index: number, component: ISceneComponent, action: T): void;
  11151. /**
  11152. * Clears all the steps from the stage.
  11153. */
  11154. clear(): void;
  11155. }
  11156. }
  11157. declare module BABYLON {
  11158. interface Scene {
  11159. /** @hidden */ pointerOverSprite: Nullable<Sprite>;
  11160. /** @hidden */ pickedDownSprite: Nullable<Sprite>;
  11161. /** @hidden */ tempSpritePickingRay: Nullable<Ray>;
  11162. /**
  11163. * All of the sprite managers added to this scene
  11164. * @see http://doc.babylonjs.com/babylon101/sprites
  11165. */
  11166. spriteManagers: Array<ISpriteManager>;
  11167. /**
  11168. * An event triggered when sprites rendering is about to start
  11169. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11170. */
  11171. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11172. /**
  11173. * An event triggered when sprites rendering is done
  11174. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11175. */
  11176. onAfterSpritesRenderingObservable: Observable<Scene>;
  11177. /** @hidden */ internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11178. /** Launch a ray to try to pick a sprite in the scene
  11179. * @param x position on screen
  11180. * @param y position on screen
  11181. * @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
  11182. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11183. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11184. * @returns a PickingInfo
  11185. */
  11186. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11187. /** Use the given ray to pick a sprite in the scene
  11188. * @param ray The ray (in world space) to use to pick meshes
  11189. * @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
  11190. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11191. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11192. * @returns a PickingInfo
  11193. */
  11194. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11195. /**
  11196. * Force the sprite under the pointer
  11197. * @param sprite defines the sprite to use
  11198. */
  11199. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11200. /**
  11201. * Gets the sprite under the pointer
  11202. * @returns a Sprite or null if no sprite is under the pointer
  11203. */
  11204. getPointerOverSprite(): Nullable<Sprite>;
  11205. }
  11206. /**
  11207. * Defines the sprite scene component responsible to manage sprites
  11208. * in a given scene.
  11209. */
  11210. export class SpriteSceneComponent implements ISceneComponent {
  11211. /**
  11212. * The component name helpfull to identify the component in the list of scene components.
  11213. */
  11214. readonly name: string;
  11215. /**
  11216. * The scene the component belongs to.
  11217. */
  11218. scene: Scene;
  11219. /** @hidden */
  11220. private _spritePredicate;
  11221. /**
  11222. * Creates a new instance of the component for the given scene
  11223. * @param scene Defines the scene to register the component in
  11224. */
  11225. constructor(scene: Scene);
  11226. /**
  11227. * Registers the component in a given scene
  11228. */
  11229. register(): void;
  11230. /**
  11231. * Rebuilds the elements related to this component in case of
  11232. * context lost for instance.
  11233. */
  11234. rebuild(): void;
  11235. /**
  11236. * Disposes the component and the associated ressources.
  11237. */
  11238. dispose(): void;
  11239. private _pickSpriteButKeepRay;
  11240. private _pointerMove;
  11241. private _pointerDown;
  11242. private _pointerUp;
  11243. }
  11244. }
  11245. declare module BABYLON {
  11246. /** @hidden */
  11247. export var fogFragmentDeclaration: {
  11248. name: string;
  11249. shader: string;
  11250. };
  11251. }
  11252. declare module BABYLON {
  11253. /** @hidden */
  11254. export var fogFragment: {
  11255. name: string;
  11256. shader: string;
  11257. };
  11258. }
  11259. declare module BABYLON {
  11260. /** @hidden */
  11261. export var spritesPixelShader: {
  11262. name: string;
  11263. shader: string;
  11264. };
  11265. }
  11266. declare module BABYLON {
  11267. /** @hidden */
  11268. export var fogVertexDeclaration: {
  11269. name: string;
  11270. shader: string;
  11271. };
  11272. }
  11273. declare module BABYLON {
  11274. /** @hidden */
  11275. export var spritesVertexShader: {
  11276. name: string;
  11277. shader: string;
  11278. };
  11279. }
  11280. declare module BABYLON {
  11281. /**
  11282. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11283. */
  11284. export interface ISpriteManager extends IDisposable {
  11285. /**
  11286. * Restricts the camera to viewing objects with the same layerMask.
  11287. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11288. */
  11289. layerMask: number;
  11290. /**
  11291. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11292. */
  11293. isPickable: boolean;
  11294. /**
  11295. * Specifies the rendering group id for this mesh (0 by default)
  11296. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11297. */
  11298. renderingGroupId: number;
  11299. /**
  11300. * Defines the list of sprites managed by the manager.
  11301. */
  11302. sprites: Array<Sprite>;
  11303. /**
  11304. * Tests the intersection of a sprite with a specific ray.
  11305. * @param ray The ray we are sending to test the collision
  11306. * @param camera The camera space we are sending rays in
  11307. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11308. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11309. * @returns picking info or null.
  11310. */
  11311. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11312. /**
  11313. * Renders the list of sprites on screen.
  11314. */
  11315. render(): void;
  11316. }
  11317. /**
  11318. * Class used to manage multiple sprites on the same spritesheet
  11319. * @see http://doc.babylonjs.com/babylon101/sprites
  11320. */
  11321. export class SpriteManager implements ISpriteManager {
  11322. /** defines the manager's name */
  11323. name: string;
  11324. /** Gets the list of sprites */
  11325. sprites: Sprite[];
  11326. /** Gets or sets the rendering group id (0 by default) */
  11327. renderingGroupId: number;
  11328. /** Gets or sets camera layer mask */
  11329. layerMask: number;
  11330. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11331. fogEnabled: boolean;
  11332. /** Gets or sets a boolean indicating if the sprites are pickable */
  11333. isPickable: boolean;
  11334. /** Defines the default width of a cell in the spritesheet */
  11335. cellWidth: number;
  11336. /** Defines the default height of a cell in the spritesheet */
  11337. cellHeight: number;
  11338. /**
  11339. * An event triggered when the manager is disposed.
  11340. */
  11341. onDisposeObservable: Observable<SpriteManager>;
  11342. private _onDisposeObserver;
  11343. /**
  11344. * Callback called when the manager is disposed
  11345. */
  11346. onDispose: () => void;
  11347. private _capacity;
  11348. private _spriteTexture;
  11349. private _epsilon;
  11350. private _scene;
  11351. private _vertexData;
  11352. private _buffer;
  11353. private _vertexBuffers;
  11354. private _indexBuffer;
  11355. private _effectBase;
  11356. private _effectFog;
  11357. /**
  11358. * Gets or sets the spritesheet texture
  11359. */
  11360. texture: Texture;
  11361. /**
  11362. * Creates a new sprite manager
  11363. * @param name defines the manager's name
  11364. * @param imgUrl defines the sprite sheet url
  11365. * @param capacity defines the maximum allowed number of sprites
  11366. * @param cellSize defines the size of a sprite cell
  11367. * @param scene defines the hosting scene
  11368. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11369. * @param samplingMode defines the smapling mode to use with spritesheet
  11370. */
  11371. constructor(
  11372. /** defines the manager's name */
  11373. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11374. private _appendSpriteVertex;
  11375. /**
  11376. * Intersects the sprites with a ray
  11377. * @param ray defines the ray to intersect with
  11378. * @param camera defines the current active camera
  11379. * @param predicate defines a predicate used to select candidate sprites
  11380. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11381. * @returns null if no hit or a PickingInfo
  11382. */
  11383. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11384. /**
  11385. * Render all child sprites
  11386. */
  11387. render(): void;
  11388. /**
  11389. * Release associated resources
  11390. */
  11391. dispose(): void;
  11392. }
  11393. }
  11394. declare module BABYLON {
  11395. /**
  11396. * Class used to represent a sprite
  11397. * @see http://doc.babylonjs.com/babylon101/sprites
  11398. */
  11399. export class Sprite {
  11400. /** defines the name */
  11401. name: string;
  11402. /** Gets or sets the current world position */
  11403. position: Vector3;
  11404. /** Gets or sets the main color */
  11405. color: Color4;
  11406. /** Gets or sets the width */
  11407. width: number;
  11408. /** Gets or sets the height */
  11409. height: number;
  11410. /** Gets or sets rotation angle */
  11411. angle: number;
  11412. /** Gets or sets the cell index in the sprite sheet */
  11413. cellIndex: number;
  11414. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11415. invertU: number;
  11416. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11417. invertV: number;
  11418. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11419. disposeWhenFinishedAnimating: boolean;
  11420. /** Gets the list of attached animations */
  11421. animations: Animation[];
  11422. /** Gets or sets a boolean indicating if the sprite can be picked */
  11423. isPickable: boolean;
  11424. /**
  11425. * Gets or sets the associated action manager
  11426. */
  11427. actionManager: Nullable<ActionManager>;
  11428. private _animationStarted;
  11429. private _loopAnimation;
  11430. private _fromIndex;
  11431. private _toIndex;
  11432. private _delay;
  11433. private _direction;
  11434. private _manager;
  11435. private _time;
  11436. private _onAnimationEnd;
  11437. /**
  11438. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11439. */
  11440. isVisible: boolean;
  11441. /**
  11442. * Gets or sets the sprite size
  11443. */
  11444. size: number;
  11445. /**
  11446. * Creates a new Sprite
  11447. * @param name defines the name
  11448. * @param manager defines the manager
  11449. */
  11450. constructor(
  11451. /** defines the name */
  11452. name: string, manager: ISpriteManager);
  11453. /**
  11454. * Starts an animation
  11455. * @param from defines the initial key
  11456. * @param to defines the end key
  11457. * @param loop defines if the animation must loop
  11458. * @param delay defines the start delay (in ms)
  11459. * @param onAnimationEnd defines a callback to call when animation ends
  11460. */
  11461. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11462. /** Stops current animation (if any) */
  11463. stopAnimation(): void;
  11464. /** @hidden */ animate(deltaTime: number): void;
  11465. /** Release associated resources */
  11466. dispose(): void;
  11467. }
  11468. }
  11469. declare module BABYLON {
  11470. /**
  11471. * Information about the result of picking within a scene
  11472. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11473. */
  11474. export class PickingInfo {
  11475. /** @hidden */ pickingUnavailable: boolean;
  11476. /**
  11477. * If the pick collided with an object
  11478. */
  11479. hit: boolean;
  11480. /**
  11481. * Distance away where the pick collided
  11482. */
  11483. distance: number;
  11484. /**
  11485. * The location of pick collision
  11486. */
  11487. pickedPoint: Nullable<Vector3>;
  11488. /**
  11489. * The mesh corresponding the the pick collision
  11490. */
  11491. pickedMesh: Nullable<AbstractMesh>;
  11492. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11493. bu: number;
  11494. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11495. bv: number;
  11496. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11497. faceId: number;
  11498. /** Id of the the submesh that was picked */
  11499. subMeshId: number;
  11500. /** If a sprite was picked, this will be the sprite the pick collided with */
  11501. pickedSprite: Nullable<Sprite>;
  11502. /**
  11503. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11504. */
  11505. originMesh: Nullable<AbstractMesh>;
  11506. /**
  11507. * The ray that was used to perform the picking.
  11508. */
  11509. ray: Nullable<Ray>;
  11510. /**
  11511. * Gets the normal correspodning to the face the pick collided with
  11512. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11513. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11514. * @returns The normal correspodning to the face the pick collided with
  11515. */
  11516. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11517. /**
  11518. * Gets the texture coordinates of where the pick occured
  11519. * @returns the vector containing the coordnates of the texture
  11520. */
  11521. getTextureCoordinates(): Nullable<Vector2>;
  11522. }
  11523. }
  11524. declare module BABYLON {
  11525. /**
  11526. * Gather the list of pointer event types as constants.
  11527. */
  11528. export class PointerEventTypes {
  11529. /**
  11530. * 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.
  11531. */
  11532. static readonly POINTERDOWN: number;
  11533. /**
  11534. * The pointerup event is fired when a pointer is no longer active.
  11535. */
  11536. static readonly POINTERUP: number;
  11537. /**
  11538. * The pointermove event is fired when a pointer changes coordinates.
  11539. */
  11540. static readonly POINTERMOVE: number;
  11541. /**
  11542. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11543. */
  11544. static readonly POINTERWHEEL: number;
  11545. /**
  11546. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11547. */
  11548. static readonly POINTERPICK: number;
  11549. /**
  11550. * The pointertap event is fired when a the object has been touched and released without drag.
  11551. */
  11552. static readonly POINTERTAP: number;
  11553. /**
  11554. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11555. */
  11556. static readonly POINTERDOUBLETAP: number;
  11557. }
  11558. /**
  11559. * Base class of pointer info types.
  11560. */
  11561. export class PointerInfoBase {
  11562. /**
  11563. * Defines the type of event (PointerEventTypes)
  11564. */
  11565. type: number;
  11566. /**
  11567. * Defines the related dom event
  11568. */
  11569. event: PointerEvent | MouseWheelEvent;
  11570. /**
  11571. * Instantiates the base class of pointers info.
  11572. * @param type Defines the type of event (PointerEventTypes)
  11573. * @param event Defines the related dom event
  11574. */
  11575. constructor(
  11576. /**
  11577. * Defines the type of event (PointerEventTypes)
  11578. */
  11579. type: number,
  11580. /**
  11581. * Defines the related dom event
  11582. */
  11583. event: PointerEvent | MouseWheelEvent);
  11584. }
  11585. /**
  11586. * This class is used to store pointer related info for the onPrePointerObservable event.
  11587. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11588. */
  11589. export class PointerInfoPre extends PointerInfoBase {
  11590. /**
  11591. * Ray from a pointer if availible (eg. 6dof controller)
  11592. */
  11593. ray: Nullable<Ray>;
  11594. /**
  11595. * Defines the local position of the pointer on the canvas.
  11596. */
  11597. localPosition: Vector2;
  11598. /**
  11599. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11600. */
  11601. skipOnPointerObservable: boolean;
  11602. /**
  11603. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11604. * @param type Defines the type of event (PointerEventTypes)
  11605. * @param event Defines the related dom event
  11606. * @param localX Defines the local x coordinates of the pointer when the event occured
  11607. * @param localY Defines the local y coordinates of the pointer when the event occured
  11608. */
  11609. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11610. }
  11611. /**
  11612. * This type contains all the data related to a pointer event in Babylon.js.
  11613. * 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.
  11614. */
  11615. export class PointerInfo extends PointerInfoBase {
  11616. /**
  11617. * Defines the picking info associated to the info (if any)\
  11618. */
  11619. pickInfo: Nullable<PickingInfo>;
  11620. /**
  11621. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11622. * @param type Defines the type of event (PointerEventTypes)
  11623. * @param event Defines the related dom event
  11624. * @param pickInfo Defines the picking info associated to the info (if any)\
  11625. */
  11626. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11627. /**
  11628. * Defines the picking info associated to the info (if any)\
  11629. */
  11630. pickInfo: Nullable<PickingInfo>);
  11631. }
  11632. }
  11633. declare module BABYLON {
  11634. /**
  11635. * Manage the mouse inputs to control the movement of a free camera.
  11636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11637. */
  11638. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11639. /**
  11640. * Define if touch is enabled in the mouse input
  11641. */
  11642. touchEnabled: boolean;
  11643. /**
  11644. * Defines the camera the input is attached to.
  11645. */
  11646. camera: FreeCamera;
  11647. /**
  11648. * Defines the buttons associated with the input to handle camera move.
  11649. */
  11650. buttons: number[];
  11651. /**
  11652. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11653. */
  11654. angularSensibility: number;
  11655. private _pointerInput;
  11656. private _onMouseMove;
  11657. private _observer;
  11658. private previousPosition;
  11659. /**
  11660. * Manage the mouse inputs to control the movement of a free camera.
  11661. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11662. * @param touchEnabled Defines if touch is enabled or not
  11663. */
  11664. constructor(
  11665. /**
  11666. * Define if touch is enabled in the mouse input
  11667. */
  11668. touchEnabled?: boolean);
  11669. /**
  11670. * Attach the input controls to a specific dom element to get the input from.
  11671. * @param element Defines the element the controls should be listened from
  11672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11673. */
  11674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11675. /**
  11676. * Detach the current controls from the specified dom element.
  11677. * @param element Defines the element to stop listening the inputs from
  11678. */
  11679. detachControl(element: Nullable<HTMLElement>): void;
  11680. /**
  11681. * Gets the class name of the current intput.
  11682. * @returns the class name
  11683. */
  11684. getClassName(): string;
  11685. /**
  11686. * Get the friendly name associated with the input class.
  11687. * @returns the input friendly name
  11688. */
  11689. getSimpleName(): string;
  11690. }
  11691. }
  11692. declare module BABYLON {
  11693. /**
  11694. * Manage the touch inputs to control the movement of a free camera.
  11695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11696. */
  11697. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11698. /**
  11699. * Defines the camera the input is attached to.
  11700. */
  11701. camera: FreeCamera;
  11702. /**
  11703. * Defines the touch sensibility for rotation.
  11704. * The higher the faster.
  11705. */
  11706. touchAngularSensibility: number;
  11707. /**
  11708. * Defines the touch sensibility for move.
  11709. * The higher the faster.
  11710. */
  11711. touchMoveSensibility: number;
  11712. private _offsetX;
  11713. private _offsetY;
  11714. private _pointerPressed;
  11715. private _pointerInput;
  11716. private _observer;
  11717. private _onLostFocus;
  11718. /**
  11719. * Attach the input controls to a specific dom element to get the input from.
  11720. * @param element Defines the element the controls should be listened from
  11721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11722. */
  11723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11724. /**
  11725. * Detach the current controls from the specified dom element.
  11726. * @param element Defines the element to stop listening the inputs from
  11727. */
  11728. detachControl(element: Nullable<HTMLElement>): void;
  11729. /**
  11730. * Update the current camera state depending on the inputs that have been used this frame.
  11731. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11732. */
  11733. checkInputs(): void;
  11734. /**
  11735. * Gets the class name of the current intput.
  11736. * @returns the class name
  11737. */
  11738. getClassName(): string;
  11739. /**
  11740. * Get the friendly name associated with the input class.
  11741. * @returns the input friendly name
  11742. */
  11743. getSimpleName(): string;
  11744. }
  11745. }
  11746. declare module BABYLON {
  11747. /**
  11748. * Default Inputs manager for the FreeCamera.
  11749. * It groups all the default supported inputs for ease of use.
  11750. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11751. */
  11752. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11753. /**
  11754. * Instantiates a new FreeCameraInputsManager.
  11755. * @param camera Defines the camera the inputs belong to
  11756. */
  11757. constructor(camera: FreeCamera);
  11758. /**
  11759. * Add keyboard input support to the input manager.
  11760. * @returns the current input manager
  11761. */
  11762. addKeyboard(): FreeCameraInputsManager;
  11763. /**
  11764. * Add mouse input support to the input manager.
  11765. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11766. * @returns the current input manager
  11767. */
  11768. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11769. /**
  11770. * Add touch input support to the input manager.
  11771. * @returns the current input manager
  11772. */
  11773. addTouch(): FreeCameraInputsManager;
  11774. }
  11775. }
  11776. declare module BABYLON {
  11777. /**
  11778. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11779. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11780. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11781. */
  11782. export class FreeCamera extends TargetCamera {
  11783. /**
  11784. * Define the collision ellipsoid of the camera.
  11785. * This is helpful to simulate a camera body like the player body around the camera
  11786. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11787. */
  11788. ellipsoid: Vector3;
  11789. /**
  11790. * Define an offset for the position of the ellipsoid around the camera.
  11791. * This can be helpful to determine the center of the body near the gravity center of the body
  11792. * instead of its head.
  11793. */
  11794. ellipsoidOffset: Vector3;
  11795. /**
  11796. * Enable or disable collisions of the camera with the rest of the scene objects.
  11797. */
  11798. checkCollisions: boolean;
  11799. /**
  11800. * Enable or disable gravity on the camera.
  11801. */
  11802. applyGravity: boolean;
  11803. /**
  11804. * Define the input manager associated to the camera.
  11805. */
  11806. inputs: FreeCameraInputsManager;
  11807. /**
  11808. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11809. * Higher values reduce sensitivity.
  11810. */
  11811. /**
  11812. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11813. * Higher values reduce sensitivity.
  11814. */
  11815. angularSensibility: number;
  11816. /**
  11817. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11818. */
  11819. keysUp: number[];
  11820. /**
  11821. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11822. */
  11823. keysDown: number[];
  11824. /**
  11825. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11826. */
  11827. keysLeft: number[];
  11828. /**
  11829. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11830. */
  11831. keysRight: number[];
  11832. /**
  11833. * Event raised when the camera collide with a mesh in the scene.
  11834. */
  11835. onCollide: (collidedMesh: AbstractMesh) => void;
  11836. private _collider;
  11837. private _needMoveForGravity;
  11838. private _oldPosition;
  11839. private _diffPosition;
  11840. private _newPosition;
  11841. /** @hidden */ localDirection: Vector3;
  11842. /** @hidden */ transformedDirection: Vector3;
  11843. /**
  11844. * Instantiates a Free Camera.
  11845. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11846. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11847. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11848. * @param name Define the name of the camera in the scene
  11849. * @param position Define the start position of the camera in the scene
  11850. * @param scene Define the scene the camera belongs to
  11851. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11852. */
  11853. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11854. /**
  11855. * Attached controls to the current camera.
  11856. * @param element Defines the element the controls should be listened from
  11857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11858. */
  11859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11860. /**
  11861. * Detach the current controls from the camera.
  11862. * The camera will stop reacting to inputs.
  11863. * @param element Defines the element to stop listening the inputs from
  11864. */
  11865. detachControl(element: HTMLElement): void;
  11866. private _collisionMask;
  11867. /**
  11868. * Define a collision mask to limit the list of object the camera can collide with
  11869. */
  11870. collisionMask: number;
  11871. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  11872. private _onCollisionPositionChange;
  11873. /** @hidden */ checkInputs(): void;
  11874. /** @hidden */ decideIfNeedsToMove(): boolean;
  11875. /** @hidden */ updatePosition(): void;
  11876. /**
  11877. * Destroy the camera and release the current resources hold by it.
  11878. */
  11879. dispose(): void;
  11880. /**
  11881. * Gets the current object class name.
  11882. * @return the class name
  11883. */
  11884. getClassName(): string;
  11885. }
  11886. }
  11887. declare module BABYLON {
  11888. /**
  11889. * Represents a gamepad control stick position
  11890. */
  11891. export class StickValues {
  11892. /**
  11893. * The x component of the control stick
  11894. */
  11895. x: number;
  11896. /**
  11897. * The y component of the control stick
  11898. */
  11899. y: number;
  11900. /**
  11901. * Initializes the gamepad x and y control stick values
  11902. * @param x The x component of the gamepad control stick value
  11903. * @param y The y component of the gamepad control stick value
  11904. */
  11905. constructor(
  11906. /**
  11907. * The x component of the control stick
  11908. */
  11909. x: number,
  11910. /**
  11911. * The y component of the control stick
  11912. */
  11913. y: number);
  11914. }
  11915. /**
  11916. * An interface which manages callbacks for gamepad button changes
  11917. */
  11918. export interface GamepadButtonChanges {
  11919. /**
  11920. * Called when a gamepad has been changed
  11921. */
  11922. changed: boolean;
  11923. /**
  11924. * Called when a gamepad press event has been triggered
  11925. */
  11926. pressChanged: boolean;
  11927. /**
  11928. * Called when a touch event has been triggered
  11929. */
  11930. touchChanged: boolean;
  11931. /**
  11932. * Called when a value has changed
  11933. */
  11934. valueChanged: boolean;
  11935. }
  11936. /**
  11937. * Represents a gamepad
  11938. */
  11939. export class Gamepad {
  11940. /**
  11941. * The id of the gamepad
  11942. */
  11943. id: string;
  11944. /**
  11945. * The index of the gamepad
  11946. */
  11947. index: number;
  11948. /**
  11949. * The browser gamepad
  11950. */
  11951. browserGamepad: any;
  11952. /**
  11953. * Specifies what type of gamepad this represents
  11954. */
  11955. type: number;
  11956. private _leftStick;
  11957. private _rightStick;
  11958. /** @hidden */ isConnected: boolean;
  11959. private _leftStickAxisX;
  11960. private _leftStickAxisY;
  11961. private _rightStickAxisX;
  11962. private _rightStickAxisY;
  11963. /**
  11964. * Triggered when the left control stick has been changed
  11965. */
  11966. private _onleftstickchanged;
  11967. /**
  11968. * Triggered when the right control stick has been changed
  11969. */
  11970. private _onrightstickchanged;
  11971. /**
  11972. * Represents a gamepad controller
  11973. */
  11974. static GAMEPAD: number;
  11975. /**
  11976. * Represents a generic controller
  11977. */
  11978. static GENERIC: number;
  11979. /**
  11980. * Represents an XBox controller
  11981. */
  11982. static XBOX: number;
  11983. /**
  11984. * Represents a pose-enabled controller
  11985. */
  11986. static POSE_ENABLED: number;
  11987. /**
  11988. * Specifies whether the left control stick should be Y-inverted
  11989. */
  11990. protected _invertLeftStickY: boolean;
  11991. /**
  11992. * Specifies if the gamepad has been connected
  11993. */
  11994. readonly isConnected: boolean;
  11995. /**
  11996. * Initializes the gamepad
  11997. * @param id The id of the gamepad
  11998. * @param index The index of the gamepad
  11999. * @param browserGamepad The browser gamepad
  12000. * @param leftStickX The x component of the left joystick
  12001. * @param leftStickY The y component of the left joystick
  12002. * @param rightStickX The x component of the right joystick
  12003. * @param rightStickY The y component of the right joystick
  12004. */
  12005. constructor(
  12006. /**
  12007. * The id of the gamepad
  12008. */
  12009. id: string,
  12010. /**
  12011. * The index of the gamepad
  12012. */
  12013. index: number,
  12014. /**
  12015. * The browser gamepad
  12016. */
  12017. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12018. /**
  12019. * Callback triggered when the left joystick has changed
  12020. * @param callback
  12021. */
  12022. onleftstickchanged(callback: (values: StickValues) => void): void;
  12023. /**
  12024. * Callback triggered when the right joystick has changed
  12025. * @param callback
  12026. */
  12027. onrightstickchanged(callback: (values: StickValues) => void): void;
  12028. /**
  12029. * Gets the left joystick
  12030. */
  12031. /**
  12032. * Sets the left joystick values
  12033. */
  12034. leftStick: StickValues;
  12035. /**
  12036. * Gets the right joystick
  12037. */
  12038. /**
  12039. * Sets the right joystick value
  12040. */
  12041. rightStick: StickValues;
  12042. /**
  12043. * Updates the gamepad joystick positions
  12044. */
  12045. update(): void;
  12046. /**
  12047. * Disposes the gamepad
  12048. */
  12049. dispose(): void;
  12050. }
  12051. /**
  12052. * Represents a generic gamepad
  12053. */
  12054. export class GenericPad extends Gamepad {
  12055. private _buttons;
  12056. private _onbuttondown;
  12057. private _onbuttonup;
  12058. /**
  12059. * Observable triggered when a button has been pressed
  12060. */
  12061. onButtonDownObservable: Observable<number>;
  12062. /**
  12063. * Observable triggered when a button has been released
  12064. */
  12065. onButtonUpObservable: Observable<number>;
  12066. /**
  12067. * Callback triggered when a button has been pressed
  12068. * @param callback Called when a button has been pressed
  12069. */
  12070. onbuttondown(callback: (buttonPressed: number) => void): void;
  12071. /**
  12072. * Callback triggered when a button has been released
  12073. * @param callback Called when a button has been released
  12074. */
  12075. onbuttonup(callback: (buttonReleased: number) => void): void;
  12076. /**
  12077. * Initializes the generic gamepad
  12078. * @param id The id of the generic gamepad
  12079. * @param index The index of the generic gamepad
  12080. * @param browserGamepad The browser gamepad
  12081. */
  12082. constructor(id: string, index: number, browserGamepad: any);
  12083. private _setButtonValue;
  12084. /**
  12085. * Updates the generic gamepad
  12086. */
  12087. update(): void;
  12088. /**
  12089. * Disposes the generic gamepad
  12090. */
  12091. dispose(): void;
  12092. }
  12093. }
  12094. declare module BABYLON {
  12095. /**
  12096. * 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.
  12097. * @see https://doc.babylonjs.com/how_to/transformnode
  12098. */
  12099. export class TransformNode extends Node {
  12100. /**
  12101. * Object will not rotate to face the camera
  12102. */
  12103. static BILLBOARDMODE_NONE: number;
  12104. /**
  12105. * Object will rotate to face the camera but only on the x axis
  12106. */
  12107. static BILLBOARDMODE_X: number;
  12108. /**
  12109. * Object will rotate to face the camera but only on the y axis
  12110. */
  12111. static BILLBOARDMODE_Y: number;
  12112. /**
  12113. * Object will rotate to face the camera but only on the z axis
  12114. */
  12115. static BILLBOARDMODE_Z: number;
  12116. /**
  12117. * Object will rotate to face the camera
  12118. */
  12119. static BILLBOARDMODE_ALL: number;
  12120. private _forward;
  12121. private _forwardInverted;
  12122. private _up;
  12123. private _right;
  12124. private _rightInverted;
  12125. private _position;
  12126. private _rotation;
  12127. private _rotationQuaternion;
  12128. protected _scaling: Vector3;
  12129. protected _isDirty: boolean;
  12130. private _transformToBoneReferal;
  12131. /**
  12132. * Set the billboard mode. Default is 0.
  12133. *
  12134. * | Value | Type | Description |
  12135. * | --- | --- | --- |
  12136. * | 0 | BILLBOARDMODE_NONE | |
  12137. * | 1 | BILLBOARDMODE_X | |
  12138. * | 2 | BILLBOARDMODE_Y | |
  12139. * | 4 | BILLBOARDMODE_Z | |
  12140. * | 7 | BILLBOARDMODE_ALL | |
  12141. *
  12142. */
  12143. billboardMode: number;
  12144. /**
  12145. * 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
  12146. */
  12147. scalingDeterminant: number;
  12148. /**
  12149. * Sets the distance of the object to max, often used by skybox
  12150. */
  12151. infiniteDistance: boolean;
  12152. /**
  12153. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  12154. * By default the system will update normals to compensate
  12155. */
  12156. ignoreNonUniformScaling: boolean;
  12157. /** @hidden */ poseMatrix: Matrix;
  12158. /** @hidden */ localMatrix: Matrix;
  12159. private _absolutePosition;
  12160. private _pivotMatrix;
  12161. private _pivotMatrixInverse;
  12162. protected _postMultiplyPivotMatrix: boolean;
  12163. protected _isWorldMatrixFrozen: boolean;
  12164. /** @hidden */ indexInSceneTransformNodesArray: number;
  12165. /**
  12166. * An event triggered after the world matrix is updated
  12167. */
  12168. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  12169. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  12170. /**
  12171. * Gets a string identifying the name of the class
  12172. * @returns "TransformNode" string
  12173. */
  12174. getClassName(): string;
  12175. /**
  12176. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  12177. */
  12178. position: Vector3;
  12179. /**
  12180. * 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)).
  12181. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  12182. */
  12183. rotation: Vector3;
  12184. /**
  12185. * 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)).
  12186. */
  12187. scaling: Vector3;
  12188. /**
  12189. * 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).
  12190. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  12191. */
  12192. rotationQuaternion: Nullable<Quaternion>;
  12193. /**
  12194. * The forward direction of that transform in world space.
  12195. */
  12196. readonly forward: Vector3;
  12197. /**
  12198. * The up direction of that transform in world space.
  12199. */
  12200. readonly up: Vector3;
  12201. /**
  12202. * The right direction of that transform in world space.
  12203. */
  12204. readonly right: Vector3;
  12205. /**
  12206. * Copies the parameter passed Matrix into the mesh Pose matrix.
  12207. * @param matrix the matrix to copy the pose from
  12208. * @returns this TransformNode.
  12209. */
  12210. updatePoseMatrix(matrix: Matrix): TransformNode;
  12211. /**
  12212. * Returns the mesh Pose matrix.
  12213. * @returns the pose matrix
  12214. */
  12215. getPoseMatrix(): Matrix;
  12216. /** @hidden */ isSynchronized(): boolean;
  12217. /** @hidden */ initCache(): void;
  12218. /**
  12219. * Flag the transform node as dirty (Forcing it to update everything)
  12220. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  12221. * @returns this transform node
  12222. */
  12223. markAsDirty(property: string): TransformNode;
  12224. /**
  12225. * Returns the current mesh absolute position.
  12226. * Returns a Vector3.
  12227. */
  12228. readonly absolutePosition: Vector3;
  12229. /**
  12230. * Sets a new matrix to apply before all other transformation
  12231. * @param matrix defines the transform matrix
  12232. * @returns the current TransformNode
  12233. */
  12234. setPreTransformMatrix(matrix: Matrix): TransformNode;
  12235. /**
  12236. * Sets a new pivot matrix to the current node
  12237. * @param matrix defines the new pivot matrix to use
  12238. * @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
  12239. * @returns the current TransformNode
  12240. */
  12241. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  12242. /**
  12243. * Returns the mesh pivot matrix.
  12244. * Default : Identity.
  12245. * @returns the matrix
  12246. */
  12247. getPivotMatrix(): Matrix;
  12248. /**
  12249. * Prevents the World matrix to be computed any longer.
  12250. * @returns the TransformNode.
  12251. */
  12252. freezeWorldMatrix(): TransformNode;
  12253. /**
  12254. * Allows back the World matrix computation.
  12255. * @returns the TransformNode.
  12256. */
  12257. unfreezeWorldMatrix(): this;
  12258. /**
  12259. * True if the World matrix has been frozen.
  12260. */
  12261. readonly isWorldMatrixFrozen: boolean;
  12262. /**
  12263. * Retuns the mesh absolute position in the World.
  12264. * @returns a Vector3.
  12265. */
  12266. getAbsolutePosition(): Vector3;
  12267. /**
  12268. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  12269. * @param absolutePosition the absolute position to set
  12270. * @returns the TransformNode.
  12271. */
  12272. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  12273. /**
  12274. * Sets the mesh position in its local space.
  12275. * @param vector3 the position to set in localspace
  12276. * @returns the TransformNode.
  12277. */
  12278. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  12279. /**
  12280. * Returns the mesh position in the local space from the current World matrix values.
  12281. * @returns a new Vector3.
  12282. */
  12283. getPositionExpressedInLocalSpace(): Vector3;
  12284. /**
  12285. * Translates the mesh along the passed Vector3 in its local space.
  12286. * @param vector3 the distance to translate in localspace
  12287. * @returns the TransformNode.
  12288. */
  12289. locallyTranslate(vector3: Vector3): TransformNode;
  12290. private static _lookAtVectorCache;
  12291. /**
  12292. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  12293. * @param targetPoint the position (must be in same space as current mesh) to look at
  12294. * @param yawCor optional yaw (y-axis) correction in radians
  12295. * @param pitchCor optional pitch (x-axis) correction in radians
  12296. * @param rollCor optional roll (z-axis) correction in radians
  12297. * @param space the choosen space of the target
  12298. * @returns the TransformNode.
  12299. */
  12300. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  12301. /**
  12302. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12303. * This Vector3 is expressed in the World space.
  12304. * @param localAxis axis to rotate
  12305. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12306. */
  12307. getDirection(localAxis: Vector3): Vector3;
  12308. /**
  12309. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  12310. * localAxis is expressed in the mesh local space.
  12311. * result is computed in the Wordl space from the mesh World matrix.
  12312. * @param localAxis axis to rotate
  12313. * @param result the resulting transformnode
  12314. * @returns this TransformNode.
  12315. */
  12316. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  12317. /**
  12318. * Sets this transform node rotation to the given local axis.
  12319. * @param localAxis the axis in local space
  12320. * @param yawCor optional yaw (y-axis) correction in radians
  12321. * @param pitchCor optional pitch (x-axis) correction in radians
  12322. * @param rollCor optional roll (z-axis) correction in radians
  12323. * @returns this TransformNode
  12324. */
  12325. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  12326. /**
  12327. * Sets a new pivot point to the current node
  12328. * @param point defines the new pivot point to use
  12329. * @param space defines if the point is in world or local space (local by default)
  12330. * @returns the current TransformNode
  12331. */
  12332. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  12333. /**
  12334. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  12335. * @returns the pivot point
  12336. */
  12337. getPivotPoint(): Vector3;
  12338. /**
  12339. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  12340. * @param result the vector3 to store the result
  12341. * @returns this TransformNode.
  12342. */
  12343. getPivotPointToRef(result: Vector3): TransformNode;
  12344. /**
  12345. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  12346. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  12347. */
  12348. getAbsolutePivotPoint(): Vector3;
  12349. /**
  12350. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  12351. * @param result vector3 to store the result
  12352. * @returns this TransformNode.
  12353. */
  12354. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  12355. /**
  12356. * Defines the passed node as the parent of the current node.
  12357. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  12358. * @param node the node ot set as the parent
  12359. * @returns this TransformNode.
  12360. */
  12361. setParent(node: Nullable<Node>): TransformNode;
  12362. private _nonUniformScaling;
  12363. /**
  12364. * True if the scaling property of this object is non uniform eg. (1,2,1)
  12365. */
  12366. readonly nonUniformScaling: boolean;
  12367. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  12368. /**
  12369. * Attach the current TransformNode to another TransformNode associated with a bone
  12370. * @param bone Bone affecting the TransformNode
  12371. * @param affectedTransformNode TransformNode associated with the bone
  12372. * @returns this object
  12373. */
  12374. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  12375. /**
  12376. * Detach the transform node if its associated with a bone
  12377. * @returns this object
  12378. */
  12379. detachFromBone(): TransformNode;
  12380. private static _rotationAxisCache;
  12381. /**
  12382. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  12383. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  12384. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12385. * The passed axis is also normalized.
  12386. * @param axis the axis to rotate around
  12387. * @param amount the amount to rotate in radians
  12388. * @param space Space to rotate in (Default: local)
  12389. * @returns the TransformNode.
  12390. */
  12391. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  12392. /**
  12393. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  12394. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12395. * The passed axis is also normalized. .
  12396. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  12397. * @param point the point to rotate around
  12398. * @param axis the axis to rotate around
  12399. * @param amount the amount to rotate in radians
  12400. * @returns the TransformNode
  12401. */
  12402. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  12403. /**
  12404. * Translates the mesh along the axis vector for the passed distance in the given space.
  12405. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  12406. * @param axis the axis to translate in
  12407. * @param distance the distance to translate
  12408. * @param space Space to rotate in (Default: local)
  12409. * @returns the TransformNode.
  12410. */
  12411. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  12412. /**
  12413. * Adds a rotation step to the mesh current rotation.
  12414. * x, y, z are Euler angles expressed in radians.
  12415. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  12416. * This means this rotation is made in the mesh local space only.
  12417. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  12418. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  12419. * ```javascript
  12420. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  12421. * ```
  12422. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  12423. * 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.
  12424. * @param x Rotation to add
  12425. * @param y Rotation to add
  12426. * @param z Rotation to add
  12427. * @returns the TransformNode.
  12428. */
  12429. addRotation(x: number, y: number, z: number): TransformNode;
  12430. /**
  12431. * Computes the world matrix of the node
  12432. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12433. * @returns the world matrix
  12434. */
  12435. computeWorldMatrix(force?: boolean): Matrix;
  12436. protected _afterComputeWorldMatrix(): void;
  12437. /**
  12438. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  12439. * @param func callback function to add
  12440. *
  12441. * @returns the TransformNode.
  12442. */
  12443. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12444. /**
  12445. * Removes a registered callback function.
  12446. * @param func callback function to remove
  12447. * @returns the TransformNode.
  12448. */
  12449. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12450. /**
  12451. * Gets the position of the current mesh in camera space
  12452. * @param camera defines the camera to use
  12453. * @returns a position
  12454. */
  12455. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  12456. /**
  12457. * Returns the distance from the mesh to the active camera
  12458. * @param camera defines the camera to use
  12459. * @returns the distance
  12460. */
  12461. getDistanceToCamera(camera?: Nullable<Camera>): number;
  12462. /**
  12463. * Clone the current transform node
  12464. * @param name Name of the new clone
  12465. * @param newParent New parent for the clone
  12466. * @param doNotCloneChildren Do not clone children hierarchy
  12467. * @returns the new transform node
  12468. */
  12469. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  12470. /**
  12471. * Serializes the objects information.
  12472. * @param currentSerializationObject defines the object to serialize in
  12473. * @returns the serialized object
  12474. */
  12475. serialize(currentSerializationObject?: any): any;
  12476. /**
  12477. * Returns a new TransformNode object parsed from the source provided.
  12478. * @param parsedTransformNode is the source.
  12479. * @param scene the scne the object belongs to
  12480. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  12481. * @returns a new TransformNode object parsed from the source provided.
  12482. */
  12483. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  12484. /**
  12485. * Get all child-transformNodes of this node
  12486. * @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
  12487. * @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
  12488. * @returns an array of TransformNode
  12489. */
  12490. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  12491. /**
  12492. * Releases resources associated with this transform node.
  12493. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12494. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12495. */
  12496. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12497. }
  12498. }
  12499. declare module BABYLON {
  12500. /**
  12501. * Defines the types of pose enabled controllers that are supported
  12502. */
  12503. export enum PoseEnabledControllerType {
  12504. /**
  12505. * HTC Vive
  12506. */
  12507. VIVE = 0,
  12508. /**
  12509. * Oculus Rift
  12510. */
  12511. OCULUS = 1,
  12512. /**
  12513. * Windows mixed reality
  12514. */
  12515. WINDOWS = 2,
  12516. /**
  12517. * Samsung gear VR
  12518. */
  12519. GEAR_VR = 3,
  12520. /**
  12521. * Google Daydream
  12522. */
  12523. DAYDREAM = 4,
  12524. /**
  12525. * Generic
  12526. */
  12527. GENERIC = 5
  12528. }
  12529. /**
  12530. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12531. */
  12532. export interface MutableGamepadButton {
  12533. /**
  12534. * Value of the button/trigger
  12535. */
  12536. value: number;
  12537. /**
  12538. * If the button/trigger is currently touched
  12539. */
  12540. touched: boolean;
  12541. /**
  12542. * If the button/trigger is currently pressed
  12543. */
  12544. pressed: boolean;
  12545. }
  12546. /**
  12547. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12548. * @hidden
  12549. */
  12550. export interface ExtendedGamepadButton extends GamepadButton {
  12551. /**
  12552. * If the button/trigger is currently pressed
  12553. */
  12554. readonly pressed: boolean;
  12555. /**
  12556. * If the button/trigger is currently touched
  12557. */
  12558. readonly touched: boolean;
  12559. /**
  12560. * Value of the button/trigger
  12561. */
  12562. readonly value: number;
  12563. }
  12564. /** @hidden */
  12565. export interface _GamePadFactory {
  12566. /**
  12567. * Returns wether or not the current gamepad can be created for this type of controller.
  12568. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12569. * @returns true if it can be created, otherwise false
  12570. */
  12571. canCreate(gamepadInfo: any): boolean;
  12572. /**
  12573. * Creates a new instance of the Gamepad.
  12574. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12575. * @returns the new gamepad instance
  12576. */
  12577. create(gamepadInfo: any): Gamepad;
  12578. }
  12579. /**
  12580. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12581. */
  12582. export class PoseEnabledControllerHelper {
  12583. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12584. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12585. /**
  12586. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12587. * @param vrGamepad the gamepad to initialized
  12588. * @returns a vr controller of the type the gamepad identified as
  12589. */
  12590. static InitiateController(vrGamepad: any): Gamepad;
  12591. }
  12592. /**
  12593. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12594. */
  12595. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12596. private _deviceRoomPosition;
  12597. private _deviceRoomRotationQuaternion;
  12598. /**
  12599. * The device position in babylon space
  12600. */
  12601. devicePosition: Vector3;
  12602. /**
  12603. * The device rotation in babylon space
  12604. */
  12605. deviceRotationQuaternion: Quaternion;
  12606. /**
  12607. * The scale factor of the device in babylon space
  12608. */
  12609. deviceScaleFactor: number;
  12610. /**
  12611. * (Likely devicePosition should be used instead) The device position in its room space
  12612. */
  12613. position: Vector3;
  12614. /**
  12615. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12616. */
  12617. rotationQuaternion: Quaternion;
  12618. /**
  12619. * The type of controller (Eg. Windows mixed reality)
  12620. */
  12621. controllerType: PoseEnabledControllerType;
  12622. protected _calculatedPosition: Vector3;
  12623. private _calculatedRotation;
  12624. /**
  12625. * The raw pose from the device
  12626. */
  12627. rawPose: DevicePose;
  12628. private _trackPosition;
  12629. private _maxRotationDistFromHeadset;
  12630. private _draggedRoomRotation;
  12631. /**
  12632. * @hidden
  12633. */ disableTrackPosition(fixedPosition: Vector3): void;
  12634. /**
  12635. * Internal, the mesh attached to the controller
  12636. * @hidden
  12637. */ mesh: Nullable<AbstractMesh>;
  12638. private _poseControlledCamera;
  12639. private _leftHandSystemQuaternion;
  12640. /**
  12641. * Internal, matrix used to convert room space to babylon space
  12642. * @hidden
  12643. */ deviceToWorld: Matrix;
  12644. /**
  12645. * Node to be used when casting a ray from the controller
  12646. * @hidden
  12647. */ pointingPoseNode: Nullable<TransformNode>;
  12648. /**
  12649. * Name of the child mesh that can be used to cast a ray from the controller
  12650. */
  12651. static readonly POINTING_POSE: string;
  12652. /**
  12653. * Creates a new PoseEnabledController from a gamepad
  12654. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12655. */
  12656. constructor(browserGamepad: any);
  12657. private _workingMatrix;
  12658. /**
  12659. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12660. */
  12661. update(): void;
  12662. /**
  12663. * Updates only the pose device and mesh without doing any button event checking
  12664. */
  12665. protected _updatePoseAndMesh(): void;
  12666. /**
  12667. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12668. * @param poseData raw pose fromthe device
  12669. */
  12670. updateFromDevice(poseData: DevicePose): void;
  12671. /**
  12672. * @hidden
  12673. */ meshAttachedObservable: Observable<AbstractMesh>;
  12674. /**
  12675. * Attaches a mesh to the controller
  12676. * @param mesh the mesh to be attached
  12677. */
  12678. attachToMesh(mesh: AbstractMesh): void;
  12679. /**
  12680. * Attaches the controllers mesh to a camera
  12681. * @param camera the camera the mesh should be attached to
  12682. */
  12683. attachToPoseControlledCamera(camera: TargetCamera): void;
  12684. /**
  12685. * Disposes of the controller
  12686. */
  12687. dispose(): void;
  12688. /**
  12689. * The mesh that is attached to the controller
  12690. */
  12691. readonly mesh: Nullable<AbstractMesh>;
  12692. /**
  12693. * Gets the ray of the controller in the direction the controller is pointing
  12694. * @param length the length the resulting ray should be
  12695. * @returns a ray in the direction the controller is pointing
  12696. */
  12697. getForwardRay(length?: number): Ray;
  12698. }
  12699. }
  12700. declare module BABYLON {
  12701. /**
  12702. * Defines the WebVRController object that represents controllers tracked in 3D space
  12703. */
  12704. export abstract class WebVRController extends PoseEnabledController {
  12705. /**
  12706. * Internal, the default controller model for the controller
  12707. */
  12708. protected _defaultModel: AbstractMesh;
  12709. /**
  12710. * Fired when the trigger state has changed
  12711. */
  12712. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12713. /**
  12714. * Fired when the main button state has changed
  12715. */
  12716. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12717. /**
  12718. * Fired when the secondary button state has changed
  12719. */
  12720. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12721. /**
  12722. * Fired when the pad state has changed
  12723. */
  12724. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12725. /**
  12726. * Fired when controllers stick values have changed
  12727. */
  12728. onPadValuesChangedObservable: Observable<StickValues>;
  12729. /**
  12730. * Array of button availible on the controller
  12731. */
  12732. protected _buttons: Array<MutableGamepadButton>;
  12733. private _onButtonStateChange;
  12734. /**
  12735. * Fired when a controller button's state has changed
  12736. * @param callback the callback containing the button that was modified
  12737. */
  12738. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12739. /**
  12740. * X and Y axis corrisponding to the controllers joystick
  12741. */
  12742. pad: StickValues;
  12743. /**
  12744. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12745. */
  12746. hand: string;
  12747. /**
  12748. * The default controller model for the controller
  12749. */
  12750. readonly defaultModel: AbstractMesh;
  12751. /**
  12752. * Creates a new WebVRController from a gamepad
  12753. * @param vrGamepad the gamepad that the WebVRController should be created from
  12754. */
  12755. constructor(vrGamepad: any);
  12756. /**
  12757. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12758. */
  12759. update(): void;
  12760. /**
  12761. * Function to be called when a button is modified
  12762. */
  12763. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12764. /**
  12765. * Loads a mesh and attaches it to the controller
  12766. * @param scene the scene the mesh should be added to
  12767. * @param meshLoaded callback for when the mesh has been loaded
  12768. */
  12769. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12770. private _setButtonValue;
  12771. private _changes;
  12772. private _checkChanges;
  12773. /**
  12774. * Disposes of th webVRCOntroller
  12775. */
  12776. dispose(): void;
  12777. }
  12778. }
  12779. declare module BABYLON {
  12780. /**
  12781. * The HemisphericLight simulates the ambient environment light,
  12782. * so the passed direction is the light reflection direction, not the incoming direction.
  12783. */
  12784. export class HemisphericLight extends Light {
  12785. /**
  12786. * The groundColor is the light in the opposite direction to the one specified during creation.
  12787. * 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.
  12788. */
  12789. groundColor: Color3;
  12790. /**
  12791. * The light reflection direction, not the incoming direction.
  12792. */
  12793. direction: Vector3;
  12794. /**
  12795. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12796. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12797. * The HemisphericLight can't cast shadows.
  12798. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12799. * @param name The friendly name of the light
  12800. * @param direction The direction of the light reflection
  12801. * @param scene The scene the light belongs to
  12802. */
  12803. constructor(name: string, direction: Vector3, scene: Scene);
  12804. protected _buildUniformLayout(): void;
  12805. /**
  12806. * Returns the string "HemisphericLight".
  12807. * @return The class name
  12808. */
  12809. getClassName(): string;
  12810. /**
  12811. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12812. * Returns the updated direction.
  12813. * @param target The target the direction should point to
  12814. * @return The computed direction
  12815. */
  12816. setDirectionToTarget(target: Vector3): Vector3;
  12817. /**
  12818. * Returns the shadow generator associated to the light.
  12819. * @returns Always null for hemispheric lights because it does not support shadows.
  12820. */
  12821. getShadowGenerator(): Nullable<IShadowGenerator>;
  12822. /**
  12823. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12824. * @param effect The effect to update
  12825. * @param lightIndex The index of the light in the effect to update
  12826. * @returns The hemispheric light
  12827. */
  12828. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12829. /**
  12830. * Computes the world matrix of the node
  12831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12832. * @param useWasUpdatedFlag defines a reserved property
  12833. * @returns the world matrix
  12834. */
  12835. computeWorldMatrix(): Matrix;
  12836. /**
  12837. * Returns the integer 3.
  12838. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12839. */
  12840. getTypeID(): number;
  12841. /**
  12842. * Prepares the list of defines specific to the light type.
  12843. * @param defines the list of defines
  12844. * @param lightIndex defines the index of the light for the effect
  12845. */
  12846. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12847. }
  12848. }
  12849. declare module BABYLON {
  12850. /**
  12851. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12852. * IMPORTANT!! The data is right-hand data.
  12853. * @export
  12854. * @interface DevicePose
  12855. */
  12856. export interface DevicePose {
  12857. /**
  12858. * The position of the device, values in array are [x,y,z].
  12859. */
  12860. readonly position: Nullable<Float32Array>;
  12861. /**
  12862. * The linearVelocity of the device, values in array are [x,y,z].
  12863. */
  12864. readonly linearVelocity: Nullable<Float32Array>;
  12865. /**
  12866. * The linearAcceleration of the device, values in array are [x,y,z].
  12867. */
  12868. readonly linearAcceleration: Nullable<Float32Array>;
  12869. /**
  12870. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12871. */
  12872. readonly orientation: Nullable<Float32Array>;
  12873. /**
  12874. * The angularVelocity of the device, values in array are [x,y,z].
  12875. */
  12876. readonly angularVelocity: Nullable<Float32Array>;
  12877. /**
  12878. * The angularAcceleration of the device, values in array are [x,y,z].
  12879. */
  12880. readonly angularAcceleration: Nullable<Float32Array>;
  12881. }
  12882. /**
  12883. * Interface representing a pose controlled object in Babylon.
  12884. * A pose controlled object has both regular pose values as well as pose values
  12885. * from an external device such as a VR head mounted display
  12886. */
  12887. export interface PoseControlled {
  12888. /**
  12889. * The position of the object in babylon space.
  12890. */
  12891. position: Vector3;
  12892. /**
  12893. * The rotation quaternion of the object in babylon space.
  12894. */
  12895. rotationQuaternion: Quaternion;
  12896. /**
  12897. * The position of the device in babylon space.
  12898. */
  12899. devicePosition?: Vector3;
  12900. /**
  12901. * The rotation quaternion of the device in babylon space.
  12902. */
  12903. deviceRotationQuaternion: Quaternion;
  12904. /**
  12905. * The raw pose coming from the device.
  12906. */
  12907. rawPose: Nullable<DevicePose>;
  12908. /**
  12909. * The scale of the device to be used when translating from device space to babylon space.
  12910. */
  12911. deviceScaleFactor: number;
  12912. /**
  12913. * Updates the poseControlled values based on the input device pose.
  12914. * @param poseData the pose data to update the object with
  12915. */
  12916. updateFromDevice(poseData: DevicePose): void;
  12917. }
  12918. /**
  12919. * Set of options to customize the webVRCamera
  12920. */
  12921. export interface WebVROptions {
  12922. /**
  12923. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  12924. */
  12925. trackPosition?: boolean;
  12926. /**
  12927. * Sets the scale of the vrDevice in babylon space. (default: 1)
  12928. */
  12929. positionScale?: number;
  12930. /**
  12931. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  12932. */
  12933. displayName?: string;
  12934. /**
  12935. * Should the native controller meshes be initialized. (default: true)
  12936. */
  12937. controllerMeshes?: boolean;
  12938. /**
  12939. * Creating a default HemiLight only on controllers. (default: true)
  12940. */
  12941. defaultLightingOnControllers?: boolean;
  12942. /**
  12943. * If you don't want to use the default VR button of the helper. (default: false)
  12944. */
  12945. useCustomVRButton?: boolean;
  12946. /**
  12947. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  12948. */
  12949. customVRButton?: HTMLButtonElement;
  12950. /**
  12951. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  12952. */
  12953. rayLength?: number;
  12954. /**
  12955. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  12956. */
  12957. defaultHeight?: number;
  12958. }
  12959. /**
  12960. * This represents a WebVR camera.
  12961. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  12962. * @example http://doc.babylonjs.com/how_to/webvr_camera
  12963. */
  12964. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  12965. private webVROptions;
  12966. /**
  12967. * @hidden
  12968. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  12969. */ vrDevice: any;
  12970. /**
  12971. * The rawPose of the vrDevice.
  12972. */
  12973. rawPose: Nullable<DevicePose>;
  12974. private _onVREnabled;
  12975. private _specsVersion;
  12976. private _attached;
  12977. private _frameData;
  12978. protected _descendants: Array<Node>;
  12979. private _deviceRoomPosition;
  12980. /** @hidden */ deviceRoomRotationQuaternion: Quaternion;
  12981. private _standingMatrix;
  12982. /**
  12983. * Represents device position in babylon space.
  12984. */
  12985. devicePosition: Vector3;
  12986. /**
  12987. * Represents device rotation in babylon space.
  12988. */
  12989. deviceRotationQuaternion: Quaternion;
  12990. /**
  12991. * The scale of the device to be used when translating from device space to babylon space.
  12992. */
  12993. deviceScaleFactor: number;
  12994. private _deviceToWorld;
  12995. private _worldToDevice;
  12996. /**
  12997. * References to the webVR controllers for the vrDevice.
  12998. */
  12999. controllers: Array<WebVRController>;
  13000. /**
  13001. * Emits an event when a controller is attached.
  13002. */
  13003. onControllersAttachedObservable: Observable<WebVRController[]>;
  13004. /**
  13005. * Emits an event when a controller's mesh has been loaded;
  13006. */
  13007. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13008. /**
  13009. * Emits an event when the HMD's pose has been updated.
  13010. */
  13011. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13012. private _poseSet;
  13013. /**
  13014. * If the rig cameras be used as parent instead of this camera.
  13015. */
  13016. rigParenting: boolean;
  13017. private _lightOnControllers;
  13018. private _defaultHeight?;
  13019. /**
  13020. * Instantiates a WebVRFreeCamera.
  13021. * @param name The name of the WebVRFreeCamera
  13022. * @param position The starting anchor position for the camera
  13023. * @param scene The scene the camera belongs to
  13024. * @param webVROptions a set of customizable options for the webVRCamera
  13025. */
  13026. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13027. /**
  13028. * Gets the device distance from the ground in meters.
  13029. * @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.
  13030. */
  13031. deviceDistanceToRoomGround(): number;
  13032. /**
  13033. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13034. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13035. */
  13036. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13037. /**
  13038. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13039. * @returns A promise with a boolean set to if the standing matrix is supported.
  13040. */
  13041. useStandingMatrixAsync(): Promise<boolean>;
  13042. /**
  13043. * Disposes the camera
  13044. */
  13045. dispose(): void;
  13046. /**
  13047. * Gets a vrController by name.
  13048. * @param name The name of the controller to retreive
  13049. * @returns the controller matching the name specified or null if not found
  13050. */
  13051. getControllerByName(name: string): Nullable<WebVRController>;
  13052. private _leftController;
  13053. /**
  13054. * The controller corrisponding to the users left hand.
  13055. */
  13056. readonly leftController: Nullable<WebVRController>;
  13057. private _rightController;
  13058. /**
  13059. * The controller corrisponding to the users right hand.
  13060. */
  13061. readonly rightController: Nullable<WebVRController>;
  13062. /**
  13063. * Casts a ray forward from the vrCamera's gaze.
  13064. * @param length Length of the ray (default: 100)
  13065. * @returns the ray corrisponding to the gaze
  13066. */
  13067. getForwardRay(length?: number): Ray;
  13068. /**
  13069. * @hidden
  13070. * Updates the camera based on device's frame data
  13071. */ checkInputs(): void;
  13072. /**
  13073. * Updates the poseControlled values based on the input device pose.
  13074. * @param poseData Pose coming from the device
  13075. */
  13076. updateFromDevice(poseData: DevicePose): void;
  13077. private _htmlElementAttached;
  13078. private _detachIfAttached;
  13079. /**
  13080. * WebVR's attach control will start broadcasting frames to the device.
  13081. * Note that in certain browsers (chrome for example) this function must be called
  13082. * within a user-interaction callback. Example:
  13083. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13084. *
  13085. * @param element html element to attach the vrDevice to
  13086. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13087. */
  13088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13089. /**
  13090. * Detaches the camera from the html element and disables VR
  13091. *
  13092. * @param element html element to detach from
  13093. */
  13094. detachControl(element: HTMLElement): void;
  13095. /**
  13096. * @returns the name of this class
  13097. */
  13098. getClassName(): string;
  13099. /**
  13100. * Calls resetPose on the vrDisplay
  13101. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13102. */
  13103. resetToCurrentRotation(): void;
  13104. /**
  13105. * @hidden
  13106. * Updates the rig cameras (left and right eye)
  13107. */ updateRigCameras(): void;
  13108. private _workingVector;
  13109. private _oneVector;
  13110. private _workingMatrix;
  13111. private updateCacheCalled;
  13112. private _correctPositionIfNotTrackPosition;
  13113. /**
  13114. * @hidden
  13115. * Updates the cached values of the camera
  13116. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13117. */ updateCache(ignoreParentClass?: boolean): void;
  13118. /**
  13119. * @hidden
  13120. * Get current device position in babylon world
  13121. */ computeDevicePosition(): void;
  13122. /**
  13123. * Updates the current device position and rotation in the babylon world
  13124. */
  13125. update(): void;
  13126. /**
  13127. * @hidden
  13128. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13129. * @returns an identity matrix
  13130. */ getViewMatrix(): Matrix;
  13131. private _tmpMatrix;
  13132. /**
  13133. * This function is called by the two RIG cameras.
  13134. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13135. * @hidden
  13136. */ getWebVRViewMatrix(): Matrix;
  13137. /** @hidden */ getWebVRProjectionMatrix(): Matrix;
  13138. private _onGamepadConnectedObserver;
  13139. private _onGamepadDisconnectedObserver;
  13140. private _updateCacheWhenTrackingDisabledObserver;
  13141. /**
  13142. * Initializes the controllers and their meshes
  13143. */
  13144. initControllers(): void;
  13145. }
  13146. }
  13147. declare module BABYLON {
  13148. /**
  13149. * Size options for a post process
  13150. */
  13151. export type PostProcessOptions = {
  13152. width: number;
  13153. height: number;
  13154. };
  13155. /**
  13156. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13157. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13158. */
  13159. export class PostProcess {
  13160. /** Name of the PostProcess. */
  13161. name: string;
  13162. /**
  13163. * Width of the texture to apply the post process on
  13164. */
  13165. width: number;
  13166. /**
  13167. * Height of the texture to apply the post process on
  13168. */
  13169. height: number;
  13170. /**
  13171. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13172. * @hidden
  13173. */ outputTexture: Nullable<InternalTexture>;
  13174. /**
  13175. * Sampling mode used by the shader
  13176. * See https://doc.babylonjs.com/classes/3.1/texture
  13177. */
  13178. renderTargetSamplingMode: number;
  13179. /**
  13180. * Clear color to use when screen clearing
  13181. */
  13182. clearColor: Color4;
  13183. /**
  13184. * If the buffer needs to be cleared before applying the post process. (default: true)
  13185. * Should be set to false if shader will overwrite all previous pixels.
  13186. */
  13187. autoClear: boolean;
  13188. /**
  13189. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13190. */
  13191. alphaMode: number;
  13192. /**
  13193. * Sets the setAlphaBlendConstants of the babylon engine
  13194. */
  13195. alphaConstants: Color4;
  13196. /**
  13197. * Animations to be used for the post processing
  13198. */
  13199. animations: Animation[];
  13200. /**
  13201. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13202. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13203. */
  13204. enablePixelPerfectMode: boolean;
  13205. /**
  13206. * Force the postprocess to be applied without taking in account viewport
  13207. */
  13208. forceFullscreenViewport: boolean;
  13209. /**
  13210. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13211. *
  13212. * | Value | Type | Description |
  13213. * | ----- | ----------------------------------- | ----------- |
  13214. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13215. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13216. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13217. *
  13218. */
  13219. scaleMode: number;
  13220. /**
  13221. * Force textures to be a power of two (default: false)
  13222. */
  13223. alwaysForcePOT: boolean;
  13224. private _samples;
  13225. /**
  13226. * Number of sample textures (default: 1)
  13227. */
  13228. samples: number;
  13229. /**
  13230. * Modify the scale of the post process to be the same as the viewport (default: false)
  13231. */
  13232. adaptScaleToCurrentViewport: boolean;
  13233. private _camera;
  13234. private _scene;
  13235. private _engine;
  13236. private _options;
  13237. private _reusable;
  13238. private _textureType;
  13239. /**
  13240. * Smart array of input and output textures for the post process.
  13241. * @hidden
  13242. */ textures: SmartArray<InternalTexture>;
  13243. /**
  13244. * The index in _textures that corresponds to the output texture.
  13245. * @hidden
  13246. */ currentRenderTextureInd: number;
  13247. private _effect;
  13248. private _samplers;
  13249. private _fragmentUrl;
  13250. private _vertexUrl;
  13251. private _parameters;
  13252. private _scaleRatio;
  13253. protected _indexParameters: any;
  13254. private _shareOutputWithPostProcess;
  13255. private _texelSize;
  13256. private _forcedOutputTexture;
  13257. /**
  13258. * Returns the fragment url or shader name used in the post process.
  13259. * @returns the fragment url or name in the shader store.
  13260. */
  13261. getEffectName(): string;
  13262. /**
  13263. * An event triggered when the postprocess is activated.
  13264. */
  13265. onActivateObservable: Observable<Camera>;
  13266. private _onActivateObserver;
  13267. /**
  13268. * A function that is added to the onActivateObservable
  13269. */
  13270. onActivate: Nullable<(camera: Camera) => void>;
  13271. /**
  13272. * An event triggered when the postprocess changes its size.
  13273. */
  13274. onSizeChangedObservable: Observable<PostProcess>;
  13275. private _onSizeChangedObserver;
  13276. /**
  13277. * A function that is added to the onSizeChangedObservable
  13278. */
  13279. onSizeChanged: (postProcess: PostProcess) => void;
  13280. /**
  13281. * An event triggered when the postprocess applies its effect.
  13282. */
  13283. onApplyObservable: Observable<Effect>;
  13284. private _onApplyObserver;
  13285. /**
  13286. * A function that is added to the onApplyObservable
  13287. */
  13288. onApply: (effect: Effect) => void;
  13289. /**
  13290. * An event triggered before rendering the postprocess
  13291. */
  13292. onBeforeRenderObservable: Observable<Effect>;
  13293. private _onBeforeRenderObserver;
  13294. /**
  13295. * A function that is added to the onBeforeRenderObservable
  13296. */
  13297. onBeforeRender: (effect: Effect) => void;
  13298. /**
  13299. * An event triggered after rendering the postprocess
  13300. */
  13301. onAfterRenderObservable: Observable<Effect>;
  13302. private _onAfterRenderObserver;
  13303. /**
  13304. * A function that is added to the onAfterRenderObservable
  13305. */
  13306. onAfterRender: (efect: Effect) => void;
  13307. /**
  13308. * 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
  13309. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13310. */
  13311. inputTexture: InternalTexture;
  13312. /**
  13313. * Gets the camera which post process is applied to.
  13314. * @returns The camera the post process is applied to.
  13315. */
  13316. getCamera(): Camera;
  13317. /**
  13318. * Gets the texel size of the postprocess.
  13319. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13320. */
  13321. readonly texelSize: Vector2;
  13322. /**
  13323. * Creates a new instance PostProcess
  13324. * @param name The name of the PostProcess.
  13325. * @param fragmentUrl The url of the fragment shader to be used.
  13326. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13327. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13328. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13329. * @param camera The camera to apply the render pass to.
  13330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13331. * @param engine The engine which the post process will be applied. (default: current engine)
  13332. * @param reusable If the post process can be reused on the same frame. (default: false)
  13333. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13334. * @param textureType Type of textures used when performing the post process. (default: 0)
  13335. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13336. * @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
  13337. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13338. */
  13339. constructor(
  13340. /** Name of the PostProcess. */
  13341. 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);
  13342. /**
  13343. * Gets the engine which this post process belongs to.
  13344. * @returns The engine the post process was enabled with.
  13345. */
  13346. getEngine(): Engine;
  13347. /**
  13348. * The effect that is created when initializing the post process.
  13349. * @returns The created effect corrisponding the the postprocess.
  13350. */
  13351. getEffect(): Effect;
  13352. /**
  13353. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13354. * @param postProcess The post process to share the output with.
  13355. * @returns This post process.
  13356. */
  13357. shareOutputWith(postProcess: PostProcess): PostProcess;
  13358. /**
  13359. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13360. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13361. */
  13362. useOwnOutput(): void;
  13363. /**
  13364. * Updates the effect with the current post process compile time values and recompiles the shader.
  13365. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13366. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13367. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13368. * @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
  13369. * @param onCompiled Called when the shader has been compiled.
  13370. * @param onError Called if there is an error when compiling a shader.
  13371. */
  13372. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13373. /**
  13374. * The post process is reusable if it can be used multiple times within one frame.
  13375. * @returns If the post process is reusable
  13376. */
  13377. isReusable(): boolean;
  13378. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13379. markTextureDirty(): void;
  13380. /**
  13381. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13382. * 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.
  13383. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13384. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13385. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13386. * @returns The target texture that was bound to be written to.
  13387. */
  13388. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13389. /**
  13390. * If the post process is supported.
  13391. */
  13392. readonly isSupported: boolean;
  13393. /**
  13394. * The aspect ratio of the output texture.
  13395. */
  13396. readonly aspectRatio: number;
  13397. /**
  13398. * Get a value indicating if the post-process is ready to be used
  13399. * @returns true if the post-process is ready (shader is compiled)
  13400. */
  13401. isReady(): boolean;
  13402. /**
  13403. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13404. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13405. */
  13406. apply(): Nullable<Effect>;
  13407. private _disposeTextures;
  13408. /**
  13409. * Disposes the post process.
  13410. * @param camera The camera to dispose the post process on.
  13411. */
  13412. dispose(camera?: Camera): void;
  13413. }
  13414. }
  13415. declare module BABYLON {
  13416. /**
  13417. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13418. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13419. */
  13420. export class PostProcessManager {
  13421. private _scene;
  13422. private _indexBuffer;
  13423. private _vertexBuffers;
  13424. /**
  13425. * Creates a new instance PostProcess
  13426. * @param scene The scene that the post process is associated with.
  13427. */
  13428. constructor(scene: Scene);
  13429. private _prepareBuffers;
  13430. private _buildIndexBuffer;
  13431. /**
  13432. * Rebuilds the vertex buffers of the manager.
  13433. * @hidden
  13434. */ rebuild(): void;
  13435. /**
  13436. * Prepares a frame to be run through a post process.
  13437. * @param sourceTexture The input texture to the post procesess. (default: null)
  13438. * @param postProcesses An array of post processes to be run. (default: null)
  13439. * @returns True if the post processes were able to be run.
  13440. * @hidden
  13441. */ prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13442. /**
  13443. * Manually render a set of post processes to a texture.
  13444. * @param postProcesses An array of post processes to be run.
  13445. * @param targetTexture The target texture to render to.
  13446. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13447. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13448. * @param lodLevel defines which lod of the texture to render to
  13449. */
  13450. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13451. /**
  13452. * Finalize the result of the output of the postprocesses.
  13453. * @param doNotPresent If true the result will not be displayed to the screen.
  13454. * @param targetTexture The target texture to render to.
  13455. * @param faceIndex The index of the face to bind the target texture to.
  13456. * @param postProcesses The array of post processes to render.
  13457. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13458. * @hidden
  13459. */ finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13460. /**
  13461. * Disposes of the post process manager.
  13462. */
  13463. dispose(): void;
  13464. }
  13465. }
  13466. declare module BABYLON {
  13467. /**
  13468. * Raw texture can help creating a texture directly from an array of data.
  13469. * This can be super useful if you either get the data from an uncompressed source or
  13470. * if you wish to create your texture pixel by pixel.
  13471. */
  13472. export class RawTexture extends Texture {
  13473. /**
  13474. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13475. */
  13476. format: number;
  13477. private _engine;
  13478. /**
  13479. * Instantiates a new RawTexture.
  13480. * Raw texture can help creating a texture directly from an array of data.
  13481. * This can be super useful if you either get the data from an uncompressed source or
  13482. * if you wish to create your texture pixel by pixel.
  13483. * @param data define the array of data to use to create the texture
  13484. * @param width define the width of the texture
  13485. * @param height define the height of the texture
  13486. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13487. * @param scene define the scene the texture belongs to
  13488. * @param generateMipMaps define whether mip maps should be generated or not
  13489. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13490. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13491. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13492. */
  13493. constructor(data: ArrayBufferView, width: number, height: number,
  13494. /**
  13495. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13496. */
  13497. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13498. /**
  13499. * Updates the texture underlying data.
  13500. * @param data Define the new data of the texture
  13501. */
  13502. update(data: ArrayBufferView): void;
  13503. /**
  13504. * Creates a luminance texture from some data.
  13505. * @param data Define the texture data
  13506. * @param width Define the width of the texture
  13507. * @param height Define the height of the texture
  13508. * @param scene Define the scene the texture belongs to
  13509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13512. * @returns the luminance texture
  13513. */
  13514. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13515. /**
  13516. * Creates a luminance alpha texture from some data.
  13517. * @param data Define the texture data
  13518. * @param width Define the width of the texture
  13519. * @param height Define the height of the texture
  13520. * @param scene Define the scene the texture belongs to
  13521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13524. * @returns the luminance alpha texture
  13525. */
  13526. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13527. /**
  13528. * Creates an alpha texture from some data.
  13529. * @param data Define the texture data
  13530. * @param width Define the width of the texture
  13531. * @param height Define the height of the texture
  13532. * @param scene Define the scene the texture belongs to
  13533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13536. * @returns the alpha texture
  13537. */
  13538. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13539. /**
  13540. * Creates a RGB texture from some data.
  13541. * @param data Define the texture data
  13542. * @param width Define the width of the texture
  13543. * @param height Define the height of the texture
  13544. * @param scene Define the scene the texture belongs to
  13545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13548. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13549. * @returns the RGB alpha texture
  13550. */
  13551. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13552. /**
  13553. * Creates a RGBA texture from some data.
  13554. * @param data Define the texture data
  13555. * @param width Define the width of the texture
  13556. * @param height Define the height of the texture
  13557. * @param scene Define the scene the texture belongs to
  13558. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13559. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13560. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13561. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13562. * @returns the RGBA texture
  13563. */
  13564. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13565. /**
  13566. * Creates a R texture from some data.
  13567. * @param data Define the texture data
  13568. * @param width Define the width of the texture
  13569. * @param height Define the height of the texture
  13570. * @param scene Define the scene the texture belongs to
  13571. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13572. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13573. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13574. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13575. * @returns the R texture
  13576. */
  13577. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13578. }
  13579. }
  13580. declare module BABYLON {
  13581. interface AbstractScene {
  13582. /**
  13583. * The list of layers (background and foreground) of the scene
  13584. */
  13585. layers: Array<Layer>;
  13586. }
  13587. /**
  13588. * Defines the layer scene component responsible to manage any layers
  13589. * in a given scene.
  13590. */
  13591. export class LayerSceneComponent implements ISceneComponent {
  13592. /**
  13593. * The component name helpfull to identify the component in the list of scene components.
  13594. */
  13595. readonly name: string;
  13596. /**
  13597. * The scene the component belongs to.
  13598. */
  13599. scene: Scene;
  13600. private _engine;
  13601. /**
  13602. * Creates a new instance of the component for the given scene
  13603. * @param scene Defines the scene to register the component in
  13604. */
  13605. constructor(scene: Scene);
  13606. /**
  13607. * Registers the component in a given scene
  13608. */
  13609. register(): void;
  13610. /**
  13611. * Rebuilds the elements related to this component in case of
  13612. * context lost for instance.
  13613. */
  13614. rebuild(): void;
  13615. /**
  13616. * Disposes the component and the associated ressources.
  13617. */
  13618. dispose(): void;
  13619. private _draw;
  13620. private _drawCameraPredicate;
  13621. private _drawCameraBackground;
  13622. private _drawCameraForeground;
  13623. private _drawRenderTargetPredicate;
  13624. private _drawRenderTargetBackground;
  13625. private _drawRenderTargetForeground;
  13626. }
  13627. }
  13628. declare module BABYLON {
  13629. /** @hidden */
  13630. export var layerPixelShader: {
  13631. name: string;
  13632. shader: string;
  13633. };
  13634. }
  13635. declare module BABYLON {
  13636. /** @hidden */
  13637. export var layerVertexShader: {
  13638. name: string;
  13639. shader: string;
  13640. };
  13641. }
  13642. declare module BABYLON {
  13643. /**
  13644. * This represents a full screen 2d layer.
  13645. * This can be useful to display a picture in the background of your scene for instance.
  13646. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13647. */
  13648. export class Layer {
  13649. /**
  13650. * Define the name of the layer.
  13651. */
  13652. name: string;
  13653. /**
  13654. * Define the texture the layer should display.
  13655. */
  13656. texture: Nullable<Texture>;
  13657. /**
  13658. * Is the layer in background or foreground.
  13659. */
  13660. isBackground: boolean;
  13661. /**
  13662. * Define the color of the layer (instead of texture).
  13663. */
  13664. color: Color4;
  13665. /**
  13666. * Define the scale of the layer in order to zoom in out of the texture.
  13667. */
  13668. scale: Vector2;
  13669. /**
  13670. * Define an offset for the layer in order to shift the texture.
  13671. */
  13672. offset: Vector2;
  13673. /**
  13674. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13675. */
  13676. alphaBlendingMode: number;
  13677. /**
  13678. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13679. * Alpha test will not mix with the background color in case of transparency.
  13680. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13681. */
  13682. alphaTest: boolean;
  13683. /**
  13684. * Define a mask to restrict the layer to only some of the scene cameras.
  13685. */
  13686. layerMask: number;
  13687. /**
  13688. * Define the list of render target the layer is visible into.
  13689. */
  13690. renderTargetTextures: RenderTargetTexture[];
  13691. /**
  13692. * Define if the layer is only used in renderTarget or if it also
  13693. * renders in the main frame buffer of the canvas.
  13694. */
  13695. renderOnlyInRenderTargetTextures: boolean;
  13696. private _scene;
  13697. private _vertexBuffers;
  13698. private _indexBuffer;
  13699. private _effect;
  13700. private _alphaTestEffect;
  13701. /**
  13702. * An event triggered when the layer is disposed.
  13703. */
  13704. onDisposeObservable: Observable<Layer>;
  13705. private _onDisposeObserver;
  13706. /**
  13707. * Back compatibility with callback before the onDisposeObservable existed.
  13708. * The set callback will be triggered when the layer has been disposed.
  13709. */
  13710. onDispose: () => void;
  13711. /**
  13712. * An event triggered before rendering the scene
  13713. */
  13714. onBeforeRenderObservable: Observable<Layer>;
  13715. private _onBeforeRenderObserver;
  13716. /**
  13717. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13718. * The set callback will be triggered just before rendering the layer.
  13719. */
  13720. onBeforeRender: () => void;
  13721. /**
  13722. * An event triggered after rendering the scene
  13723. */
  13724. onAfterRenderObservable: Observable<Layer>;
  13725. private _onAfterRenderObserver;
  13726. /**
  13727. * Back compatibility with callback before the onAfterRenderObservable existed.
  13728. * The set callback will be triggered just after rendering the layer.
  13729. */
  13730. onAfterRender: () => void;
  13731. /**
  13732. * Instantiates a new layer.
  13733. * This represents a full screen 2d layer.
  13734. * This can be useful to display a picture in the background of your scene for instance.
  13735. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13736. * @param name Define the name of the layer in the scene
  13737. * @param imgUrl Define the url of the texture to display in the layer
  13738. * @param scene Define the scene the layer belongs to
  13739. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13740. * @param color Defines a color for the layer
  13741. */
  13742. constructor(
  13743. /**
  13744. * Define the name of the layer.
  13745. */
  13746. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13747. private _createIndexBuffer;
  13748. /** @hidden */ rebuild(): void;
  13749. /**
  13750. * Renders the layer in the scene.
  13751. */
  13752. render(): void;
  13753. /**
  13754. * Disposes and releases the associated ressources.
  13755. */
  13756. dispose(): void;
  13757. }
  13758. }
  13759. declare module BABYLON {
  13760. interface AbstractScene {
  13761. /**
  13762. * The list of procedural textures added to the scene
  13763. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13764. */
  13765. proceduralTextures: Array<ProceduralTexture>;
  13766. }
  13767. /**
  13768. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13769. * in a given scene.
  13770. */
  13771. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13772. /**
  13773. * The component name helpfull to identify the component in the list of scene components.
  13774. */
  13775. readonly name: string;
  13776. /**
  13777. * The scene the component belongs to.
  13778. */
  13779. scene: Scene;
  13780. /**
  13781. * Creates a new instance of the component for the given scene
  13782. * @param scene Defines the scene to register the component in
  13783. */
  13784. constructor(scene: Scene);
  13785. /**
  13786. * Registers the component in a given scene
  13787. */
  13788. register(): void;
  13789. /**
  13790. * Rebuilds the elements related to this component in case of
  13791. * context lost for instance.
  13792. */
  13793. rebuild(): void;
  13794. /**
  13795. * Disposes the component and the associated ressources.
  13796. */
  13797. dispose(): void;
  13798. private _beforeClear;
  13799. }
  13800. }
  13801. declare module BABYLON {
  13802. /** @hidden */
  13803. export var proceduralVertexShader: {
  13804. name: string;
  13805. shader: string;
  13806. };
  13807. }
  13808. declare module BABYLON {
  13809. /**
  13810. * 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.
  13811. * This is the base class of any Procedural texture and contains most of the shareable code.
  13812. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13813. */
  13814. export class ProceduralTexture extends Texture {
  13815. isCube: boolean;
  13816. /**
  13817. * Define if the texture is enabled or not (disabled texture will not render)
  13818. */
  13819. isEnabled: boolean;
  13820. /**
  13821. * Define if the texture must be cleared before rendering (default is true)
  13822. */
  13823. autoClear: boolean;
  13824. /**
  13825. * Callback called when the texture is generated
  13826. */
  13827. onGenerated: () => void;
  13828. /**
  13829. * Event raised when the texture is generated
  13830. */
  13831. onGeneratedObservable: Observable<ProceduralTexture>;
  13832. /** @hidden */ generateMipMaps: boolean;
  13833. /** @hidden **/ effect: Effect;
  13834. /** @hidden */ textures: {
  13835. [key: string]: Texture;
  13836. };
  13837. private _size;
  13838. private _currentRefreshId;
  13839. private _refreshRate;
  13840. private _vertexBuffers;
  13841. private _indexBuffer;
  13842. private _uniforms;
  13843. private _samplers;
  13844. private _fragment;
  13845. private _floats;
  13846. private _ints;
  13847. private _floatsArrays;
  13848. private _colors3;
  13849. private _colors4;
  13850. private _vectors2;
  13851. private _vectors3;
  13852. private _matrices;
  13853. private _fallbackTexture;
  13854. private _fallbackTextureUsed;
  13855. private _engine;
  13856. private _cachedDefines;
  13857. private _contentUpdateId;
  13858. private _contentData;
  13859. /**
  13860. * Instantiates a new procedural texture.
  13861. * 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.
  13862. * This is the base class of any Procedural texture and contains most of the shareable code.
  13863. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13864. * @param name Define the name of the texture
  13865. * @param size Define the size of the texture to create
  13866. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13867. * @param scene Define the scene the texture belongs to
  13868. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13869. * @param generateMipMaps Define if the texture should creates mip maps or not
  13870. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13871. */
  13872. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13873. /**
  13874. * The effect that is created when initializing the post process.
  13875. * @returns The created effect corrisponding the the postprocess.
  13876. */
  13877. getEffect(): Effect;
  13878. /**
  13879. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13880. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13881. */
  13882. getContent(): Nullable<ArrayBufferView>;
  13883. private _createIndexBuffer;
  13884. /** @hidden */ rebuild(): void;
  13885. /**
  13886. * Resets the texture in order to recreate its associated resources.
  13887. * This can be called in case of context loss
  13888. */
  13889. reset(): void;
  13890. protected _getDefines(): string;
  13891. /**
  13892. * Is the texture ready to be used ? (rendered at least once)
  13893. * @returns true if ready, otherwise, false.
  13894. */
  13895. isReady(): boolean;
  13896. /**
  13897. * Resets the refresh counter of the texture and start bak from scratch.
  13898. * Could be useful to regenerate the texture if it is setup to render only once.
  13899. */
  13900. resetRefreshCounter(): void;
  13901. /**
  13902. * Set the fragment shader to use in order to render the texture.
  13903. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13904. */
  13905. setFragment(fragment: any): void;
  13906. /**
  13907. * Define the refresh rate of the texture or the rendering frequency.
  13908. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13909. */
  13910. refreshRate: number;
  13911. /** @hidden */ shouldRender(): boolean;
  13912. /**
  13913. * Get the size the texture is rendering at.
  13914. * @returns the size (texture is always squared)
  13915. */
  13916. getRenderSize(): number;
  13917. /**
  13918. * Resize the texture to new value.
  13919. * @param size Define the new size the texture should have
  13920. * @param generateMipMaps Define whether the new texture should create mip maps
  13921. */
  13922. resize(size: number, generateMipMaps: boolean): void;
  13923. private _checkUniform;
  13924. /**
  13925. * Set a texture in the shader program used to render.
  13926. * @param name Define the name of the uniform samplers as defined in the shader
  13927. * @param texture Define the texture to bind to this sampler
  13928. * @return the texture itself allowing "fluent" like uniform updates
  13929. */
  13930. setTexture(name: string, texture: Texture): ProceduralTexture;
  13931. /**
  13932. * Set a float in the shader.
  13933. * @param name Define the name of the uniform as defined in the shader
  13934. * @param value Define the value to give to the uniform
  13935. * @return the texture itself allowing "fluent" like uniform updates
  13936. */
  13937. setFloat(name: string, value: number): ProceduralTexture;
  13938. /**
  13939. * Set a int in the shader.
  13940. * @param name Define the name of the uniform as defined in the shader
  13941. * @param value Define the value to give to the uniform
  13942. * @return the texture itself allowing "fluent" like uniform updates
  13943. */
  13944. setInt(name: string, value: number): ProceduralTexture;
  13945. /**
  13946. * Set an array of floats in the shader.
  13947. * @param name Define the name of the uniform as defined in the shader
  13948. * @param value Define the value to give to the uniform
  13949. * @return the texture itself allowing "fluent" like uniform updates
  13950. */
  13951. setFloats(name: string, value: number[]): ProceduralTexture;
  13952. /**
  13953. * Set a vec3 in the shader from a Color3.
  13954. * @param name Define the name of the uniform as defined in the shader
  13955. * @param value Define the value to give to the uniform
  13956. * @return the texture itself allowing "fluent" like uniform updates
  13957. */
  13958. setColor3(name: string, value: Color3): ProceduralTexture;
  13959. /**
  13960. * Set a vec4 in the shader from a Color4.
  13961. * @param name Define the name of the uniform as defined in the shader
  13962. * @param value Define the value to give to the uniform
  13963. * @return the texture itself allowing "fluent" like uniform updates
  13964. */
  13965. setColor4(name: string, value: Color4): ProceduralTexture;
  13966. /**
  13967. * Set a vec2 in the shader from a Vector2.
  13968. * @param name Define the name of the uniform as defined in the shader
  13969. * @param value Define the value to give to the uniform
  13970. * @return the texture itself allowing "fluent" like uniform updates
  13971. */
  13972. setVector2(name: string, value: Vector2): ProceduralTexture;
  13973. /**
  13974. * Set a vec3 in the shader from a Vector3.
  13975. * @param name Define the name of the uniform as defined in the shader
  13976. * @param value Define the value to give to the uniform
  13977. * @return the texture itself allowing "fluent" like uniform updates
  13978. */
  13979. setVector3(name: string, value: Vector3): ProceduralTexture;
  13980. /**
  13981. * Set a mat4 in the shader from a MAtrix.
  13982. * @param name Define the name of the uniform as defined in the shader
  13983. * @param value Define the value to give to the uniform
  13984. * @return the texture itself allowing "fluent" like uniform updates
  13985. */
  13986. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13987. /**
  13988. * Render the texture to its associated render target.
  13989. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13990. */
  13991. render(useCameraPostProcess?: boolean): void;
  13992. /**
  13993. * Clone the texture.
  13994. * @returns the cloned texture
  13995. */
  13996. clone(): ProceduralTexture;
  13997. /**
  13998. * Dispose the texture and release its asoociated resources.
  13999. */
  14000. dispose(): void;
  14001. }
  14002. }
  14003. declare module BABYLON {
  14004. /**
  14005. * This represents the base class for particle system in Babylon.
  14006. * 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.
  14007. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14008. * @example https://doc.babylonjs.com/babylon101/particles
  14009. */
  14010. export class BaseParticleSystem {
  14011. /**
  14012. * Source color is added to the destination color without alpha affecting the result
  14013. */
  14014. static BLENDMODE_ONEONE: number;
  14015. /**
  14016. * Blend current color and particle color using particle’s alpha
  14017. */
  14018. static BLENDMODE_STANDARD: number;
  14019. /**
  14020. * Add current color and particle color multiplied by particle’s alpha
  14021. */
  14022. static BLENDMODE_ADD: number;
  14023. /**
  14024. * Multiply current color with particle color
  14025. */
  14026. static BLENDMODE_MULTIPLY: number;
  14027. /**
  14028. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14029. */
  14030. static BLENDMODE_MULTIPLYADD: number;
  14031. /**
  14032. * List of animations used by the particle system.
  14033. */
  14034. animations: Animation[];
  14035. /**
  14036. * The id of the Particle system.
  14037. */
  14038. id: string;
  14039. /**
  14040. * The friendly name of the Particle system.
  14041. */
  14042. name: string;
  14043. /**
  14044. * The rendering group used by the Particle system to chose when to render.
  14045. */
  14046. renderingGroupId: number;
  14047. /**
  14048. * The emitter represents the Mesh or position we are attaching the particle system to.
  14049. */
  14050. emitter: Nullable<AbstractMesh | Vector3>;
  14051. /**
  14052. * The maximum number of particles to emit per frame
  14053. */
  14054. emitRate: number;
  14055. /**
  14056. * If you want to launch only a few particles at once, that can be done, as well.
  14057. */
  14058. manualEmitCount: number;
  14059. /**
  14060. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14061. */
  14062. updateSpeed: number;
  14063. /**
  14064. * The amount of time the particle system is running (depends of the overall update speed).
  14065. */
  14066. targetStopDuration: number;
  14067. /**
  14068. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14069. */
  14070. disposeOnStop: boolean;
  14071. /**
  14072. * Minimum power of emitting particles.
  14073. */
  14074. minEmitPower: number;
  14075. /**
  14076. * Maximum power of emitting particles.
  14077. */
  14078. maxEmitPower: number;
  14079. /**
  14080. * Minimum life time of emitting particles.
  14081. */
  14082. minLifeTime: number;
  14083. /**
  14084. * Maximum life time of emitting particles.
  14085. */
  14086. maxLifeTime: number;
  14087. /**
  14088. * Minimum Size of emitting particles.
  14089. */
  14090. minSize: number;
  14091. /**
  14092. * Maximum Size of emitting particles.
  14093. */
  14094. maxSize: number;
  14095. /**
  14096. * Minimum scale of emitting particles on X axis.
  14097. */
  14098. minScaleX: number;
  14099. /**
  14100. * Maximum scale of emitting particles on X axis.
  14101. */
  14102. maxScaleX: number;
  14103. /**
  14104. * Minimum scale of emitting particles on Y axis.
  14105. */
  14106. minScaleY: number;
  14107. /**
  14108. * Maximum scale of emitting particles on Y axis.
  14109. */
  14110. maxScaleY: number;
  14111. /**
  14112. * Gets or sets the minimal initial rotation in radians.
  14113. */
  14114. minInitialRotation: number;
  14115. /**
  14116. * Gets or sets the maximal initial rotation in radians.
  14117. */
  14118. maxInitialRotation: number;
  14119. /**
  14120. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14121. */
  14122. minAngularSpeed: number;
  14123. /**
  14124. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14125. */
  14126. maxAngularSpeed: number;
  14127. /**
  14128. * The texture used to render each particle. (this can be a spritesheet)
  14129. */
  14130. particleTexture: Nullable<Texture>;
  14131. /**
  14132. * The layer mask we are rendering the particles through.
  14133. */
  14134. layerMask: number;
  14135. /**
  14136. * This can help using your own shader to render the particle system.
  14137. * The according effect will be created
  14138. */
  14139. customShader: any;
  14140. /**
  14141. * By default particle system starts as soon as they are created. This prevents the
  14142. * automatic start to happen and let you decide when to start emitting particles.
  14143. */
  14144. preventAutoStart: boolean;
  14145. private _noiseTexture;
  14146. /**
  14147. * Gets or sets a texture used to add random noise to particle positions
  14148. */
  14149. noiseTexture: Nullable<ProceduralTexture>;
  14150. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14151. noiseStrength: Vector3;
  14152. /**
  14153. * Callback triggered when the particle animation is ending.
  14154. */
  14155. onAnimationEnd: Nullable<() => void>;
  14156. /**
  14157. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14158. */
  14159. blendMode: number;
  14160. /**
  14161. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14162. * to override the particles.
  14163. */
  14164. forceDepthWrite: boolean;
  14165. /** 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 */
  14166. preWarmCycles: number;
  14167. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14168. preWarmStepOffset: number;
  14169. /**
  14170. * 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)
  14171. */
  14172. spriteCellChangeSpeed: number;
  14173. /**
  14174. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14175. */
  14176. startSpriteCellID: number;
  14177. /**
  14178. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14179. */
  14180. endSpriteCellID: number;
  14181. /**
  14182. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14183. */
  14184. spriteCellWidth: number;
  14185. /**
  14186. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14187. */
  14188. spriteCellHeight: number;
  14189. /**
  14190. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14191. */
  14192. spriteRandomStartCell: boolean;
  14193. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14194. translationPivot: Vector2;
  14195. /** @hidden */
  14196. protected _isAnimationSheetEnabled: boolean;
  14197. /**
  14198. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14199. */
  14200. beginAnimationOnStart: boolean;
  14201. /**
  14202. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14203. */
  14204. beginAnimationFrom: number;
  14205. /**
  14206. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14207. */
  14208. beginAnimationTo: number;
  14209. /**
  14210. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14211. */
  14212. beginAnimationLoop: boolean;
  14213. /**
  14214. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14215. */
  14216. isAnimationSheetEnabled: boolean;
  14217. /**
  14218. * Get hosting scene
  14219. * @returns the scene
  14220. */
  14221. getScene(): Scene;
  14222. /**
  14223. * You can use gravity if you want to give an orientation to your particles.
  14224. */
  14225. gravity: Vector3;
  14226. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14227. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14228. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14229. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14230. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14231. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14232. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14233. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14234. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14235. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14236. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14237. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14238. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14239. /**
  14240. * Defines the delay in milliseconds before starting the system (0 by default)
  14241. */
  14242. startDelay: number;
  14243. /**
  14244. * Gets the current list of drag gradients.
  14245. * You must use addDragGradient and removeDragGradient to udpate this list
  14246. * @returns the list of drag gradients
  14247. */
  14248. getDragGradients(): Nullable<Array<FactorGradient>>;
  14249. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14250. limitVelocityDamping: number;
  14251. /**
  14252. * Gets the current list of limit velocity gradients.
  14253. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14254. * @returns the list of limit velocity gradients
  14255. */
  14256. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14257. /**
  14258. * Gets the current list of color gradients.
  14259. * You must use addColorGradient and removeColorGradient to udpate this list
  14260. * @returns the list of color gradients
  14261. */
  14262. getColorGradients(): Nullable<Array<ColorGradient>>;
  14263. /**
  14264. * Gets the current list of size gradients.
  14265. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14266. * @returns the list of size gradients
  14267. */
  14268. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14269. /**
  14270. * Gets the current list of color remap gradients.
  14271. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14272. * @returns the list of color remap gradients
  14273. */
  14274. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14275. /**
  14276. * Gets the current list of alpha remap gradients.
  14277. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14278. * @returns the list of alpha remap gradients
  14279. */
  14280. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14281. /**
  14282. * Gets the current list of life time gradients.
  14283. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14284. * @returns the list of life time gradients
  14285. */
  14286. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14287. /**
  14288. * Gets the current list of angular speed gradients.
  14289. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14290. * @returns the list of angular speed gradients
  14291. */
  14292. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14293. /**
  14294. * Gets the current list of velocity gradients.
  14295. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14296. * @returns the list of velocity gradients
  14297. */
  14298. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14299. /**
  14300. * Gets the current list of start size gradients.
  14301. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14302. * @returns the list of start size gradients
  14303. */
  14304. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14305. /**
  14306. * Gets the current list of emit rate gradients.
  14307. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14308. * @returns the list of emit rate gradients
  14309. */
  14310. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14311. /**
  14312. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14313. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14314. */
  14315. direction1: Vector3;
  14316. /**
  14317. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14318. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14319. */
  14320. direction2: Vector3;
  14321. /**
  14322. * 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.
  14323. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14324. */
  14325. minEmitBox: Vector3;
  14326. /**
  14327. * 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.
  14328. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14329. */
  14330. maxEmitBox: Vector3;
  14331. /**
  14332. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14333. */
  14334. color1: Color4;
  14335. /**
  14336. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14337. */
  14338. color2: Color4;
  14339. /**
  14340. * Color the particle will have at the end of its lifetime
  14341. */
  14342. colorDead: Color4;
  14343. /**
  14344. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14345. */
  14346. textureMask: Color4;
  14347. /**
  14348. * The particle emitter type defines the emitter used by the particle system.
  14349. * It can be for example box, sphere, or cone...
  14350. */
  14351. particleEmitterType: IParticleEmitterType;
  14352. /** @hidden */ isSubEmitter: boolean;
  14353. /**
  14354. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14355. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14356. */
  14357. billboardMode: number;
  14358. protected _isBillboardBased: boolean;
  14359. /**
  14360. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14361. */
  14362. isBillboardBased: boolean;
  14363. /**
  14364. * The scene the particle system belongs to.
  14365. */
  14366. protected _scene: Scene;
  14367. /**
  14368. * Local cache of defines for image processing.
  14369. */
  14370. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14371. /**
  14372. * Default configuration related to image processing available in the standard Material.
  14373. */
  14374. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14375. /**
  14376. * Gets the image processing configuration used either in this material.
  14377. */
  14378. /**
  14379. * Sets the Default image processing configuration used either in the this material.
  14380. *
  14381. * If sets to null, the scene one is in use.
  14382. */
  14383. imageProcessingConfiguration: ImageProcessingConfiguration;
  14384. /**
  14385. * Attaches a new image processing configuration to the Standard Material.
  14386. * @param configuration
  14387. */
  14388. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14389. /** @hidden */
  14390. protected _reset(): void;
  14391. /** @hidden */
  14392. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14393. /**
  14394. * Instantiates a particle system.
  14395. * 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.
  14396. * @param name The name of the particle system
  14397. */
  14398. constructor(name: string);
  14399. /**
  14400. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14401. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14402. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14403. * @returns the emitter
  14404. */
  14405. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14406. /**
  14407. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14408. * @param radius The radius of the hemisphere to emit from
  14409. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14410. * @returns the emitter
  14411. */
  14412. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14413. /**
  14414. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14415. * @param radius The radius of the sphere to emit from
  14416. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14417. * @returns the emitter
  14418. */
  14419. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14420. /**
  14421. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14422. * @param radius The radius of the sphere to emit from
  14423. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14424. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14425. * @returns the emitter
  14426. */
  14427. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14428. /**
  14429. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14430. * @param radius The radius of the emission cylinder
  14431. * @param height The height of the emission cylinder
  14432. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14433. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14434. * @returns the emitter
  14435. */
  14436. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14437. /**
  14438. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14439. * @param radius The radius of the cylinder to emit from
  14440. * @param height The height of the emission cylinder
  14441. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14442. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14443. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14444. * @returns the emitter
  14445. */
  14446. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14447. /**
  14448. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14449. * @param radius The radius of the cone to emit from
  14450. * @param angle The base angle of the cone
  14451. * @returns the emitter
  14452. */
  14453. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14454. /**
  14455. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14456. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14457. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14458. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14459. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14460. * @returns the emitter
  14461. */
  14462. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14463. }
  14464. }
  14465. declare module BABYLON {
  14466. /**
  14467. * Type of sub emitter
  14468. */
  14469. export enum SubEmitterType {
  14470. /**
  14471. * Attached to the particle over it's lifetime
  14472. */
  14473. ATTACHED = 0,
  14474. /**
  14475. * Created when the particle dies
  14476. */
  14477. END = 1
  14478. }
  14479. /**
  14480. * Sub emitter class used to emit particles from an existing particle
  14481. */
  14482. export class SubEmitter {
  14483. /**
  14484. * the particle system to be used by the sub emitter
  14485. */
  14486. particleSystem: ParticleSystem;
  14487. /**
  14488. * Type of the submitter (Default: END)
  14489. */
  14490. type: SubEmitterType;
  14491. /**
  14492. * 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)
  14493. * Note: This only is supported when using an emitter of type Mesh
  14494. */
  14495. inheritDirection: boolean;
  14496. /**
  14497. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14498. */
  14499. inheritedVelocityAmount: number;
  14500. /**
  14501. * Creates a sub emitter
  14502. * @param particleSystem the particle system to be used by the sub emitter
  14503. */
  14504. constructor(
  14505. /**
  14506. * the particle system to be used by the sub emitter
  14507. */
  14508. particleSystem: ParticleSystem);
  14509. /**
  14510. * Clones the sub emitter
  14511. * @returns the cloned sub emitter
  14512. */
  14513. clone(): SubEmitter;
  14514. /**
  14515. * Serialize current object to a JSON object
  14516. * @returns the serialized object
  14517. */
  14518. serialize(): any;
  14519. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14520. /**
  14521. * Creates a new SubEmitter from a serialized JSON version
  14522. * @param serializationObject defines the JSON object to read from
  14523. * @param scene defines the hosting scene
  14524. * @param rootUrl defines the rootUrl for data loading
  14525. * @returns a new SubEmitter
  14526. */
  14527. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14528. /** Release associated resources */
  14529. dispose(): void;
  14530. }
  14531. }
  14532. declare module BABYLON {
  14533. /** @hidden */
  14534. export var clipPlaneFragmentDeclaration: {
  14535. name: string;
  14536. shader: string;
  14537. };
  14538. }
  14539. declare module BABYLON {
  14540. /** @hidden */
  14541. export var imageProcessingDeclaration: {
  14542. name: string;
  14543. shader: string;
  14544. };
  14545. }
  14546. declare module BABYLON {
  14547. /** @hidden */
  14548. export var imageProcessingFunctions: {
  14549. name: string;
  14550. shader: string;
  14551. };
  14552. }
  14553. declare module BABYLON {
  14554. /** @hidden */
  14555. export var clipPlaneFragment: {
  14556. name: string;
  14557. shader: string;
  14558. };
  14559. }
  14560. declare module BABYLON {
  14561. /** @hidden */
  14562. export var particlesPixelShader: {
  14563. name: string;
  14564. shader: string;
  14565. };
  14566. }
  14567. declare module BABYLON {
  14568. /** @hidden */
  14569. export var clipPlaneVertexDeclaration: {
  14570. name: string;
  14571. shader: string;
  14572. };
  14573. }
  14574. declare module BABYLON {
  14575. /** @hidden */
  14576. export var clipPlaneVertex: {
  14577. name: string;
  14578. shader: string;
  14579. };
  14580. }
  14581. declare module BABYLON {
  14582. /** @hidden */
  14583. export var particlesVertexShader: {
  14584. name: string;
  14585. shader: string;
  14586. };
  14587. }
  14588. declare module BABYLON {
  14589. /**
  14590. * This represents a particle system in Babylon.
  14591. * 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.
  14592. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14593. * @example https://doc.babylonjs.com/babylon101/particles
  14594. */
  14595. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14596. /**
  14597. * Billboard mode will only apply to Y axis
  14598. */
  14599. static readonly BILLBOARDMODE_Y: number;
  14600. /**
  14601. * Billboard mode will apply to all axes
  14602. */
  14603. static readonly BILLBOARDMODE_ALL: number;
  14604. /**
  14605. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14606. */
  14607. static readonly BILLBOARDMODE_STRETCHED: number;
  14608. /**
  14609. * This function can be defined to provide custom update for active particles.
  14610. * This function will be called instead of regular update (age, position, color, etc.).
  14611. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14612. */
  14613. updateFunction: (particles: Particle[]) => void;
  14614. private _emitterWorldMatrix;
  14615. /**
  14616. * This function can be defined to specify initial direction for every new particle.
  14617. * It by default use the emitterType defined function
  14618. */
  14619. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14620. /**
  14621. * This function can be defined to specify initial position for every new particle.
  14622. * It by default use the emitterType defined function
  14623. */
  14624. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14625. /**
  14626. * @hidden
  14627. */ inheritedVelocityOffset: Vector3;
  14628. /**
  14629. * An event triggered when the system is disposed
  14630. */
  14631. onDisposeObservable: Observable<ParticleSystem>;
  14632. private _onDisposeObserver;
  14633. /**
  14634. * Sets a callback that will be triggered when the system is disposed
  14635. */
  14636. onDispose: () => void;
  14637. private _particles;
  14638. private _epsilon;
  14639. private _capacity;
  14640. private _stockParticles;
  14641. private _newPartsExcess;
  14642. private _vertexData;
  14643. private _vertexBuffer;
  14644. private _vertexBuffers;
  14645. private _spriteBuffer;
  14646. private _indexBuffer;
  14647. private _effect;
  14648. private _customEffect;
  14649. private _cachedDefines;
  14650. private _scaledColorStep;
  14651. private _colorDiff;
  14652. private _scaledDirection;
  14653. private _scaledGravity;
  14654. private _currentRenderId;
  14655. private _alive;
  14656. private _useInstancing;
  14657. private _started;
  14658. private _stopped;
  14659. private _actualFrame;
  14660. private _scaledUpdateSpeed;
  14661. private _vertexBufferSize;
  14662. /** @hidden */ currentEmitRateGradient: Nullable<FactorGradient>;
  14663. /** @hidden */ currentEmitRate1: number;
  14664. /** @hidden */ currentEmitRate2: number;
  14665. /** @hidden */ currentStartSizeGradient: Nullable<FactorGradient>;
  14666. /** @hidden */ currentStartSize1: number;
  14667. /** @hidden */ currentStartSize2: number;
  14668. private readonly _rawTextureWidth;
  14669. private _rampGradientsTexture;
  14670. private _useRampGradients;
  14671. /** Gets or sets a boolean indicating that ramp gradients must be used
  14672. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14673. */
  14674. useRampGradients: boolean;
  14675. /**
  14676. * 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.
  14677. * 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: [])
  14678. */
  14679. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14680. private _subEmitters;
  14681. /**
  14682. * @hidden
  14683. * If the particle systems emitter should be disposed when the particle system is disposed
  14684. */ disposeEmitterOnDispose: boolean;
  14685. /**
  14686. * The current active Sub-systems, this property is used by the root particle system only.
  14687. */
  14688. activeSubSystems: Array<ParticleSystem>;
  14689. private _rootParticleSystem;
  14690. /**
  14691. * Gets the current list of active particles
  14692. */
  14693. readonly particles: Particle[];
  14694. /**
  14695. * Returns the string "ParticleSystem"
  14696. * @returns a string containing the class name
  14697. */
  14698. getClassName(): string;
  14699. /**
  14700. * Instantiates a particle system.
  14701. * 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.
  14702. * @param name The name of the particle system
  14703. * @param capacity The max number of particles alive at the same time
  14704. * @param scene The scene the particle system belongs to
  14705. * @param customEffect a custom effect used to change the way particles are rendered by default
  14706. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14707. * @param epsilon Offset used to render the particles
  14708. */
  14709. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14710. private _addFactorGradient;
  14711. private _removeFactorGradient;
  14712. /**
  14713. * Adds a new life time gradient
  14714. * @param gradient defines the gradient to use (between 0 and 1)
  14715. * @param factor defines the life time factor to affect to the specified gradient
  14716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14717. * @returns the current particle system
  14718. */
  14719. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14720. /**
  14721. * Remove a specific life time gradient
  14722. * @param gradient defines the gradient to remove
  14723. * @returns the current particle system
  14724. */
  14725. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14726. /**
  14727. * Adds a new size gradient
  14728. * @param gradient defines the gradient to use (between 0 and 1)
  14729. * @param factor defines the size factor to affect to the specified gradient
  14730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14731. * @returns the current particle system
  14732. */
  14733. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14734. /**
  14735. * Remove a specific size gradient
  14736. * @param gradient defines the gradient to remove
  14737. * @returns the current particle system
  14738. */
  14739. removeSizeGradient(gradient: number): IParticleSystem;
  14740. /**
  14741. * Adds a new color remap gradient
  14742. * @param gradient defines the gradient to use (between 0 and 1)
  14743. * @param min defines the color remap minimal range
  14744. * @param max defines the color remap maximal range
  14745. * @returns the current particle system
  14746. */
  14747. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14748. /**
  14749. * Remove a specific color remap gradient
  14750. * @param gradient defines the gradient to remove
  14751. * @returns the current particle system
  14752. */
  14753. removeColorRemapGradient(gradient: number): IParticleSystem;
  14754. /**
  14755. * Adds a new alpha remap gradient
  14756. * @param gradient defines the gradient to use (between 0 and 1)
  14757. * @param min defines the alpha remap minimal range
  14758. * @param max defines the alpha remap maximal range
  14759. * @returns the current particle system
  14760. */
  14761. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14762. /**
  14763. * Remove a specific alpha remap gradient
  14764. * @param gradient defines the gradient to remove
  14765. * @returns the current particle system
  14766. */
  14767. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14768. /**
  14769. * Adds a new angular speed gradient
  14770. * @param gradient defines the gradient to use (between 0 and 1)
  14771. * @param factor defines the angular speed to affect to the specified gradient
  14772. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14773. * @returns the current particle system
  14774. */
  14775. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14776. /**
  14777. * Remove a specific angular speed gradient
  14778. * @param gradient defines the gradient to remove
  14779. * @returns the current particle system
  14780. */
  14781. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14782. /**
  14783. * Adds a new velocity gradient
  14784. * @param gradient defines the gradient to use (between 0 and 1)
  14785. * @param factor defines the velocity to affect to the specified gradient
  14786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14787. * @returns the current particle system
  14788. */
  14789. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14790. /**
  14791. * Remove a specific velocity gradient
  14792. * @param gradient defines the gradient to remove
  14793. * @returns the current particle system
  14794. */
  14795. removeVelocityGradient(gradient: number): IParticleSystem;
  14796. /**
  14797. * Adds a new limit velocity gradient
  14798. * @param gradient defines the gradient to use (between 0 and 1)
  14799. * @param factor defines the limit velocity value to affect to the specified gradient
  14800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14801. * @returns the current particle system
  14802. */
  14803. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14804. /**
  14805. * Remove a specific limit velocity gradient
  14806. * @param gradient defines the gradient to remove
  14807. * @returns the current particle system
  14808. */
  14809. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14810. /**
  14811. * Adds a new drag gradient
  14812. * @param gradient defines the gradient to use (between 0 and 1)
  14813. * @param factor defines the drag value to affect to the specified gradient
  14814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14815. * @returns the current particle system
  14816. */
  14817. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14818. /**
  14819. * Remove a specific drag gradient
  14820. * @param gradient defines the gradient to remove
  14821. * @returns the current particle system
  14822. */
  14823. removeDragGradient(gradient: number): IParticleSystem;
  14824. /**
  14825. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14826. * @param gradient defines the gradient to use (between 0 and 1)
  14827. * @param factor defines the emit rate value to affect to the specified gradient
  14828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14829. * @returns the current particle system
  14830. */
  14831. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14832. /**
  14833. * Remove a specific emit rate gradient
  14834. * @param gradient defines the gradient to remove
  14835. * @returns the current particle system
  14836. */
  14837. removeEmitRateGradient(gradient: number): IParticleSystem;
  14838. /**
  14839. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14840. * @param gradient defines the gradient to use (between 0 and 1)
  14841. * @param factor defines the start size value to affect to the specified gradient
  14842. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14843. * @returns the current particle system
  14844. */
  14845. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14846. /**
  14847. * Remove a specific start size gradient
  14848. * @param gradient defines the gradient to remove
  14849. * @returns the current particle system
  14850. */
  14851. removeStartSizeGradient(gradient: number): IParticleSystem;
  14852. private _createRampGradientTexture;
  14853. /**
  14854. * Gets the current list of ramp gradients.
  14855. * You must use addRampGradient and removeRampGradient to udpate this list
  14856. * @returns the list of ramp gradients
  14857. */
  14858. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14859. /**
  14860. * Adds a new ramp gradient used to remap particle colors
  14861. * @param gradient defines the gradient to use (between 0 and 1)
  14862. * @param color defines the color to affect to the specified gradient
  14863. * @returns the current particle system
  14864. */
  14865. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14866. /**
  14867. * Remove a specific ramp gradient
  14868. * @param gradient defines the gradient to remove
  14869. * @returns the current particle system
  14870. */
  14871. removeRampGradient(gradient: number): ParticleSystem;
  14872. /**
  14873. * Adds a new color gradient
  14874. * @param gradient defines the gradient to use (between 0 and 1)
  14875. * @param color1 defines the color to affect to the specified gradient
  14876. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14877. * @returns this particle system
  14878. */
  14879. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14880. /**
  14881. * Remove a specific color gradient
  14882. * @param gradient defines the gradient to remove
  14883. * @returns this particle system
  14884. */
  14885. removeColorGradient(gradient: number): IParticleSystem;
  14886. private _fetchR;
  14887. protected _reset(): void;
  14888. private _resetEffect;
  14889. private _createVertexBuffers;
  14890. private _createIndexBuffer;
  14891. /**
  14892. * Gets the maximum number of particles active at the same time.
  14893. * @returns The max number of active particles.
  14894. */
  14895. getCapacity(): number;
  14896. /**
  14897. * Gets whether there are still active particles in the system.
  14898. * @returns True if it is alive, otherwise false.
  14899. */
  14900. isAlive(): boolean;
  14901. /**
  14902. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14903. * @returns True if it has been started, otherwise false.
  14904. */
  14905. isStarted(): boolean;
  14906. private _prepareSubEmitterInternalArray;
  14907. /**
  14908. * Starts the particle system and begins to emit
  14909. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14910. */
  14911. start(delay?: number): void;
  14912. /**
  14913. * Stops the particle system.
  14914. * @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.
  14915. */
  14916. stop(stopSubEmitters?: boolean): void;
  14917. /**
  14918. * Remove all active particles
  14919. */
  14920. reset(): void;
  14921. /**
  14922. * @hidden (for internal use only)
  14923. */ appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14924. /**
  14925. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14926. * Its lifetime will start back at 0.
  14927. */
  14928. recycleParticle: (particle: Particle) => void;
  14929. private _stopSubEmitters;
  14930. private _createParticle;
  14931. private _removeFromRoot;
  14932. private _emitFromParticle;
  14933. private _update;
  14934. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14935. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14936. /** @hidden */
  14937. private _getEffect;
  14938. /**
  14939. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14940. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14941. */
  14942. animate(preWarmOnly?: boolean): void;
  14943. private _appendParticleVertices;
  14944. /**
  14945. * Rebuilds the particle system.
  14946. */
  14947. rebuild(): void;
  14948. /**
  14949. * Is this system ready to be used/rendered
  14950. * @return true if the system is ready
  14951. */
  14952. isReady(): boolean;
  14953. private _render;
  14954. /**
  14955. * Renders the particle system in its current state.
  14956. * @returns the current number of particles
  14957. */
  14958. render(): number;
  14959. /**
  14960. * Disposes the particle system and free the associated resources
  14961. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14962. */
  14963. dispose(disposeTexture?: boolean): void;
  14964. /**
  14965. * Clones the particle system.
  14966. * @param name The name of the cloned object
  14967. * @param newEmitter The new emitter to use
  14968. * @returns the cloned particle system
  14969. */
  14970. clone(name: string, newEmitter: any): ParticleSystem;
  14971. /**
  14972. * Serializes the particle system to a JSON object.
  14973. * @returns the JSON object
  14974. */
  14975. serialize(): any;
  14976. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14977. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14978. /**
  14979. * Parses a JSON object to create a particle system.
  14980. * @param parsedParticleSystem The JSON object to parse
  14981. * @param scene The scene to create the particle system in
  14982. * @param rootUrl The root url to use to load external dependencies like texture
  14983. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14984. * @returns the Parsed particle system
  14985. */
  14986. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14987. }
  14988. }
  14989. declare module BABYLON {
  14990. /**
  14991. * A particle represents one of the element emitted by a particle system.
  14992. * This is mainly define by its coordinates, direction, velocity and age.
  14993. */
  14994. export class Particle {
  14995. /**
  14996. * The particle system the particle belongs to.
  14997. */
  14998. particleSystem: ParticleSystem;
  14999. private static _Count;
  15000. /**
  15001. * Unique ID of the particle
  15002. */
  15003. id: number;
  15004. /**
  15005. * The world position of the particle in the scene.
  15006. */
  15007. position: Vector3;
  15008. /**
  15009. * The world direction of the particle in the scene.
  15010. */
  15011. direction: Vector3;
  15012. /**
  15013. * The color of the particle.
  15014. */
  15015. color: Color4;
  15016. /**
  15017. * The color change of the particle per step.
  15018. */
  15019. colorStep: Color4;
  15020. /**
  15021. * Defines how long will the life of the particle be.
  15022. */
  15023. lifeTime: number;
  15024. /**
  15025. * The current age of the particle.
  15026. */
  15027. age: number;
  15028. /**
  15029. * The current size of the particle.
  15030. */
  15031. size: number;
  15032. /**
  15033. * The current scale of the particle.
  15034. */
  15035. scale: Vector2;
  15036. /**
  15037. * The current angle of the particle.
  15038. */
  15039. angle: number;
  15040. /**
  15041. * Defines how fast is the angle changing.
  15042. */
  15043. angularSpeed: number;
  15044. /**
  15045. * Defines the cell index used by the particle to be rendered from a sprite.
  15046. */
  15047. cellIndex: number;
  15048. /**
  15049. * The information required to support color remapping
  15050. */
  15051. remapData: Vector4;
  15052. /** @hidden */ randomCellOffset?: number;
  15053. /** @hidden */ initialDirection: Nullable<Vector3>;
  15054. /** @hidden */ attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15055. /** @hidden */ initialStartSpriteCellID: number;
  15056. /** @hidden */ initialEndSpriteCellID: number;
  15057. /** @hidden */ currentColorGradient: Nullable<ColorGradient>;
  15058. /** @hidden */ currentColor1: Color4;
  15059. /** @hidden */ currentColor2: Color4;
  15060. /** @hidden */ currentSizeGradient: Nullable<FactorGradient>;
  15061. /** @hidden */ currentSize1: number;
  15062. /** @hidden */ currentSize2: number;
  15063. /** @hidden */ currentAngularSpeedGradient: Nullable<FactorGradient>;
  15064. /** @hidden */ currentAngularSpeed1: number;
  15065. /** @hidden */ currentAngularSpeed2: number;
  15066. /** @hidden */ currentVelocityGradient: Nullable<FactorGradient>;
  15067. /** @hidden */ currentVelocity1: number;
  15068. /** @hidden */ currentVelocity2: number;
  15069. /** @hidden */ currentLimitVelocityGradient: Nullable<FactorGradient>;
  15070. /** @hidden */ currentLimitVelocity1: number;
  15071. /** @hidden */ currentLimitVelocity2: number;
  15072. /** @hidden */ currentDragGradient: Nullable<FactorGradient>;
  15073. /** @hidden */ currentDrag1: number;
  15074. /** @hidden */ currentDrag2: number;
  15075. /** @hidden */ randomNoiseCoordinates1: Vector3;
  15076. /** @hidden */ randomNoiseCoordinates2: Vector3;
  15077. /**
  15078. * Creates a new instance Particle
  15079. * @param particleSystem the particle system the particle belongs to
  15080. */
  15081. constructor(
  15082. /**
  15083. * The particle system the particle belongs to.
  15084. */
  15085. particleSystem: ParticleSystem);
  15086. private updateCellInfoFromSystem;
  15087. /**
  15088. * Defines how the sprite cell index is updated for the particle
  15089. */
  15090. updateCellIndex(): void;
  15091. /** @hidden */ inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15092. /** @hidden */ inheritParticleInfoToSubEmitters(): void;
  15093. /** @hidden */ reset(): void;
  15094. /**
  15095. * Copy the properties of particle to another one.
  15096. * @param other the particle to copy the information to.
  15097. */
  15098. copyTo(other: Particle): void;
  15099. }
  15100. }
  15101. declare module BABYLON {
  15102. /**
  15103. * Particle emitter represents a volume emitting particles.
  15104. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15105. */
  15106. export interface IParticleEmitterType {
  15107. /**
  15108. * Called by the particle System when the direction is computed for the created particle.
  15109. * @param worldMatrix is the world matrix of the particle system
  15110. * @param directionToUpdate is the direction vector to update with the result
  15111. * @param particle is the particle we are computed the direction for
  15112. */
  15113. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15114. /**
  15115. * Called by the particle System when the position is computed for the created particle.
  15116. * @param worldMatrix is the world matrix of the particle system
  15117. * @param positionToUpdate is the position vector to update with the result
  15118. * @param particle is the particle we are computed the position for
  15119. */
  15120. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15121. /**
  15122. * Clones the current emitter and returns a copy of it
  15123. * @returns the new emitter
  15124. */
  15125. clone(): IParticleEmitterType;
  15126. /**
  15127. * Called by the GPUParticleSystem to setup the update shader
  15128. * @param effect defines the update shader
  15129. */
  15130. applyToShader(effect: Effect): void;
  15131. /**
  15132. * Returns a string to use to update the GPU particles update shader
  15133. * @returns the effect defines string
  15134. */
  15135. getEffectDefines(): string;
  15136. /**
  15137. * Returns a string representing the class name
  15138. * @returns a string containing the class name
  15139. */
  15140. getClassName(): string;
  15141. /**
  15142. * Serializes the particle system to a JSON object.
  15143. * @returns the JSON object
  15144. */
  15145. serialize(): any;
  15146. /**
  15147. * Parse properties from a JSON object
  15148. * @param serializationObject defines the JSON object
  15149. */
  15150. parse(serializationObject: any): void;
  15151. }
  15152. }
  15153. declare module BABYLON {
  15154. /**
  15155. * Particle emitter emitting particles from the inside of a box.
  15156. * It emits the particles randomly between 2 given directions.
  15157. */
  15158. export class BoxParticleEmitter implements IParticleEmitterType {
  15159. /**
  15160. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15161. */
  15162. direction1: Vector3;
  15163. /**
  15164. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15165. */
  15166. direction2: Vector3;
  15167. /**
  15168. * 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.
  15169. */
  15170. minEmitBox: Vector3;
  15171. /**
  15172. * 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.
  15173. */
  15174. maxEmitBox: Vector3;
  15175. /**
  15176. * Creates a new instance BoxParticleEmitter
  15177. */
  15178. constructor();
  15179. /**
  15180. * Called by the particle System when the direction is computed for the created particle.
  15181. * @param worldMatrix is the world matrix of the particle system
  15182. * @param directionToUpdate is the direction vector to update with the result
  15183. * @param particle is the particle we are computed the direction for
  15184. */
  15185. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15186. /**
  15187. * Called by the particle System when the position is computed for the created particle.
  15188. * @param worldMatrix is the world matrix of the particle system
  15189. * @param positionToUpdate is the position vector to update with the result
  15190. * @param particle is the particle we are computed the position for
  15191. */
  15192. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15193. /**
  15194. * Clones the current emitter and returns a copy of it
  15195. * @returns the new emitter
  15196. */
  15197. clone(): BoxParticleEmitter;
  15198. /**
  15199. * Called by the GPUParticleSystem to setup the update shader
  15200. * @param effect defines the update shader
  15201. */
  15202. applyToShader(effect: Effect): void;
  15203. /**
  15204. * Returns a string to use to update the GPU particles update shader
  15205. * @returns a string containng the defines string
  15206. */
  15207. getEffectDefines(): string;
  15208. /**
  15209. * Returns the string "BoxParticleEmitter"
  15210. * @returns a string containing the class name
  15211. */
  15212. getClassName(): string;
  15213. /**
  15214. * Serializes the particle system to a JSON object.
  15215. * @returns the JSON object
  15216. */
  15217. serialize(): any;
  15218. /**
  15219. * Parse properties from a JSON object
  15220. * @param serializationObject defines the JSON object
  15221. */
  15222. parse(serializationObject: any): void;
  15223. }
  15224. }
  15225. declare module BABYLON {
  15226. /**
  15227. * Particle emitter emitting particles from the inside of a cone.
  15228. * It emits the particles alongside the cone volume from the base to the particle.
  15229. * The emission direction might be randomized.
  15230. */
  15231. export class ConeParticleEmitter implements IParticleEmitterType {
  15232. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15233. directionRandomizer: number;
  15234. private _radius;
  15235. private _angle;
  15236. private _height;
  15237. /**
  15238. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15239. */
  15240. radiusRange: number;
  15241. /**
  15242. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15243. */
  15244. heightRange: number;
  15245. /**
  15246. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15247. */
  15248. emitFromSpawnPointOnly: boolean;
  15249. /**
  15250. * Gets or sets the radius of the emission cone
  15251. */
  15252. radius: number;
  15253. /**
  15254. * Gets or sets the angle of the emission cone
  15255. */
  15256. angle: number;
  15257. private _buildHeight;
  15258. /**
  15259. * Creates a new instance ConeParticleEmitter
  15260. * @param radius the radius of the emission cone (1 by default)
  15261. * @param angle the cone base angle (PI by default)
  15262. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15263. */
  15264. constructor(radius?: number, angle?: number,
  15265. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15266. directionRandomizer?: number);
  15267. /**
  15268. * Called by the particle System when the direction is computed for the created particle.
  15269. * @param worldMatrix is the world matrix of the particle system
  15270. * @param directionToUpdate is the direction vector to update with the result
  15271. * @param particle is the particle we are computed the direction for
  15272. */
  15273. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15274. /**
  15275. * Called by the particle System when the position is computed for the created particle.
  15276. * @param worldMatrix is the world matrix of the particle system
  15277. * @param positionToUpdate is the position vector to update with the result
  15278. * @param particle is the particle we are computed the position for
  15279. */
  15280. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15281. /**
  15282. * Clones the current emitter and returns a copy of it
  15283. * @returns the new emitter
  15284. */
  15285. clone(): ConeParticleEmitter;
  15286. /**
  15287. * Called by the GPUParticleSystem to setup the update shader
  15288. * @param effect defines the update shader
  15289. */
  15290. applyToShader(effect: Effect): void;
  15291. /**
  15292. * Returns a string to use to update the GPU particles update shader
  15293. * @returns a string containng the defines string
  15294. */
  15295. getEffectDefines(): string;
  15296. /**
  15297. * Returns the string "ConeParticleEmitter"
  15298. * @returns a string containing the class name
  15299. */
  15300. getClassName(): string;
  15301. /**
  15302. * Serializes the particle system to a JSON object.
  15303. * @returns the JSON object
  15304. */
  15305. serialize(): any;
  15306. /**
  15307. * Parse properties from a JSON object
  15308. * @param serializationObject defines the JSON object
  15309. */
  15310. parse(serializationObject: any): void;
  15311. }
  15312. }
  15313. declare module BABYLON {
  15314. /**
  15315. * Particle emitter emitting particles from the inside of a cylinder.
  15316. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15317. */
  15318. export class CylinderParticleEmitter implements IParticleEmitterType {
  15319. /**
  15320. * The radius of the emission cylinder.
  15321. */
  15322. radius: number;
  15323. /**
  15324. * The height of the emission cylinder.
  15325. */
  15326. height: number;
  15327. /**
  15328. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15329. */
  15330. radiusRange: number;
  15331. /**
  15332. * How much to randomize the particle direction [0-1].
  15333. */
  15334. directionRandomizer: number;
  15335. /**
  15336. * Creates a new instance CylinderParticleEmitter
  15337. * @param radius the radius of the emission cylinder (1 by default)
  15338. * @param height the height of the emission cylinder (1 by default)
  15339. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15340. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15341. */
  15342. constructor(
  15343. /**
  15344. * The radius of the emission cylinder.
  15345. */
  15346. radius?: number,
  15347. /**
  15348. * The height of the emission cylinder.
  15349. */
  15350. height?: number,
  15351. /**
  15352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15353. */
  15354. radiusRange?: number,
  15355. /**
  15356. * How much to randomize the particle direction [0-1].
  15357. */
  15358. directionRandomizer?: number);
  15359. /**
  15360. * Called by the particle System when the direction is computed for the created particle.
  15361. * @param worldMatrix is the world matrix of the particle system
  15362. * @param directionToUpdate is the direction vector to update with the result
  15363. * @param particle is the particle we are computed the direction for
  15364. */
  15365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15366. /**
  15367. * Called by the particle System when the position is computed for the created particle.
  15368. * @param worldMatrix is the world matrix of the particle system
  15369. * @param positionToUpdate is the position vector to update with the result
  15370. * @param particle is the particle we are computed the position for
  15371. */
  15372. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15373. /**
  15374. * Clones the current emitter and returns a copy of it
  15375. * @returns the new emitter
  15376. */
  15377. clone(): CylinderParticleEmitter;
  15378. /**
  15379. * Called by the GPUParticleSystem to setup the update shader
  15380. * @param effect defines the update shader
  15381. */
  15382. applyToShader(effect: Effect): void;
  15383. /**
  15384. * Returns a string to use to update the GPU particles update shader
  15385. * @returns a string containng the defines string
  15386. */
  15387. getEffectDefines(): string;
  15388. /**
  15389. * Returns the string "CylinderParticleEmitter"
  15390. * @returns a string containing the class name
  15391. */
  15392. getClassName(): string;
  15393. /**
  15394. * Serializes the particle system to a JSON object.
  15395. * @returns the JSON object
  15396. */
  15397. serialize(): any;
  15398. /**
  15399. * Parse properties from a JSON object
  15400. * @param serializationObject defines the JSON object
  15401. */
  15402. parse(serializationObject: any): void;
  15403. }
  15404. /**
  15405. * Particle emitter emitting particles from the inside of a cylinder.
  15406. * It emits the particles randomly between two vectors.
  15407. */
  15408. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15409. /**
  15410. * The min limit of the emission direction.
  15411. */
  15412. direction1: Vector3;
  15413. /**
  15414. * The max limit of the emission direction.
  15415. */
  15416. direction2: Vector3;
  15417. /**
  15418. * Creates a new instance CylinderDirectedParticleEmitter
  15419. * @param radius the radius of the emission cylinder (1 by default)
  15420. * @param height the height of the emission cylinder (1 by default)
  15421. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15422. * @param direction1 the min limit of the emission direction (up vector by default)
  15423. * @param direction2 the max limit of the emission direction (up vector by default)
  15424. */
  15425. constructor(radius?: number, height?: number, radiusRange?: number,
  15426. /**
  15427. * The min limit of the emission direction.
  15428. */
  15429. direction1?: Vector3,
  15430. /**
  15431. * The max limit of the emission direction.
  15432. */
  15433. direction2?: Vector3);
  15434. /**
  15435. * Called by the particle System when the direction is computed for the created particle.
  15436. * @param worldMatrix is the world matrix of the particle system
  15437. * @param directionToUpdate is the direction vector to update with the result
  15438. * @param particle is the particle we are computed the direction for
  15439. */
  15440. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15441. /**
  15442. * Clones the current emitter and returns a copy of it
  15443. * @returns the new emitter
  15444. */
  15445. clone(): CylinderDirectedParticleEmitter;
  15446. /**
  15447. * Called by the GPUParticleSystem to setup the update shader
  15448. * @param effect defines the update shader
  15449. */
  15450. applyToShader(effect: Effect): void;
  15451. /**
  15452. * Returns a string to use to update the GPU particles update shader
  15453. * @returns a string containng the defines string
  15454. */
  15455. getEffectDefines(): string;
  15456. /**
  15457. * Returns the string "CylinderDirectedParticleEmitter"
  15458. * @returns a string containing the class name
  15459. */
  15460. getClassName(): string;
  15461. /**
  15462. * Serializes the particle system to a JSON object.
  15463. * @returns the JSON object
  15464. */
  15465. serialize(): any;
  15466. /**
  15467. * Parse properties from a JSON object
  15468. * @param serializationObject defines the JSON object
  15469. */
  15470. parse(serializationObject: any): void;
  15471. }
  15472. }
  15473. declare module BABYLON {
  15474. /**
  15475. * Particle emitter emitting particles from the inside of a hemisphere.
  15476. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15477. */
  15478. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15479. /**
  15480. * The radius of the emission hemisphere.
  15481. */
  15482. radius: number;
  15483. /**
  15484. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15485. */
  15486. radiusRange: number;
  15487. /**
  15488. * How much to randomize the particle direction [0-1].
  15489. */
  15490. directionRandomizer: number;
  15491. /**
  15492. * Creates a new instance HemisphericParticleEmitter
  15493. * @param radius the radius of the emission hemisphere (1 by default)
  15494. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15495. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15496. */
  15497. constructor(
  15498. /**
  15499. * The radius of the emission hemisphere.
  15500. */
  15501. radius?: number,
  15502. /**
  15503. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15504. */
  15505. radiusRange?: number,
  15506. /**
  15507. * How much to randomize the particle direction [0-1].
  15508. */
  15509. directionRandomizer?: number);
  15510. /**
  15511. * Called by the particle System when the direction is computed for the created particle.
  15512. * @param worldMatrix is the world matrix of the particle system
  15513. * @param directionToUpdate is the direction vector to update with the result
  15514. * @param particle is the particle we are computed the direction for
  15515. */
  15516. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15517. /**
  15518. * Called by the particle System when the position is computed for the created particle.
  15519. * @param worldMatrix is the world matrix of the particle system
  15520. * @param positionToUpdate is the position vector to update with the result
  15521. * @param particle is the particle we are computed the position for
  15522. */
  15523. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15524. /**
  15525. * Clones the current emitter and returns a copy of it
  15526. * @returns the new emitter
  15527. */
  15528. clone(): HemisphericParticleEmitter;
  15529. /**
  15530. * Called by the GPUParticleSystem to setup the update shader
  15531. * @param effect defines the update shader
  15532. */
  15533. applyToShader(effect: Effect): void;
  15534. /**
  15535. * Returns a string to use to update the GPU particles update shader
  15536. * @returns a string containng the defines string
  15537. */
  15538. getEffectDefines(): string;
  15539. /**
  15540. * Returns the string "HemisphericParticleEmitter"
  15541. * @returns a string containing the class name
  15542. */
  15543. getClassName(): string;
  15544. /**
  15545. * Serializes the particle system to a JSON object.
  15546. * @returns the JSON object
  15547. */
  15548. serialize(): any;
  15549. /**
  15550. * Parse properties from a JSON object
  15551. * @param serializationObject defines the JSON object
  15552. */
  15553. parse(serializationObject: any): void;
  15554. }
  15555. }
  15556. declare module BABYLON {
  15557. /**
  15558. * Particle emitter emitting particles from a point.
  15559. * It emits the particles randomly between 2 given directions.
  15560. */
  15561. export class PointParticleEmitter implements IParticleEmitterType {
  15562. /**
  15563. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15564. */
  15565. direction1: Vector3;
  15566. /**
  15567. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15568. */
  15569. direction2: Vector3;
  15570. /**
  15571. * Creates a new instance PointParticleEmitter
  15572. */
  15573. constructor();
  15574. /**
  15575. * Called by the particle System when the direction is computed for the created particle.
  15576. * @param worldMatrix is the world matrix of the particle system
  15577. * @param directionToUpdate is the direction vector to update with the result
  15578. * @param particle is the particle we are computed the direction for
  15579. */
  15580. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15581. /**
  15582. * Called by the particle System when the position is computed for the created particle.
  15583. * @param worldMatrix is the world matrix of the particle system
  15584. * @param positionToUpdate is the position vector to update with the result
  15585. * @param particle is the particle we are computed the position for
  15586. */
  15587. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15588. /**
  15589. * Clones the current emitter and returns a copy of it
  15590. * @returns the new emitter
  15591. */
  15592. clone(): PointParticleEmitter;
  15593. /**
  15594. * Called by the GPUParticleSystem to setup the update shader
  15595. * @param effect defines the update shader
  15596. */
  15597. applyToShader(effect: Effect): void;
  15598. /**
  15599. * Returns a string to use to update the GPU particles update shader
  15600. * @returns a string containng the defines string
  15601. */
  15602. getEffectDefines(): string;
  15603. /**
  15604. * Returns the string "PointParticleEmitter"
  15605. * @returns a string containing the class name
  15606. */
  15607. getClassName(): string;
  15608. /**
  15609. * Serializes the particle system to a JSON object.
  15610. * @returns the JSON object
  15611. */
  15612. serialize(): any;
  15613. /**
  15614. * Parse properties from a JSON object
  15615. * @param serializationObject defines the JSON object
  15616. */
  15617. parse(serializationObject: any): void;
  15618. }
  15619. }
  15620. declare module BABYLON {
  15621. /**
  15622. * Particle emitter emitting particles from the inside of a sphere.
  15623. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15624. */
  15625. export class SphereParticleEmitter implements IParticleEmitterType {
  15626. /**
  15627. * The radius of the emission sphere.
  15628. */
  15629. radius: number;
  15630. /**
  15631. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15632. */
  15633. radiusRange: number;
  15634. /**
  15635. * How much to randomize the particle direction [0-1].
  15636. */
  15637. directionRandomizer: number;
  15638. /**
  15639. * Creates a new instance SphereParticleEmitter
  15640. * @param radius the radius of the emission sphere (1 by default)
  15641. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15642. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15643. */
  15644. constructor(
  15645. /**
  15646. * The radius of the emission sphere.
  15647. */
  15648. radius?: number,
  15649. /**
  15650. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15651. */
  15652. radiusRange?: number,
  15653. /**
  15654. * How much to randomize the particle direction [0-1].
  15655. */
  15656. directionRandomizer?: number);
  15657. /**
  15658. * Called by the particle System when the direction is computed for the created particle.
  15659. * @param worldMatrix is the world matrix of the particle system
  15660. * @param directionToUpdate is the direction vector to update with the result
  15661. * @param particle is the particle we are computed the direction for
  15662. */
  15663. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15664. /**
  15665. * Called by the particle System when the position is computed for the created particle.
  15666. * @param worldMatrix is the world matrix of the particle system
  15667. * @param positionToUpdate is the position vector to update with the result
  15668. * @param particle is the particle we are computed the position for
  15669. */
  15670. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15671. /**
  15672. * Clones the current emitter and returns a copy of it
  15673. * @returns the new emitter
  15674. */
  15675. clone(): SphereParticleEmitter;
  15676. /**
  15677. * Called by the GPUParticleSystem to setup the update shader
  15678. * @param effect defines the update shader
  15679. */
  15680. applyToShader(effect: Effect): void;
  15681. /**
  15682. * Returns a string to use to update the GPU particles update shader
  15683. * @returns a string containng the defines string
  15684. */
  15685. getEffectDefines(): string;
  15686. /**
  15687. * Returns the string "SphereParticleEmitter"
  15688. * @returns a string containing the class name
  15689. */
  15690. getClassName(): string;
  15691. /**
  15692. * Serializes the particle system to a JSON object.
  15693. * @returns the JSON object
  15694. */
  15695. serialize(): any;
  15696. /**
  15697. * Parse properties from a JSON object
  15698. * @param serializationObject defines the JSON object
  15699. */
  15700. parse(serializationObject: any): void;
  15701. }
  15702. /**
  15703. * Particle emitter emitting particles from the inside of a sphere.
  15704. * It emits the particles randomly between two vectors.
  15705. */
  15706. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15707. /**
  15708. * The min limit of the emission direction.
  15709. */
  15710. direction1: Vector3;
  15711. /**
  15712. * The max limit of the emission direction.
  15713. */
  15714. direction2: Vector3;
  15715. /**
  15716. * Creates a new instance SphereDirectedParticleEmitter
  15717. * @param radius the radius of the emission sphere (1 by default)
  15718. * @param direction1 the min limit of the emission direction (up vector by default)
  15719. * @param direction2 the max limit of the emission direction (up vector by default)
  15720. */
  15721. constructor(radius?: number,
  15722. /**
  15723. * The min limit of the emission direction.
  15724. */
  15725. direction1?: Vector3,
  15726. /**
  15727. * The max limit of the emission direction.
  15728. */
  15729. direction2?: Vector3);
  15730. /**
  15731. * Called by the particle System when the direction is computed for the created particle.
  15732. * @param worldMatrix is the world matrix of the particle system
  15733. * @param directionToUpdate is the direction vector to update with the result
  15734. * @param particle is the particle we are computed the direction for
  15735. */
  15736. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15737. /**
  15738. * Clones the current emitter and returns a copy of it
  15739. * @returns the new emitter
  15740. */
  15741. clone(): SphereDirectedParticleEmitter;
  15742. /**
  15743. * Called by the GPUParticleSystem to setup the update shader
  15744. * @param effect defines the update shader
  15745. */
  15746. applyToShader(effect: Effect): void;
  15747. /**
  15748. * Returns a string to use to update the GPU particles update shader
  15749. * @returns a string containng the defines string
  15750. */
  15751. getEffectDefines(): string;
  15752. /**
  15753. * Returns the string "SphereDirectedParticleEmitter"
  15754. * @returns a string containing the class name
  15755. */
  15756. getClassName(): string;
  15757. /**
  15758. * Serializes the particle system to a JSON object.
  15759. * @returns the JSON object
  15760. */
  15761. serialize(): any;
  15762. /**
  15763. * Parse properties from a JSON object
  15764. * @param serializationObject defines the JSON object
  15765. */
  15766. parse(serializationObject: any): void;
  15767. }
  15768. }
  15769. declare module BABYLON {
  15770. /**
  15771. * Interface representing a particle system in Babylon.js.
  15772. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15773. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15774. */
  15775. export interface IParticleSystem {
  15776. /**
  15777. * List of animations used by the particle system.
  15778. */
  15779. animations: Animation[];
  15780. /**
  15781. * The id of the Particle system.
  15782. */
  15783. id: string;
  15784. /**
  15785. * The name of the Particle system.
  15786. */
  15787. name: string;
  15788. /**
  15789. * The emitter represents the Mesh or position we are attaching the particle system to.
  15790. */
  15791. emitter: Nullable<AbstractMesh | Vector3>;
  15792. /**
  15793. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15794. */
  15795. isBillboardBased: boolean;
  15796. /**
  15797. * The rendering group used by the Particle system to chose when to render.
  15798. */
  15799. renderingGroupId: number;
  15800. /**
  15801. * The layer mask we are rendering the particles through.
  15802. */
  15803. layerMask: number;
  15804. /**
  15805. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15806. */
  15807. updateSpeed: number;
  15808. /**
  15809. * The amount of time the particle system is running (depends of the overall update speed).
  15810. */
  15811. targetStopDuration: number;
  15812. /**
  15813. * The texture used to render each particle. (this can be a spritesheet)
  15814. */
  15815. particleTexture: Nullable<Texture>;
  15816. /**
  15817. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15818. */
  15819. blendMode: number;
  15820. /**
  15821. * Minimum life time of emitting particles.
  15822. */
  15823. minLifeTime: number;
  15824. /**
  15825. * Maximum life time of emitting particles.
  15826. */
  15827. maxLifeTime: number;
  15828. /**
  15829. * Minimum Size of emitting particles.
  15830. */
  15831. minSize: number;
  15832. /**
  15833. * Maximum Size of emitting particles.
  15834. */
  15835. maxSize: number;
  15836. /**
  15837. * Minimum scale of emitting particles on X axis.
  15838. */
  15839. minScaleX: number;
  15840. /**
  15841. * Maximum scale of emitting particles on X axis.
  15842. */
  15843. maxScaleX: number;
  15844. /**
  15845. * Minimum scale of emitting particles on Y axis.
  15846. */
  15847. minScaleY: number;
  15848. /**
  15849. * Maximum scale of emitting particles on Y axis.
  15850. */
  15851. maxScaleY: number;
  15852. /**
  15853. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15854. */
  15855. color1: Color4;
  15856. /**
  15857. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15858. */
  15859. color2: Color4;
  15860. /**
  15861. * Color the particle will have at the end of its lifetime.
  15862. */
  15863. colorDead: Color4;
  15864. /**
  15865. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15866. */
  15867. emitRate: number;
  15868. /**
  15869. * You can use gravity if you want to give an orientation to your particles.
  15870. */
  15871. gravity: Vector3;
  15872. /**
  15873. * Minimum power of emitting particles.
  15874. */
  15875. minEmitPower: number;
  15876. /**
  15877. * Maximum power of emitting particles.
  15878. */
  15879. maxEmitPower: number;
  15880. /**
  15881. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15882. */
  15883. minAngularSpeed: number;
  15884. /**
  15885. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15886. */
  15887. maxAngularSpeed: number;
  15888. /**
  15889. * Gets or sets the minimal initial rotation in radians.
  15890. */
  15891. minInitialRotation: number;
  15892. /**
  15893. * Gets or sets the maximal initial rotation in radians.
  15894. */
  15895. maxInitialRotation: number;
  15896. /**
  15897. * The particle emitter type defines the emitter used by the particle system.
  15898. * It can be for example box, sphere, or cone...
  15899. */
  15900. particleEmitterType: Nullable<IParticleEmitterType>;
  15901. /**
  15902. * Defines the delay in milliseconds before starting the system (0 by default)
  15903. */
  15904. startDelay: number;
  15905. /**
  15906. * 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
  15907. */
  15908. preWarmCycles: number;
  15909. /**
  15910. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15911. */
  15912. preWarmStepOffset: number;
  15913. /**
  15914. * 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)
  15915. */
  15916. spriteCellChangeSpeed: number;
  15917. /**
  15918. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15919. */
  15920. startSpriteCellID: number;
  15921. /**
  15922. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15923. */
  15924. endSpriteCellID: number;
  15925. /**
  15926. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15927. */
  15928. spriteCellWidth: number;
  15929. /**
  15930. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15931. */
  15932. spriteCellHeight: number;
  15933. /**
  15934. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15935. */
  15936. spriteRandomStartCell: boolean;
  15937. /**
  15938. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15939. */
  15940. isAnimationSheetEnabled: boolean;
  15941. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15942. translationPivot: Vector2;
  15943. /**
  15944. * Gets or sets a texture used to add random noise to particle positions
  15945. */
  15946. noiseTexture: Nullable<BaseTexture>;
  15947. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15948. noiseStrength: Vector3;
  15949. /**
  15950. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15951. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15952. */
  15953. billboardMode: number;
  15954. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15955. limitVelocityDamping: number;
  15956. /**
  15957. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15958. */
  15959. beginAnimationOnStart: boolean;
  15960. /**
  15961. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15962. */
  15963. beginAnimationFrom: number;
  15964. /**
  15965. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15966. */
  15967. beginAnimationTo: number;
  15968. /**
  15969. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15970. */
  15971. beginAnimationLoop: boolean;
  15972. /**
  15973. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15974. */
  15975. disposeOnStop: boolean;
  15976. /**
  15977. * Gets the maximum number of particles active at the same time.
  15978. * @returns The max number of active particles.
  15979. */
  15980. getCapacity(): number;
  15981. /**
  15982. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15983. * @returns True if it has been started, otherwise false.
  15984. */
  15985. isStarted(): boolean;
  15986. /**
  15987. * Animates the particle system for this frame.
  15988. */
  15989. animate(): void;
  15990. /**
  15991. * Renders the particle system in its current state.
  15992. * @returns the current number of particles
  15993. */
  15994. render(): number;
  15995. /**
  15996. * Dispose the particle system and frees its associated resources.
  15997. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15998. */
  15999. dispose(disposeTexture?: boolean): void;
  16000. /**
  16001. * Clones the particle system.
  16002. * @param name The name of the cloned object
  16003. * @param newEmitter The new emitter to use
  16004. * @returns the cloned particle system
  16005. */
  16006. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16007. /**
  16008. * Serializes the particle system to a JSON object.
  16009. * @returns the JSON object
  16010. */
  16011. serialize(): any;
  16012. /**
  16013. * Rebuild the particle system
  16014. */
  16015. rebuild(): void;
  16016. /**
  16017. * Starts the particle system and begins to emit
  16018. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16019. */
  16020. start(delay?: number): void;
  16021. /**
  16022. * Stops the particle system.
  16023. */
  16024. stop(): void;
  16025. /**
  16026. * Remove all active particles
  16027. */
  16028. reset(): void;
  16029. /**
  16030. * Is this system ready to be used/rendered
  16031. * @return true if the system is ready
  16032. */
  16033. isReady(): boolean;
  16034. /**
  16035. * Adds a new color gradient
  16036. * @param gradient defines the gradient to use (between 0 and 1)
  16037. * @param color1 defines the color to affect to the specified gradient
  16038. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16039. * @returns the current particle system
  16040. */
  16041. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16042. /**
  16043. * Remove a specific color gradient
  16044. * @param gradient defines the gradient to remove
  16045. * @returns the current particle system
  16046. */
  16047. removeColorGradient(gradient: number): IParticleSystem;
  16048. /**
  16049. * Adds a new size gradient
  16050. * @param gradient defines the gradient to use (between 0 and 1)
  16051. * @param factor defines the size factor to affect to the specified gradient
  16052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16053. * @returns the current particle system
  16054. */
  16055. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16056. /**
  16057. * Remove a specific size gradient
  16058. * @param gradient defines the gradient to remove
  16059. * @returns the current particle system
  16060. */
  16061. removeSizeGradient(gradient: number): IParticleSystem;
  16062. /**
  16063. * Gets the current list of color gradients.
  16064. * You must use addColorGradient and removeColorGradient to udpate this list
  16065. * @returns the list of color gradients
  16066. */
  16067. getColorGradients(): Nullable<Array<ColorGradient>>;
  16068. /**
  16069. * Gets the current list of size gradients.
  16070. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16071. * @returns the list of size gradients
  16072. */
  16073. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16074. /**
  16075. * Gets the current list of angular speed gradients.
  16076. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16077. * @returns the list of angular speed gradients
  16078. */
  16079. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16080. /**
  16081. * Adds a new angular speed gradient
  16082. * @param gradient defines the gradient to use (between 0 and 1)
  16083. * @param factor defines the angular speed to affect to the specified gradient
  16084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16085. * @returns the current particle system
  16086. */
  16087. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16088. /**
  16089. * Remove a specific angular speed gradient
  16090. * @param gradient defines the gradient to remove
  16091. * @returns the current particle system
  16092. */
  16093. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16094. /**
  16095. * Gets the current list of velocity gradients.
  16096. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16097. * @returns the list of velocity gradients
  16098. */
  16099. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16100. /**
  16101. * Adds a new velocity gradient
  16102. * @param gradient defines the gradient to use (between 0 and 1)
  16103. * @param factor defines the velocity to affect to the specified gradient
  16104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16105. * @returns the current particle system
  16106. */
  16107. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16108. /**
  16109. * Remove a specific velocity gradient
  16110. * @param gradient defines the gradient to remove
  16111. * @returns the current particle system
  16112. */
  16113. removeVelocityGradient(gradient: number): IParticleSystem;
  16114. /**
  16115. * Gets the current list of limit velocity gradients.
  16116. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16117. * @returns the list of limit velocity gradients
  16118. */
  16119. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16120. /**
  16121. * Adds a new limit velocity gradient
  16122. * @param gradient defines the gradient to use (between 0 and 1)
  16123. * @param factor defines the limit velocity to affect to the specified gradient
  16124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16125. * @returns the current particle system
  16126. */
  16127. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16128. /**
  16129. * Remove a specific limit velocity gradient
  16130. * @param gradient defines the gradient to remove
  16131. * @returns the current particle system
  16132. */
  16133. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16134. /**
  16135. * Adds a new drag gradient
  16136. * @param gradient defines the gradient to use (between 0 and 1)
  16137. * @param factor defines the drag to affect to the specified gradient
  16138. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16139. * @returns the current particle system
  16140. */
  16141. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16142. /**
  16143. * Remove a specific drag gradient
  16144. * @param gradient defines the gradient to remove
  16145. * @returns the current particle system
  16146. */
  16147. removeDragGradient(gradient: number): IParticleSystem;
  16148. /**
  16149. * Gets the current list of drag gradients.
  16150. * You must use addDragGradient and removeDragGradient to udpate this list
  16151. * @returns the list of drag gradients
  16152. */
  16153. getDragGradients(): Nullable<Array<FactorGradient>>;
  16154. /**
  16155. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16156. * @param gradient defines the gradient to use (between 0 and 1)
  16157. * @param factor defines the emit rate to affect to the specified gradient
  16158. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16159. * @returns the current particle system
  16160. */
  16161. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16162. /**
  16163. * Remove a specific emit rate gradient
  16164. * @param gradient defines the gradient to remove
  16165. * @returns the current particle system
  16166. */
  16167. removeEmitRateGradient(gradient: number): IParticleSystem;
  16168. /**
  16169. * Gets the current list of emit rate gradients.
  16170. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16171. * @returns the list of emit rate gradients
  16172. */
  16173. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16174. /**
  16175. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16176. * @param gradient defines the gradient to use (between 0 and 1)
  16177. * @param factor defines the start size to affect to the specified gradient
  16178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16179. * @returns the current particle system
  16180. */
  16181. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16182. /**
  16183. * Remove a specific start size gradient
  16184. * @param gradient defines the gradient to remove
  16185. * @returns the current particle system
  16186. */
  16187. removeStartSizeGradient(gradient: number): IParticleSystem;
  16188. /**
  16189. * Gets the current list of start size gradients.
  16190. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16191. * @returns the list of start size gradients
  16192. */
  16193. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16194. /**
  16195. * Adds a new life time gradient
  16196. * @param gradient defines the gradient to use (between 0 and 1)
  16197. * @param factor defines the life time factor to affect to the specified gradient
  16198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16199. * @returns the current particle system
  16200. */
  16201. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16202. /**
  16203. * Remove a specific life time gradient
  16204. * @param gradient defines the gradient to remove
  16205. * @returns the current particle system
  16206. */
  16207. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16208. /**
  16209. * Gets the current list of life time gradients.
  16210. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16211. * @returns the list of life time gradients
  16212. */
  16213. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16214. /**
  16215. * Gets the current list of color gradients.
  16216. * You must use addColorGradient and removeColorGradient to udpate this list
  16217. * @returns the list of color gradients
  16218. */
  16219. getColorGradients(): Nullable<Array<ColorGradient>>;
  16220. /**
  16221. * Adds a new ramp gradient used to remap particle colors
  16222. * @param gradient defines the gradient to use (between 0 and 1)
  16223. * @param color defines the color to affect to the specified gradient
  16224. * @returns the current particle system
  16225. */
  16226. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16227. /**
  16228. * Gets the current list of ramp gradients.
  16229. * You must use addRampGradient and removeRampGradient to udpate this list
  16230. * @returns the list of ramp gradients
  16231. */
  16232. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16233. /** Gets or sets a boolean indicating that ramp gradients must be used
  16234. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16235. */
  16236. useRampGradients: boolean;
  16237. /**
  16238. * Adds a new color remap gradient
  16239. * @param gradient defines the gradient to use (between 0 and 1)
  16240. * @param min defines the color remap minimal range
  16241. * @param max defines the color remap maximal range
  16242. * @returns the current particle system
  16243. */
  16244. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16245. /**
  16246. * Gets the current list of color remap gradients.
  16247. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16248. * @returns the list of color remap gradients
  16249. */
  16250. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16251. /**
  16252. * Adds a new alpha remap gradient
  16253. * @param gradient defines the gradient to use (between 0 and 1)
  16254. * @param min defines the alpha remap minimal range
  16255. * @param max defines the alpha remap maximal range
  16256. * @returns the current particle system
  16257. */
  16258. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16259. /**
  16260. * Gets the current list of alpha remap gradients.
  16261. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16262. * @returns the list of alpha remap gradients
  16263. */
  16264. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16265. /**
  16266. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16267. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16268. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16269. * @returns the emitter
  16270. */
  16271. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16272. /**
  16273. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16274. * @param radius The radius of the hemisphere to emit from
  16275. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16276. * @returns the emitter
  16277. */
  16278. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16279. /**
  16280. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16281. * @param radius The radius of the sphere to emit from
  16282. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16283. * @returns the emitter
  16284. */
  16285. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16286. /**
  16287. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16288. * @param radius The radius of the sphere to emit from
  16289. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16290. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16291. * @returns the emitter
  16292. */
  16293. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16294. /**
  16295. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16296. * @param radius The radius of the emission cylinder
  16297. * @param height The height of the emission cylinder
  16298. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16299. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16300. * @returns the emitter
  16301. */
  16302. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16303. /**
  16304. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16305. * @param radius The radius of the cylinder to emit from
  16306. * @param height The height of the emission cylinder
  16307. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16308. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16309. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16310. * @returns the emitter
  16311. */
  16312. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16313. /**
  16314. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16315. * @param radius The radius of the cone to emit from
  16316. * @param angle The base angle of the cone
  16317. * @returns the emitter
  16318. */
  16319. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16320. /**
  16321. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16322. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16323. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16324. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16325. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16326. * @returns the emitter
  16327. */
  16328. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16329. /**
  16330. * Get hosting scene
  16331. * @returns the scene
  16332. */
  16333. getScene(): Scene;
  16334. }
  16335. }
  16336. declare module BABYLON {
  16337. /** @hidden */
  16338. export var linePixelShader: {
  16339. name: string;
  16340. shader: string;
  16341. };
  16342. }
  16343. declare module BABYLON {
  16344. /** @hidden */
  16345. export var lineVertexShader: {
  16346. name: string;
  16347. shader: string;
  16348. };
  16349. }
  16350. declare module BABYLON {
  16351. interface AbstractMesh {
  16352. /**
  16353. * Disables the mesh edge rendering mode
  16354. * @returns the currentAbstractMesh
  16355. */
  16356. disableEdgesRendering(): AbstractMesh;
  16357. /**
  16358. * Enables the edge rendering mode on the mesh.
  16359. * This mode makes the mesh edges visible
  16360. * @param epsilon defines the maximal distance between two angles to detect a face
  16361. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16362. * @returns the currentAbstractMesh
  16363. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16364. */
  16365. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16366. /**
  16367. * Gets the edgesRenderer associated with the mesh
  16368. */
  16369. edgesRenderer: Nullable<EdgesRenderer>;
  16370. }
  16371. interface LinesMesh {
  16372. /**
  16373. * Enables the edge rendering mode on the mesh.
  16374. * This mode makes the mesh edges visible
  16375. * @param epsilon defines the maximal distance between two angles to detect a face
  16376. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16377. * @returns the currentAbstractMesh
  16378. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16379. */
  16380. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16381. }
  16382. interface InstancedLinesMesh {
  16383. /**
  16384. * Enables the edge rendering mode on the mesh.
  16385. * This mode makes the mesh edges visible
  16386. * @param epsilon defines the maximal distance between two angles to detect a face
  16387. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16388. * @returns the current InstancedLinesMesh
  16389. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16390. */
  16391. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16392. }
  16393. /**
  16394. * Defines the minimum contract an Edges renderer should follow.
  16395. */
  16396. export interface IEdgesRenderer extends IDisposable {
  16397. /**
  16398. * Gets or sets a boolean indicating if the edgesRenderer is active
  16399. */
  16400. isEnabled: boolean;
  16401. /**
  16402. * Renders the edges of the attached mesh,
  16403. */
  16404. render(): void;
  16405. /**
  16406. * Checks wether or not the edges renderer is ready to render.
  16407. * @return true if ready, otherwise false.
  16408. */
  16409. isReady(): boolean;
  16410. }
  16411. /**
  16412. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16413. */
  16414. export class EdgesRenderer implements IEdgesRenderer {
  16415. /**
  16416. * Define the size of the edges with an orthographic camera
  16417. */
  16418. edgesWidthScalerForOrthographic: number;
  16419. /**
  16420. * Define the size of the edges with a perspective camera
  16421. */
  16422. edgesWidthScalerForPerspective: number;
  16423. protected _source: AbstractMesh;
  16424. protected _linesPositions: number[];
  16425. protected _linesNormals: number[];
  16426. protected _linesIndices: number[];
  16427. protected _epsilon: number;
  16428. protected _indicesCount: number;
  16429. protected _lineShader: ShaderMaterial;
  16430. protected _ib: WebGLBuffer;
  16431. protected _buffers: {
  16432. [key: string]: Nullable<VertexBuffer>;
  16433. };
  16434. protected _checkVerticesInsteadOfIndices: boolean;
  16435. private _meshRebuildObserver;
  16436. private _meshDisposeObserver;
  16437. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16438. isEnabled: boolean;
  16439. /**
  16440. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16441. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16442. * @param source Mesh used to create edges
  16443. * @param epsilon sum of angles in adjacency to check for edge
  16444. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16445. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16446. */
  16447. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16448. protected _prepareRessources(): void;
  16449. /** @hidden */ rebuild(): void;
  16450. /**
  16451. * Releases the required resources for the edges renderer
  16452. */
  16453. dispose(): void;
  16454. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16455. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16456. /**
  16457. * Checks if the pair of p0 and p1 is en edge
  16458. * @param faceIndex
  16459. * @param edge
  16460. * @param faceNormals
  16461. * @param p0
  16462. * @param p1
  16463. * @private
  16464. */
  16465. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16466. /**
  16467. * push line into the position, normal and index buffer
  16468. * @protected
  16469. */
  16470. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16471. /**
  16472. * Generates lines edges from adjacencjes
  16473. * @private
  16474. */ generateEdgesLines(): void;
  16475. /**
  16476. * Checks wether or not the edges renderer is ready to render.
  16477. * @return true if ready, otherwise false.
  16478. */
  16479. isReady(): boolean;
  16480. /**
  16481. * Renders the edges of the attached mesh,
  16482. */
  16483. render(): void;
  16484. }
  16485. /**
  16486. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16487. */
  16488. export class LineEdgesRenderer extends EdgesRenderer {
  16489. /**
  16490. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16491. * @param source LineMesh used to generate edges
  16492. * @param epsilon not important (specified angle for edge detection)
  16493. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16494. */
  16495. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16496. /**
  16497. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16498. */ generateEdgesLines(): void;
  16499. }
  16500. }
  16501. declare module BABYLON {
  16502. /**
  16503. * This represents the object necessary to create a rendering group.
  16504. * This is exclusively used and created by the rendering manager.
  16505. * To modify the behavior, you use the available helpers in your scene or meshes.
  16506. * @hidden
  16507. */
  16508. export class RenderingGroup {
  16509. index: number;
  16510. private _scene;
  16511. private _opaqueSubMeshes;
  16512. private _transparentSubMeshes;
  16513. private _alphaTestSubMeshes;
  16514. private _depthOnlySubMeshes;
  16515. private _particleSystems;
  16516. private _spriteManagers;
  16517. private _opaqueSortCompareFn;
  16518. private _alphaTestSortCompareFn;
  16519. private _transparentSortCompareFn;
  16520. private _renderOpaque;
  16521. private _renderAlphaTest;
  16522. private _renderTransparent;
  16523. private _edgesRenderers;
  16524. onBeforeTransparentRendering: () => void;
  16525. /**
  16526. * Set the opaque sort comparison function.
  16527. * If null the sub meshes will be render in the order they were created
  16528. */
  16529. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16530. /**
  16531. * Set the alpha test sort comparison function.
  16532. * If null the sub meshes will be render in the order they were created
  16533. */
  16534. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16535. /**
  16536. * Set the transparent sort comparison function.
  16537. * If null the sub meshes will be render in the order they were created
  16538. */
  16539. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16540. /**
  16541. * Creates a new rendering group.
  16542. * @param index The rendering group index
  16543. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16544. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16545. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16546. */
  16547. 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>);
  16548. /**
  16549. * Render all the sub meshes contained in the group.
  16550. * @param customRenderFunction Used to override the default render behaviour of the group.
  16551. * @returns true if rendered some submeshes.
  16552. */
  16553. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16554. /**
  16555. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16556. * @param subMeshes The submeshes to render
  16557. */
  16558. private renderOpaqueSorted;
  16559. /**
  16560. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16561. * @param subMeshes The submeshes to render
  16562. */
  16563. private renderAlphaTestSorted;
  16564. /**
  16565. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16566. * @param subMeshes The submeshes to render
  16567. */
  16568. private renderTransparentSorted;
  16569. /**
  16570. * Renders the submeshes in a specified order.
  16571. * @param subMeshes The submeshes to sort before render
  16572. * @param sortCompareFn The comparison function use to sort
  16573. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16574. * @param transparent Specifies to activate blending if true
  16575. */
  16576. private static renderSorted;
  16577. /**
  16578. * Renders the submeshes in the order they were dispatched (no sort applied).
  16579. * @param subMeshes The submeshes to render
  16580. */
  16581. private static renderUnsorted;
  16582. /**
  16583. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16584. * are rendered back to front if in the same alpha index.
  16585. *
  16586. * @param a The first submesh
  16587. * @param b The second submesh
  16588. * @returns The result of the comparison
  16589. */
  16590. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16591. /**
  16592. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16593. * are rendered back to front.
  16594. *
  16595. * @param a The first submesh
  16596. * @param b The second submesh
  16597. * @returns The result of the comparison
  16598. */
  16599. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16600. /**
  16601. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16602. * are rendered front to back (prevent overdraw).
  16603. *
  16604. * @param a The first submesh
  16605. * @param b The second submesh
  16606. * @returns The result of the comparison
  16607. */
  16608. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16609. /**
  16610. * Resets the different lists of submeshes to prepare a new frame.
  16611. */
  16612. prepare(): void;
  16613. dispose(): void;
  16614. /**
  16615. * Inserts the submesh in its correct queue depending on its material.
  16616. * @param subMesh The submesh to dispatch
  16617. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16618. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16619. */
  16620. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16621. dispatchSprites(spriteManager: ISpriteManager): void;
  16622. dispatchParticles(particleSystem: IParticleSystem): void;
  16623. private _renderParticles;
  16624. private _renderSprites;
  16625. }
  16626. }
  16627. declare module BABYLON {
  16628. /**
  16629. * Interface describing the different options available in the rendering manager
  16630. * regarding Auto Clear between groups.
  16631. */
  16632. export interface IRenderingManagerAutoClearSetup {
  16633. /**
  16634. * Defines whether or not autoclear is enable.
  16635. */
  16636. autoClear: boolean;
  16637. /**
  16638. * Defines whether or not to autoclear the depth buffer.
  16639. */
  16640. depth: boolean;
  16641. /**
  16642. * Defines whether or not to autoclear the stencil buffer.
  16643. */
  16644. stencil: boolean;
  16645. }
  16646. /**
  16647. * This class is used by the onRenderingGroupObservable
  16648. */
  16649. export class RenderingGroupInfo {
  16650. /**
  16651. * The Scene that being rendered
  16652. */
  16653. scene: Scene;
  16654. /**
  16655. * The camera currently used for the rendering pass
  16656. */
  16657. camera: Nullable<Camera>;
  16658. /**
  16659. * The ID of the renderingGroup being processed
  16660. */
  16661. renderingGroupId: number;
  16662. }
  16663. /**
  16664. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16665. * It is enable to manage the different groups as well as the different necessary sort functions.
  16666. * This should not be used directly aside of the few static configurations
  16667. */
  16668. export class RenderingManager {
  16669. /**
  16670. * The max id used for rendering groups (not included)
  16671. */
  16672. static MAX_RENDERINGGROUPS: number;
  16673. /**
  16674. * The min id used for rendering groups (included)
  16675. */
  16676. static MIN_RENDERINGGROUPS: number;
  16677. /**
  16678. * Used to globally prevent autoclearing scenes.
  16679. */
  16680. static AUTOCLEAR: boolean;
  16681. /**
  16682. * @hidden
  16683. */ useSceneAutoClearSetup: boolean;
  16684. private _scene;
  16685. private _renderingGroups;
  16686. private _depthStencilBufferAlreadyCleaned;
  16687. private _autoClearDepthStencil;
  16688. private _customOpaqueSortCompareFn;
  16689. private _customAlphaTestSortCompareFn;
  16690. private _customTransparentSortCompareFn;
  16691. private _renderingGroupInfo;
  16692. /**
  16693. * Instantiates a new rendering group for a particular scene
  16694. * @param scene Defines the scene the groups belongs to
  16695. */
  16696. constructor(scene: Scene);
  16697. private _clearDepthStencilBuffer;
  16698. /**
  16699. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16700. * @hidden
  16701. */
  16702. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16703. /**
  16704. * Resets the different information of the group to prepare a new frame
  16705. * @hidden
  16706. */
  16707. reset(): void;
  16708. /**
  16709. * Dispose and release the group and its associated resources.
  16710. * @hidden
  16711. */
  16712. dispose(): void;
  16713. /**
  16714. * Clear the info related to rendering groups preventing retention points during dispose.
  16715. */
  16716. freeRenderingGroups(): void;
  16717. private _prepareRenderingGroup;
  16718. /**
  16719. * Add a sprite manager to the rendering manager in order to render it this frame.
  16720. * @param spriteManager Define the sprite manager to render
  16721. */
  16722. dispatchSprites(spriteManager: ISpriteManager): void;
  16723. /**
  16724. * Add a particle system to the rendering manager in order to render it this frame.
  16725. * @param particleSystem Define the particle system to render
  16726. */
  16727. dispatchParticles(particleSystem: IParticleSystem): void;
  16728. /**
  16729. * Add a submesh to the manager in order to render it this frame
  16730. * @param subMesh The submesh to dispatch
  16731. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16732. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16733. */
  16734. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16735. /**
  16736. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16737. * This allowed control for front to back rendering or reversly depending of the special needs.
  16738. *
  16739. * @param renderingGroupId The rendering group id corresponding to its index
  16740. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16741. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16742. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16743. */
  16744. 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;
  16745. /**
  16746. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16747. *
  16748. * @param renderingGroupId The rendering group id corresponding to its index
  16749. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16750. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16751. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16752. */
  16753. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16754. /**
  16755. * Gets the current auto clear configuration for one rendering group of the rendering
  16756. * manager.
  16757. * @param index the rendering group index to get the information for
  16758. * @returns The auto clear setup for the requested rendering group
  16759. */
  16760. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16761. }
  16762. }
  16763. declare module BABYLON {
  16764. /**
  16765. * This Helps creating a texture that will be created from a camera in your scene.
  16766. * It is basically a dynamic texture that could be used to create special effects for instance.
  16767. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  16768. */
  16769. export class RenderTargetTexture extends Texture {
  16770. isCube: boolean;
  16771. /**
  16772. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  16773. */
  16774. static readonly REFRESHRATE_RENDER_ONCE: number;
  16775. /**
  16776. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  16777. */
  16778. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  16779. /**
  16780. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  16781. * the central point of your effect and can save a lot of performances.
  16782. */
  16783. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  16784. /**
  16785. * Use this predicate to dynamically define the list of mesh you want to render.
  16786. * If set, the renderList property will be overwritten.
  16787. */
  16788. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  16789. private _renderList;
  16790. /**
  16791. * Use this list to define the list of mesh you want to render.
  16792. */
  16793. renderList: Nullable<Array<AbstractMesh>>;
  16794. private _hookArray;
  16795. /**
  16796. * Define if particles should be rendered in your texture.
  16797. */
  16798. renderParticles: boolean;
  16799. /**
  16800. * Define if sprites should be rendered in your texture.
  16801. */
  16802. renderSprites: boolean;
  16803. /**
  16804. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  16805. */
  16806. coordinatesMode: number;
  16807. /**
  16808. * Define the camera used to render the texture.
  16809. */
  16810. activeCamera: Nullable<Camera>;
  16811. /**
  16812. * Override the render function of the texture with your own one.
  16813. */
  16814. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  16815. /**
  16816. * Define if camera post processes should be use while rendering the texture.
  16817. */
  16818. useCameraPostProcesses: boolean;
  16819. /**
  16820. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  16821. */
  16822. ignoreCameraViewport: boolean;
  16823. private _postProcessManager;
  16824. private _postProcesses;
  16825. private _resizeObserver;
  16826. /**
  16827. * An event triggered when the texture is unbind.
  16828. */
  16829. onBeforeBindObservable: Observable<RenderTargetTexture>;
  16830. /**
  16831. * An event triggered when the texture is unbind.
  16832. */
  16833. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  16834. private _onAfterUnbindObserver;
  16835. /**
  16836. * Set a after unbind callback in the texture.
  16837. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  16838. */
  16839. onAfterUnbind: () => void;
  16840. /**
  16841. * An event triggered before rendering the texture
  16842. */
  16843. onBeforeRenderObservable: Observable<number>;
  16844. private _onBeforeRenderObserver;
  16845. /**
  16846. * Set a before render callback in the texture.
  16847. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  16848. */
  16849. onBeforeRender: (faceIndex: number) => void;
  16850. /**
  16851. * An event triggered after rendering the texture
  16852. */
  16853. onAfterRenderObservable: Observable<number>;
  16854. private _onAfterRenderObserver;
  16855. /**
  16856. * Set a after render callback in the texture.
  16857. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  16858. */
  16859. onAfterRender: (faceIndex: number) => void;
  16860. /**
  16861. * An event triggered after the texture clear
  16862. */
  16863. onClearObservable: Observable<Engine>;
  16864. private _onClearObserver;
  16865. /**
  16866. * Set a clear callback in the texture.
  16867. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  16868. */
  16869. onClear: (Engine: Engine) => void;
  16870. /**
  16871. * Define the clear color of the Render Target if it should be different from the scene.
  16872. */
  16873. clearColor: Color4;
  16874. protected _size: number | {
  16875. width: number;
  16876. height: number;
  16877. };
  16878. protected _initialSizeParameter: number | {
  16879. width: number;
  16880. height: number;
  16881. } | {
  16882. ratio: number;
  16883. };
  16884. protected _sizeRatio: Nullable<number>;
  16885. /** @hidden */ generateMipMaps: boolean;
  16886. protected _renderingManager: RenderingManager;
  16887. /** @hidden */ waitingRenderList: string[];
  16888. protected _doNotChangeAspectRatio: boolean;
  16889. protected _currentRefreshId: number;
  16890. protected _refreshRate: number;
  16891. protected _textureMatrix: Matrix;
  16892. protected _samples: number;
  16893. protected _renderTargetOptions: RenderTargetCreationOptions;
  16894. /**
  16895. * Gets render target creation options that were used.
  16896. */
  16897. readonly renderTargetOptions: RenderTargetCreationOptions;
  16898. protected _engine: Engine;
  16899. protected _onRatioRescale(): void;
  16900. /**
  16901. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  16902. * It must define where the camera used to render the texture is set
  16903. */
  16904. boundingBoxPosition: Vector3;
  16905. private _boundingBoxSize;
  16906. /**
  16907. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  16908. * When defined, the cubemap will switch to local mode
  16909. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  16910. * @example https://www.babylonjs-playground.com/#RNASML
  16911. */
  16912. boundingBoxSize: Vector3;
  16913. /**
  16914. * In case the RTT has been created with a depth texture, get the associated
  16915. * depth texture.
  16916. * Otherwise, return null.
  16917. */
  16918. depthStencilTexture: Nullable<InternalTexture>;
  16919. /**
  16920. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  16921. * or used a shadow, depth texture...
  16922. * @param name The friendly name of the texture
  16923. * @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)
  16924. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  16925. * @param generateMipMaps True if mip maps need to be generated after render.
  16926. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  16927. * @param type The type of the buffer in the RTT (int, half float, float...)
  16928. * @param isCube True if a cube texture needs to be created
  16929. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  16930. * @param generateDepthBuffer True to generate a depth buffer
  16931. * @param generateStencilBuffer True to generate a stencil buffer
  16932. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  16933. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  16934. * @param delayAllocation if the texture allocation should be delayed (default: false)
  16935. */
  16936. constructor(name: string, size: number | {
  16937. width: number;
  16938. height: number;
  16939. } | {
  16940. ratio: number;
  16941. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  16942. /**
  16943. * Creates a depth stencil texture.
  16944. * This is only available in WebGL 2 or with the depth texture extension available.
  16945. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  16946. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  16947. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  16948. */
  16949. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  16950. private _processSizeParameter;
  16951. /**
  16952. * Define the number of samples to use in case of MSAA.
  16953. * It defaults to one meaning no MSAA has been enabled.
  16954. */
  16955. samples: number;
  16956. /**
  16957. * Resets the refresh counter of the texture and start bak from scratch.
  16958. * Could be useful to regenerate the texture if it is setup to render only once.
  16959. */
  16960. resetRefreshCounter(): void;
  16961. /**
  16962. * Define the refresh rate of the texture or the rendering frequency.
  16963. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16964. */
  16965. refreshRate: number;
  16966. /**
  16967. * Adds a post process to the render target rendering passes.
  16968. * @param postProcess define the post process to add
  16969. */
  16970. addPostProcess(postProcess: PostProcess): void;
  16971. /**
  16972. * Clear all the post processes attached to the render target
  16973. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  16974. */
  16975. clearPostProcesses(dispose?: boolean): void;
  16976. /**
  16977. * Remove one of the post process from the list of attached post processes to the texture
  16978. * @param postProcess define the post process to remove from the list
  16979. */
  16980. removePostProcess(postProcess: PostProcess): void;
  16981. /** @hidden */ shouldRender(): boolean;
  16982. /**
  16983. * Gets the actual render size of the texture.
  16984. * @returns the width of the render size
  16985. */
  16986. getRenderSize(): number;
  16987. /**
  16988. * Gets the actual render width of the texture.
  16989. * @returns the width of the render size
  16990. */
  16991. getRenderWidth(): number;
  16992. /**
  16993. * Gets the actual render height of the texture.
  16994. * @returns the height of the render size
  16995. */
  16996. getRenderHeight(): number;
  16997. /**
  16998. * Get if the texture can be rescaled or not.
  16999. */
  17000. readonly canRescale: boolean;
  17001. /**
  17002. * Resize the texture using a ratio.
  17003. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17004. */
  17005. scale(ratio: number): void;
  17006. /**
  17007. * Get the texture reflection matrix used to rotate/transform the reflection.
  17008. * @returns the reflection matrix
  17009. */
  17010. getReflectionTextureMatrix(): Matrix;
  17011. /**
  17012. * Resize the texture to a new desired size.
  17013. * Be carrefull as it will recreate all the data in the new texture.
  17014. * @param size Define the new size. It can be:
  17015. * - a number for squared texture,
  17016. * - an object containing { width: number, height: number }
  17017. * - or an object containing a ratio { ratio: number }
  17018. */
  17019. resize(size: number | {
  17020. width: number;
  17021. height: number;
  17022. } | {
  17023. ratio: number;
  17024. }): void;
  17025. /**
  17026. * Renders all the objects from the render list into the texture.
  17027. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17028. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17029. */
  17030. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17031. private _bestReflectionRenderTargetDimension;
  17032. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17033. private renderToTarget;
  17034. /**
  17035. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17036. * This allowed control for front to back rendering or reversly depending of the special needs.
  17037. *
  17038. * @param renderingGroupId The rendering group id corresponding to its index
  17039. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17040. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17041. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17042. */
  17043. 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;
  17044. /**
  17045. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17046. *
  17047. * @param renderingGroupId The rendering group id corresponding to its index
  17048. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17049. */
  17050. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17051. /**
  17052. * Clones the texture.
  17053. * @returns the cloned texture
  17054. */
  17055. clone(): RenderTargetTexture;
  17056. /**
  17057. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17058. * @returns The JSON representation of the texture
  17059. */
  17060. serialize(): any;
  17061. /**
  17062. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17063. */
  17064. disposeFramebufferObjects(): void;
  17065. /**
  17066. * Dispose the texture and release its associated resources.
  17067. */
  17068. dispose(): void;
  17069. /** @hidden */ rebuild(): void;
  17070. /**
  17071. * Clear the info related to rendering groups preventing retention point in material dispose.
  17072. */
  17073. freeRenderingGroups(): void;
  17074. }
  17075. }
  17076. declare module BABYLON {
  17077. /**
  17078. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17079. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17080. * You can then easily use it as a reflectionTexture on a flat surface.
  17081. * In case the surface is not a plane, please consider relying on reflection probes.
  17082. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17083. */
  17084. export class MirrorTexture extends RenderTargetTexture {
  17085. private scene;
  17086. /**
  17087. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17088. * 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.
  17089. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17090. */
  17091. mirrorPlane: Plane;
  17092. /**
  17093. * Define the blur ratio used to blur the reflection if needed.
  17094. */
  17095. blurRatio: number;
  17096. /**
  17097. * Define the adaptive blur kernel used to blur the reflection if needed.
  17098. * This will autocompute the closest best match for the `blurKernel`
  17099. */
  17100. adaptiveBlurKernel: number;
  17101. /**
  17102. * Define the blur kernel used to blur the reflection if needed.
  17103. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17104. */
  17105. blurKernel: number;
  17106. /**
  17107. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17108. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17109. */
  17110. blurKernelX: number;
  17111. /**
  17112. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17113. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17114. */
  17115. blurKernelY: number;
  17116. private _autoComputeBlurKernel;
  17117. protected _onRatioRescale(): void;
  17118. private _updateGammaSpace;
  17119. private _imageProcessingConfigChangeObserver;
  17120. private _transformMatrix;
  17121. private _mirrorMatrix;
  17122. private _savedViewMatrix;
  17123. private _blurX;
  17124. private _blurY;
  17125. private _adaptiveBlurKernel;
  17126. private _blurKernelX;
  17127. private _blurKernelY;
  17128. private _blurRatio;
  17129. /**
  17130. * Instantiates a Mirror Texture.
  17131. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17132. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17133. * You can then easily use it as a reflectionTexture on a flat surface.
  17134. * In case the surface is not a plane, please consider relying on reflection probes.
  17135. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17136. * @param name
  17137. * @param size
  17138. * @param scene
  17139. * @param generateMipMaps
  17140. * @param type
  17141. * @param samplingMode
  17142. * @param generateDepthBuffer
  17143. */
  17144. constructor(name: string, size: number | {
  17145. width: number;
  17146. height: number;
  17147. } | {
  17148. ratio: number;
  17149. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17150. private _preparePostProcesses;
  17151. /**
  17152. * Clone the mirror texture.
  17153. * @returns the cloned texture
  17154. */
  17155. clone(): MirrorTexture;
  17156. /**
  17157. * Serialize the texture to a JSON representation you could use in Parse later on
  17158. * @returns the serialized JSON representation
  17159. */
  17160. serialize(): any;
  17161. /**
  17162. * Dispose the texture and release its associated resources.
  17163. */
  17164. dispose(): void;
  17165. }
  17166. }
  17167. declare module BABYLON {
  17168. /**
  17169. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17170. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17171. */
  17172. export class Texture extends BaseTexture {
  17173. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17174. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17175. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17176. /** nearest is mag = nearest and min = nearest and mip = linear */
  17177. static readonly NEAREST_SAMPLINGMODE: number;
  17178. /** nearest is mag = nearest and min = nearest and mip = linear */
  17179. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17180. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17181. static readonly BILINEAR_SAMPLINGMODE: number;
  17182. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17183. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17184. /** Trilinear is mag = linear and min = linear and mip = linear */
  17185. static readonly TRILINEAR_SAMPLINGMODE: number;
  17186. /** Trilinear is mag = linear and min = linear and mip = linear */
  17187. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17188. /** mag = nearest and min = nearest and mip = nearest */
  17189. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17190. /** mag = nearest and min = linear and mip = nearest */
  17191. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17192. /** mag = nearest and min = linear and mip = linear */
  17193. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17194. /** mag = nearest and min = linear and mip = none */
  17195. static readonly NEAREST_LINEAR: number;
  17196. /** mag = nearest and min = nearest and mip = none */
  17197. static readonly NEAREST_NEAREST: number;
  17198. /** mag = linear and min = nearest and mip = nearest */
  17199. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17200. /** mag = linear and min = nearest and mip = linear */
  17201. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17202. /** mag = linear and min = linear and mip = none */
  17203. static readonly LINEAR_LINEAR: number;
  17204. /** mag = linear and min = nearest and mip = none */
  17205. static readonly LINEAR_NEAREST: number;
  17206. /** Explicit coordinates mode */
  17207. static readonly EXPLICIT_MODE: number;
  17208. /** Spherical coordinates mode */
  17209. static readonly SPHERICAL_MODE: number;
  17210. /** Planar coordinates mode */
  17211. static readonly PLANAR_MODE: number;
  17212. /** Cubic coordinates mode */
  17213. static readonly CUBIC_MODE: number;
  17214. /** Projection coordinates mode */
  17215. static readonly PROJECTION_MODE: number;
  17216. /** Inverse Cubic coordinates mode */
  17217. static readonly SKYBOX_MODE: number;
  17218. /** Inverse Cubic coordinates mode */
  17219. static readonly INVCUBIC_MODE: number;
  17220. /** Equirectangular coordinates mode */
  17221. static readonly EQUIRECTANGULAR_MODE: number;
  17222. /** Equirectangular Fixed coordinates mode */
  17223. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17224. /** Equirectangular Fixed Mirrored coordinates mode */
  17225. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17226. /** Texture is not repeating outside of 0..1 UVs */
  17227. static readonly CLAMP_ADDRESSMODE: number;
  17228. /** Texture is repeating outside of 0..1 UVs */
  17229. static readonly WRAP_ADDRESSMODE: number;
  17230. /** Texture is repeating and mirrored */
  17231. static readonly MIRROR_ADDRESSMODE: number;
  17232. /**
  17233. * 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
  17234. */
  17235. static UseSerializedUrlIfAny: boolean;
  17236. /**
  17237. * Define the url of the texture.
  17238. */
  17239. url: Nullable<string>;
  17240. /**
  17241. * Define an offset on the texture to offset the u coordinates of the UVs
  17242. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17243. */
  17244. uOffset: number;
  17245. /**
  17246. * Define an offset on the texture to offset the v coordinates of the UVs
  17247. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17248. */
  17249. vOffset: number;
  17250. /**
  17251. * Define an offset on the texture to scale the u coordinates of the UVs
  17252. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17253. */
  17254. uScale: number;
  17255. /**
  17256. * Define an offset on the texture to scale the v coordinates of the UVs
  17257. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17258. */
  17259. vScale: number;
  17260. /**
  17261. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17262. * @see http://doc.babylonjs.com/how_to/more_materials
  17263. */
  17264. uAng: number;
  17265. /**
  17266. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17267. * @see http://doc.babylonjs.com/how_to/more_materials
  17268. */
  17269. vAng: number;
  17270. /**
  17271. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17272. * @see http://doc.babylonjs.com/how_to/more_materials
  17273. */
  17274. wAng: number;
  17275. /**
  17276. * Defines the center of rotation (U)
  17277. */
  17278. uRotationCenter: number;
  17279. /**
  17280. * Defines the center of rotation (V)
  17281. */
  17282. vRotationCenter: number;
  17283. /**
  17284. * Defines the center of rotation (W)
  17285. */
  17286. wRotationCenter: number;
  17287. /**
  17288. * Are mip maps generated for this texture or not.
  17289. */
  17290. readonly noMipmap: boolean;
  17291. private _noMipmap;
  17292. /** @hidden */ invertY: boolean;
  17293. private _rowGenerationMatrix;
  17294. private _cachedTextureMatrix;
  17295. private _projectionModeMatrix;
  17296. private _t0;
  17297. private _t1;
  17298. private _t2;
  17299. private _cachedUOffset;
  17300. private _cachedVOffset;
  17301. private _cachedUScale;
  17302. private _cachedVScale;
  17303. private _cachedUAng;
  17304. private _cachedVAng;
  17305. private _cachedWAng;
  17306. private _cachedProjectionMatrixId;
  17307. private _cachedCoordinatesMode;
  17308. /** @hidden */
  17309. protected _initialSamplingMode: number;
  17310. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17311. private _deleteBuffer;
  17312. protected _format: Nullable<number>;
  17313. private _delayedOnLoad;
  17314. private _delayedOnError;
  17315. /**
  17316. * Observable triggered once the texture has been loaded.
  17317. */
  17318. onLoadObservable: Observable<Texture>;
  17319. protected _isBlocking: boolean;
  17320. /**
  17321. * Is the texture preventing material to render while loading.
  17322. * If false, a default texture will be used instead of the loading one during the preparation step.
  17323. */
  17324. isBlocking: boolean;
  17325. /**
  17326. * Get the current sampling mode associated with the texture.
  17327. */
  17328. readonly samplingMode: number;
  17329. /**
  17330. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17331. */
  17332. readonly invertY: boolean;
  17333. /**
  17334. * Instantiates a new texture.
  17335. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17336. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17337. * @param url define the url of the picture to load as a texture
  17338. * @param scene define the scene the texture will belong to
  17339. * @param noMipmap define if the texture will require mip maps or not
  17340. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17341. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17342. * @param onLoad define a callback triggered when the texture has been loaded
  17343. * @param onError define a callback triggered when an error occurred during the loading session
  17344. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17345. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17346. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17347. */
  17348. 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);
  17349. /**
  17350. * Update the url (and optional buffer) of this texture if url was null during construction.
  17351. * @param url the url of the texture
  17352. * @param buffer the buffer of the texture (defaults to null)
  17353. * @param onLoad callback called when the texture is loaded (defaults to null)
  17354. */
  17355. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17356. /**
  17357. * Finish the loading sequence of a texture flagged as delayed load.
  17358. * @hidden
  17359. */
  17360. delayLoad(): void;
  17361. private _prepareRowForTextureGeneration;
  17362. /**
  17363. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17364. * @returns the transform matrix of the texture.
  17365. */
  17366. getTextureMatrix(): Matrix;
  17367. /**
  17368. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17369. * @returns The reflection texture transform
  17370. */
  17371. getReflectionTextureMatrix(): Matrix;
  17372. /**
  17373. * Clones the texture.
  17374. * @returns the cloned texture
  17375. */
  17376. clone(): Texture;
  17377. /**
  17378. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17379. * @returns The JSON representation of the texture
  17380. */
  17381. serialize(): any;
  17382. /**
  17383. * Get the current class name of the texture useful for serialization or dynamic coding.
  17384. * @returns "Texture"
  17385. */
  17386. getClassName(): string;
  17387. /**
  17388. * Dispose the texture and release its associated resources.
  17389. */
  17390. dispose(): void;
  17391. /**
  17392. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  17393. * @param parsedTexture Define the JSON representation of the texture
  17394. * @param scene Define the scene the parsed texture should be instantiated in
  17395. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  17396. * @returns The parsed texture if successful
  17397. */
  17398. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  17399. /**
  17400. * Creates a texture from its base 64 representation.
  17401. * @param data Define the base64 payload without the data: prefix
  17402. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17403. * @param scene Define the scene the texture should belong to
  17404. * @param noMipmap Forces the texture to not create mip map information if true
  17405. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17406. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17407. * @param onLoad define a callback triggered when the texture has been loaded
  17408. * @param onError define a callback triggered when an error occurred during the loading session
  17409. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17410. * @returns the created texture
  17411. */
  17412. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  17413. /**
  17414. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  17415. * @param data Define the base64 payload without the data: prefix
  17416. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17417. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17418. * @param scene Define the scene the texture should belong to
  17419. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17420. * @param noMipmap Forces the texture to not create mip map information if true
  17421. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17422. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17423. * @param onLoad define a callback triggered when the texture has been loaded
  17424. * @param onError define a callback triggered when an error occurred during the loading session
  17425. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17426. * @returns the created texture
  17427. */
  17428. 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;
  17429. }
  17430. }
  17431. declare module BABYLON {
  17432. /**
  17433. * Defines the options associated with the creation of a shader material.
  17434. */
  17435. export interface IShaderMaterialOptions {
  17436. /**
  17437. * Does the material work in alpha blend mode
  17438. */
  17439. needAlphaBlending: boolean;
  17440. /**
  17441. * Does the material work in alpha test mode
  17442. */
  17443. needAlphaTesting: boolean;
  17444. /**
  17445. * The list of attribute names used in the shader
  17446. */
  17447. attributes: string[];
  17448. /**
  17449. * The list of unifrom names used in the shader
  17450. */
  17451. uniforms: string[];
  17452. /**
  17453. * The list of UBO names used in the shader
  17454. */
  17455. uniformBuffers: string[];
  17456. /**
  17457. * The list of sampler names used in the shader
  17458. */
  17459. samplers: string[];
  17460. /**
  17461. * The list of defines used in the shader
  17462. */
  17463. defines: string[];
  17464. }
  17465. /**
  17466. * 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.
  17467. *
  17468. * This returned material effects how the mesh will look based on the code in the shaders.
  17469. *
  17470. * @see http://doc.babylonjs.com/how_to/shader_material
  17471. */
  17472. export class ShaderMaterial extends Material {
  17473. private _shaderPath;
  17474. private _options;
  17475. private _textures;
  17476. private _textureArrays;
  17477. private _floats;
  17478. private _ints;
  17479. private _floatsArrays;
  17480. private _colors3;
  17481. private _colors3Arrays;
  17482. private _colors4;
  17483. private _vectors2;
  17484. private _vectors3;
  17485. private _vectors4;
  17486. private _matrices;
  17487. private _matrices3x3;
  17488. private _matrices2x2;
  17489. private _vectors2Arrays;
  17490. private _vectors3Arrays;
  17491. private _cachedWorldViewMatrix;
  17492. private _renderId;
  17493. /**
  17494. * Instantiate a new shader material.
  17495. * 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.
  17496. * This returned material effects how the mesh will look based on the code in the shaders.
  17497. * @see http://doc.babylonjs.com/how_to/shader_material
  17498. * @param name Define the name of the material in the scene
  17499. * @param scene Define the scene the material belongs to
  17500. * @param shaderPath Defines the route to the shader code in one of three ways:
  17501. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17502. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17503. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17504. * @param options Define the options used to create the shader
  17505. */
  17506. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17507. /**
  17508. * Gets the current class name of the material e.g. "ShaderMaterial"
  17509. * Mainly use in serialization.
  17510. * @returns the class name
  17511. */
  17512. getClassName(): string;
  17513. /**
  17514. * Specifies if the material will require alpha blending
  17515. * @returns a boolean specifying if alpha blending is needed
  17516. */
  17517. needAlphaBlending(): boolean;
  17518. /**
  17519. * Specifies if this material should be rendered in alpha test mode
  17520. * @returns a boolean specifying if an alpha test is needed.
  17521. */
  17522. needAlphaTesting(): boolean;
  17523. private _checkUniform;
  17524. /**
  17525. * Set a texture in the shader.
  17526. * @param name Define the name of the uniform samplers as defined in the shader
  17527. * @param texture Define the texture to bind to this sampler
  17528. * @return the material itself allowing "fluent" like uniform updates
  17529. */
  17530. setTexture(name: string, texture: Texture): ShaderMaterial;
  17531. /**
  17532. * Set a texture array in the shader.
  17533. * @param name Define the name of the uniform sampler array as defined in the shader
  17534. * @param textures Define the list of textures to bind to this sampler
  17535. * @return the material itself allowing "fluent" like uniform updates
  17536. */
  17537. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17538. /**
  17539. * Set a float in the shader.
  17540. * @param name Define the name of the uniform as defined in the shader
  17541. * @param value Define the value to give to the uniform
  17542. * @return the material itself allowing "fluent" like uniform updates
  17543. */
  17544. setFloat(name: string, value: number): ShaderMaterial;
  17545. /**
  17546. * Set a int in the shader.
  17547. * @param name Define the name of the uniform as defined in the shader
  17548. * @param value Define the value to give to the uniform
  17549. * @return the material itself allowing "fluent" like uniform updates
  17550. */
  17551. setInt(name: string, value: number): ShaderMaterial;
  17552. /**
  17553. * Set an array of floats in the shader.
  17554. * @param name Define the name of the uniform as defined in the shader
  17555. * @param value Define the value to give to the uniform
  17556. * @return the material itself allowing "fluent" like uniform updates
  17557. */
  17558. setFloats(name: string, value: number[]): ShaderMaterial;
  17559. /**
  17560. * Set a vec3 in the shader from a Color3.
  17561. * @param name Define the name of the uniform as defined in the shader
  17562. * @param value Define the value to give to the uniform
  17563. * @return the material itself allowing "fluent" like uniform updates
  17564. */
  17565. setColor3(name: string, value: Color3): ShaderMaterial;
  17566. /**
  17567. * Set a vec3 array in the shader from a Color3 array.
  17568. * @param name Define the name of the uniform as defined in the shader
  17569. * @param value Define the value to give to the uniform
  17570. * @return the material itself allowing "fluent" like uniform updates
  17571. */
  17572. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17573. /**
  17574. * Set a vec4 in the shader from a Color4.
  17575. * @param name Define the name of the uniform as defined in the shader
  17576. * @param value Define the value to give to the uniform
  17577. * @return the material itself allowing "fluent" like uniform updates
  17578. */
  17579. setColor4(name: string, value: Color4): ShaderMaterial;
  17580. /**
  17581. * Set a vec2 in the shader from a Vector2.
  17582. * @param name Define the name of the uniform as defined in the shader
  17583. * @param value Define the value to give to the uniform
  17584. * @return the material itself allowing "fluent" like uniform updates
  17585. */
  17586. setVector2(name: string, value: Vector2): ShaderMaterial;
  17587. /**
  17588. * Set a vec3 in the shader from a Vector3.
  17589. * @param name Define the name of the uniform as defined in the shader
  17590. * @param value Define the value to give to the uniform
  17591. * @return the material itself allowing "fluent" like uniform updates
  17592. */
  17593. setVector3(name: string, value: Vector3): ShaderMaterial;
  17594. /**
  17595. * Set a vec4 in the shader from a Vector4.
  17596. * @param name Define the name of the uniform as defined in the shader
  17597. * @param value Define the value to give to the uniform
  17598. * @return the material itself allowing "fluent" like uniform updates
  17599. */
  17600. setVector4(name: string, value: Vector4): ShaderMaterial;
  17601. /**
  17602. * Set a mat4 in the shader from a Matrix.
  17603. * @param name Define the name of the uniform as defined in the shader
  17604. * @param value Define the value to give to the uniform
  17605. * @return the material itself allowing "fluent" like uniform updates
  17606. */
  17607. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17608. /**
  17609. * Set a mat3 in the shader from a Float32Array.
  17610. * @param name Define the name of the uniform as defined in the shader
  17611. * @param value Define the value to give to the uniform
  17612. * @return the material itself allowing "fluent" like uniform updates
  17613. */
  17614. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17615. /**
  17616. * Set a mat2 in the shader from a Float32Array.
  17617. * @param name Define the name of the uniform as defined in the shader
  17618. * @param value Define the value to give to the uniform
  17619. * @return the material itself allowing "fluent" like uniform updates
  17620. */
  17621. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17622. /**
  17623. * Set a vec2 array in the shader from a number array.
  17624. * @param name Define the name of the uniform as defined in the shader
  17625. * @param value Define the value to give to the uniform
  17626. * @return the material itself allowing "fluent" like uniform updates
  17627. */
  17628. setArray2(name: string, value: number[]): ShaderMaterial;
  17629. /**
  17630. * Set a vec3 array in the shader from a number array.
  17631. * @param name Define the name of the uniform as defined in the shader
  17632. * @param value Define the value to give to the uniform
  17633. * @return the material itself allowing "fluent" like uniform updates
  17634. */
  17635. setArray3(name: string, value: number[]): ShaderMaterial;
  17636. private _checkCache;
  17637. /**
  17638. * Checks if the material is ready to render the requested mesh
  17639. * @param mesh Define the mesh to render
  17640. * @param useInstances Define whether or not the material is used with instances
  17641. * @returns true if ready, otherwise false
  17642. */
  17643. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17644. /**
  17645. * Binds the world matrix to the material
  17646. * @param world defines the world transformation matrix
  17647. */
  17648. bindOnlyWorldMatrix(world: Matrix): void;
  17649. /**
  17650. * Binds the material to the mesh
  17651. * @param world defines the world transformation matrix
  17652. * @param mesh defines the mesh to bind the material to
  17653. */
  17654. bind(world: Matrix, mesh?: Mesh): void;
  17655. /**
  17656. * Gets the active textures from the material
  17657. * @returns an array of textures
  17658. */
  17659. getActiveTextures(): BaseTexture[];
  17660. /**
  17661. * Specifies if the material uses a texture
  17662. * @param texture defines the texture to check against the material
  17663. * @returns a boolean specifying if the material uses the texture
  17664. */
  17665. hasTexture(texture: BaseTexture): boolean;
  17666. /**
  17667. * Makes a duplicate of the material, and gives it a new name
  17668. * @param name defines the new name for the duplicated material
  17669. * @returns the cloned material
  17670. */
  17671. clone(name: string): ShaderMaterial;
  17672. /**
  17673. * Disposes the material
  17674. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17675. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17676. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17677. */
  17678. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17679. /**
  17680. * Serializes this material in a JSON representation
  17681. * @returns the serialized material object
  17682. */
  17683. serialize(): any;
  17684. /**
  17685. * Creates a shader material from parsed shader material data
  17686. * @param source defines the JSON represnetation of the material
  17687. * @param scene defines the hosting scene
  17688. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17689. * @returns a new material
  17690. */
  17691. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17692. }
  17693. }
  17694. declare module BABYLON {
  17695. /** @hidden */
  17696. export var colorPixelShader: {
  17697. name: string;
  17698. shader: string;
  17699. };
  17700. }
  17701. declare module BABYLON {
  17702. /** @hidden */
  17703. export var colorVertexShader: {
  17704. name: string;
  17705. shader: string;
  17706. };
  17707. }
  17708. declare module BABYLON {
  17709. /**
  17710. * Line mesh
  17711. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17712. */
  17713. export class LinesMesh extends Mesh {
  17714. /**
  17715. * If vertex color should be applied to the mesh
  17716. */
  17717. useVertexColor?: boolean | undefined;
  17718. /**
  17719. * If vertex alpha should be applied to the mesh
  17720. */
  17721. useVertexAlpha?: boolean | undefined;
  17722. /**
  17723. * Color of the line (Default: White)
  17724. */
  17725. color: Color3;
  17726. /**
  17727. * Alpha of the line (Default: 1)
  17728. */
  17729. alpha: number;
  17730. /**
  17731. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17732. * This margin is expressed in world space coordinates, so its value may vary.
  17733. * Default value is 0.1
  17734. */
  17735. intersectionThreshold: number;
  17736. private _colorShader;
  17737. /**
  17738. * Creates a new LinesMesh
  17739. * @param name defines the name
  17740. * @param scene defines the hosting scene
  17741. * @param parent defines the parent mesh if any
  17742. * @param source defines the optional source LinesMesh used to clone data from
  17743. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17744. * When false, achieved by calling a clone(), also passing False.
  17745. * This will make creation of children, recursive.
  17746. * @param useVertexColor defines if this LinesMesh supports vertex color
  17747. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17748. */
  17749. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17750. /**
  17751. * If vertex color should be applied to the mesh
  17752. */
  17753. useVertexColor?: boolean | undefined,
  17754. /**
  17755. * If vertex alpha should be applied to the mesh
  17756. */
  17757. useVertexAlpha?: boolean | undefined);
  17758. /**
  17759. * Returns the string "LineMesh"
  17760. */
  17761. getClassName(): string;
  17762. /**
  17763. * @hidden
  17764. */
  17765. /**
  17766. * @hidden
  17767. */
  17768. material: Material;
  17769. /**
  17770. * @hidden
  17771. */
  17772. readonly checkCollisions: boolean;
  17773. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17774. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17775. /**
  17776. * Disposes of the line mesh
  17777. * @param doNotRecurse If children should be disposed
  17778. */
  17779. dispose(doNotRecurse?: boolean): void;
  17780. /**
  17781. * Returns a new LineMesh object cloned from the current one.
  17782. */
  17783. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17784. /**
  17785. * Creates a new InstancedLinesMesh object from the mesh model.
  17786. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17787. * @param name defines the name of the new instance
  17788. * @returns a new InstancedLinesMesh
  17789. */
  17790. createInstance(name: string): InstancedLinesMesh;
  17791. }
  17792. /**
  17793. * Creates an instance based on a source LinesMesh
  17794. */
  17795. export class InstancedLinesMesh extends InstancedMesh {
  17796. /**
  17797. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17798. * This margin is expressed in world space coordinates, so its value may vary.
  17799. * Initilized with the intersectionThreshold value of the source LinesMesh
  17800. */
  17801. intersectionThreshold: number;
  17802. constructor(name: string, source: LinesMesh);
  17803. /**
  17804. * Returns the string "InstancedLinesMesh".
  17805. */
  17806. getClassName(): string;
  17807. }
  17808. }
  17809. declare module BABYLON {
  17810. /**
  17811. * Mesh representing the gorund
  17812. */
  17813. export class GroundMesh extends Mesh {
  17814. /** If octree should be generated */
  17815. generateOctree: boolean;
  17816. private _heightQuads;
  17817. /** @hidden */ subdivisionsX: number;
  17818. /** @hidden */ subdivisionsY: number;
  17819. /** @hidden */ width: number;
  17820. /** @hidden */ height: number;
  17821. /** @hidden */ minX: number;
  17822. /** @hidden */ maxX: number;
  17823. /** @hidden */ minZ: number;
  17824. /** @hidden */ maxZ: number;
  17825. constructor(name: string, scene: Scene);
  17826. /**
  17827. * "GroundMesh"
  17828. * @returns "GroundMesh"
  17829. */
  17830. getClassName(): string;
  17831. /**
  17832. * The minimum of x and y subdivisions
  17833. */
  17834. readonly subdivisions: number;
  17835. /**
  17836. * X subdivisions
  17837. */
  17838. readonly subdivisionsX: number;
  17839. /**
  17840. * Y subdivisions
  17841. */
  17842. readonly subdivisionsY: number;
  17843. /**
  17844. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  17845. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  17846. * @param chunksCount the number of subdivisions for x and y
  17847. * @param octreeBlocksSize (Default: 32)
  17848. */
  17849. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  17850. /**
  17851. * Returns a height (y) value in the Worl system :
  17852. * the ground altitude at the coordinates (x, z) expressed in the World system.
  17853. * @param x x coordinate
  17854. * @param z z coordinate
  17855. * @returns the ground y position if (x, z) are outside the ground surface.
  17856. */
  17857. getHeightAtCoordinates(x: number, z: number): number;
  17858. /**
  17859. * Returns a normalized vector (Vector3) orthogonal to the ground
  17860. * at the ground coordinates (x, z) expressed in the World system.
  17861. * @param x x coordinate
  17862. * @param z z coordinate
  17863. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  17864. */
  17865. getNormalAtCoordinates(x: number, z: number): Vector3;
  17866. /**
  17867. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  17868. * at the ground coordinates (x, z) expressed in the World system.
  17869. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  17870. * @param x x coordinate
  17871. * @param z z coordinate
  17872. * @param ref vector to store the result
  17873. * @returns the GroundMesh.
  17874. */
  17875. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  17876. /**
  17877. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  17878. * if the ground has been updated.
  17879. * This can be used in the render loop.
  17880. * @returns the GroundMesh.
  17881. */
  17882. updateCoordinateHeights(): GroundMesh;
  17883. private _getFacetAt;
  17884. private _initHeightQuads;
  17885. private _computeHeightQuads;
  17886. /**
  17887. * Serializes this ground mesh
  17888. * @param serializationObject object to write serialization to
  17889. */
  17890. serialize(serializationObject: any): void;
  17891. /**
  17892. * Parses a serialized ground mesh
  17893. * @param parsedMesh the serialized mesh
  17894. * @param scene the scene to create the ground mesh in
  17895. * @returns the created ground mesh
  17896. */
  17897. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  17898. }
  17899. }
  17900. declare module BABYLON {
  17901. /**
  17902. * Interface for Physics-Joint data
  17903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17904. */
  17905. export interface PhysicsJointData {
  17906. /**
  17907. * The main pivot of the joint
  17908. */
  17909. mainPivot?: Vector3;
  17910. /**
  17911. * The connected pivot of the joint
  17912. */
  17913. connectedPivot?: Vector3;
  17914. /**
  17915. * The main axis of the joint
  17916. */
  17917. mainAxis?: Vector3;
  17918. /**
  17919. * The connected axis of the joint
  17920. */
  17921. connectedAxis?: Vector3;
  17922. /**
  17923. * The collision of the joint
  17924. */
  17925. collision?: boolean;
  17926. /**
  17927. * Native Oimo/Cannon/Energy data
  17928. */
  17929. nativeParams?: any;
  17930. }
  17931. /**
  17932. * This is a holder class for the physics joint created by the physics plugin
  17933. * It holds a set of functions to control the underlying joint
  17934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17935. */
  17936. export class PhysicsJoint {
  17937. /**
  17938. * The type of the physics joint
  17939. */
  17940. type: number;
  17941. /**
  17942. * The data for the physics joint
  17943. */
  17944. jointData: PhysicsJointData;
  17945. private _physicsJoint;
  17946. protected _physicsPlugin: IPhysicsEnginePlugin;
  17947. /**
  17948. * Initializes the physics joint
  17949. * @param type The type of the physics joint
  17950. * @param jointData The data for the physics joint
  17951. */
  17952. constructor(
  17953. /**
  17954. * The type of the physics joint
  17955. */
  17956. type: number,
  17957. /**
  17958. * The data for the physics joint
  17959. */
  17960. jointData: PhysicsJointData);
  17961. /**
  17962. * Gets the physics joint
  17963. */
  17964. /**
  17965. * Sets the physics joint
  17966. */
  17967. physicsJoint: any;
  17968. /**
  17969. * Sets the physics plugin
  17970. */
  17971. physicsPlugin: IPhysicsEnginePlugin;
  17972. /**
  17973. * Execute a function that is physics-plugin specific.
  17974. * @param {Function} func the function that will be executed.
  17975. * It accepts two parameters: the physics world and the physics joint
  17976. */
  17977. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  17978. /**
  17979. * Distance-Joint type
  17980. */
  17981. static DistanceJoint: number;
  17982. /**
  17983. * Hinge-Joint type
  17984. */
  17985. static HingeJoint: number;
  17986. /**
  17987. * Ball-and-Socket joint type
  17988. */
  17989. static BallAndSocketJoint: number;
  17990. /**
  17991. * Wheel-Joint type
  17992. */
  17993. static WheelJoint: number;
  17994. /**
  17995. * Slider-Joint type
  17996. */
  17997. static SliderJoint: number;
  17998. /**
  17999. * Prismatic-Joint type
  18000. */
  18001. static PrismaticJoint: number;
  18002. /**
  18003. * Universal-Joint type
  18004. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18005. */
  18006. static UniversalJoint: number;
  18007. /**
  18008. * Hinge-Joint 2 type
  18009. */
  18010. static Hinge2Joint: number;
  18011. /**
  18012. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18013. */
  18014. static PointToPointJoint: number;
  18015. /**
  18016. * Spring-Joint type
  18017. */
  18018. static SpringJoint: number;
  18019. /**
  18020. * Lock-Joint type
  18021. */
  18022. static LockJoint: number;
  18023. }
  18024. /**
  18025. * A class representing a physics distance joint
  18026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18027. */
  18028. export class DistanceJoint extends PhysicsJoint {
  18029. /**
  18030. *
  18031. * @param jointData The data for the Distance-Joint
  18032. */
  18033. constructor(jointData: DistanceJointData);
  18034. /**
  18035. * Update the predefined distance.
  18036. * @param maxDistance The maximum preferred distance
  18037. * @param minDistance The minimum preferred distance
  18038. */
  18039. updateDistance(maxDistance: number, minDistance?: number): void;
  18040. }
  18041. /**
  18042. * Represents a Motor-Enabled Joint
  18043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18044. */
  18045. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18046. /**
  18047. * Initializes the Motor-Enabled Joint
  18048. * @param type The type of the joint
  18049. * @param jointData The physica joint data for the joint
  18050. */
  18051. constructor(type: number, jointData: PhysicsJointData);
  18052. /**
  18053. * Set the motor values.
  18054. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18055. * @param force the force to apply
  18056. * @param maxForce max force for this motor.
  18057. */
  18058. setMotor(force?: number, maxForce?: number): void;
  18059. /**
  18060. * Set the motor's limits.
  18061. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18062. * @param upperLimit The upper limit of the motor
  18063. * @param lowerLimit The lower limit of the motor
  18064. */
  18065. setLimit(upperLimit: number, lowerLimit?: number): void;
  18066. }
  18067. /**
  18068. * This class represents a single physics Hinge-Joint
  18069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18070. */
  18071. export class HingeJoint extends MotorEnabledJoint {
  18072. /**
  18073. * Initializes the Hinge-Joint
  18074. * @param jointData The joint data for the Hinge-Joint
  18075. */
  18076. constructor(jointData: PhysicsJointData);
  18077. /**
  18078. * Set the motor values.
  18079. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18080. * @param {number} force the force to apply
  18081. * @param {number} maxForce max force for this motor.
  18082. */
  18083. setMotor(force?: number, maxForce?: number): void;
  18084. /**
  18085. * Set the motor's limits.
  18086. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18087. * @param upperLimit The upper limit of the motor
  18088. * @param lowerLimit The lower limit of the motor
  18089. */
  18090. setLimit(upperLimit: number, lowerLimit?: number): void;
  18091. }
  18092. /**
  18093. * This class represents a dual hinge physics joint (same as wheel joint)
  18094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18095. */
  18096. export class Hinge2Joint extends MotorEnabledJoint {
  18097. /**
  18098. * Initializes the Hinge2-Joint
  18099. * @param jointData The joint data for the Hinge2-Joint
  18100. */
  18101. constructor(jointData: PhysicsJointData);
  18102. /**
  18103. * Set the motor values.
  18104. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18105. * @param {number} targetSpeed the speed the motor is to reach
  18106. * @param {number} maxForce max force for this motor.
  18107. * @param {motorIndex} the motor's index, 0 or 1.
  18108. */
  18109. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  18110. /**
  18111. * Set the motor limits.
  18112. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18113. * @param {number} upperLimit the upper limit
  18114. * @param {number} lowerLimit lower limit
  18115. * @param {motorIndex} the motor's index, 0 or 1.
  18116. */
  18117. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18118. }
  18119. /**
  18120. * Interface for a motor enabled joint
  18121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18122. */
  18123. export interface IMotorEnabledJoint {
  18124. /**
  18125. * Physics joint
  18126. */
  18127. physicsJoint: any;
  18128. /**
  18129. * Sets the motor of the motor-enabled joint
  18130. * @param force The force of the motor
  18131. * @param maxForce The maximum force of the motor
  18132. * @param motorIndex The index of the motor
  18133. */
  18134. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18135. /**
  18136. * Sets the limit of the motor
  18137. * @param upperLimit The upper limit of the motor
  18138. * @param lowerLimit The lower limit of the motor
  18139. * @param motorIndex The index of the motor
  18140. */
  18141. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18142. }
  18143. /**
  18144. * Joint data for a Distance-Joint
  18145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18146. */
  18147. export interface DistanceJointData extends PhysicsJointData {
  18148. /**
  18149. * Max distance the 2 joint objects can be apart
  18150. */
  18151. maxDistance: number;
  18152. }
  18153. /**
  18154. * Joint data from a spring joint
  18155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18156. */
  18157. export interface SpringJointData extends PhysicsJointData {
  18158. /**
  18159. * Length of the spring
  18160. */
  18161. length: number;
  18162. /**
  18163. * Stiffness of the spring
  18164. */
  18165. stiffness: number;
  18166. /**
  18167. * Damping of the spring
  18168. */
  18169. damping: number;
  18170. /** this callback will be called when applying the force to the impostors. */
  18171. forceApplicationCallback: () => void;
  18172. }
  18173. }
  18174. declare module BABYLON {
  18175. /**
  18176. * Interface used to describe a physics joint
  18177. */
  18178. export interface PhysicsImpostorJoint {
  18179. /** Defines the main impostor to which the joint is linked */
  18180. mainImpostor: PhysicsImpostor;
  18181. /** Defines the impostor that is connected to the main impostor using this joint */
  18182. connectedImpostor: PhysicsImpostor;
  18183. /** Defines the joint itself */
  18184. joint: PhysicsJoint;
  18185. }
  18186. /** @hidden */
  18187. export interface IPhysicsEnginePlugin {
  18188. world: any;
  18189. name: string;
  18190. setGravity(gravity: Vector3): void;
  18191. setTimeStep(timeStep: number): void;
  18192. getTimeStep(): number;
  18193. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18194. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18195. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18196. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18197. removePhysicsBody(impostor: PhysicsImpostor): void;
  18198. generateJoint(joint: PhysicsImpostorJoint): void;
  18199. removeJoint(joint: PhysicsImpostorJoint): void;
  18200. isSupported(): boolean;
  18201. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18202. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18203. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18204. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18205. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18206. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18207. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18208. getBodyMass(impostor: PhysicsImpostor): number;
  18209. getBodyFriction(impostor: PhysicsImpostor): number;
  18210. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18211. getBodyRestitution(impostor: PhysicsImpostor): number;
  18212. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18213. sleepBody(impostor: PhysicsImpostor): void;
  18214. wakeUpBody(impostor: PhysicsImpostor): void;
  18215. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18216. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18217. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18218. getRadius(impostor: PhysicsImpostor): number;
  18219. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18220. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18221. dispose(): void;
  18222. }
  18223. /**
  18224. * Interface used to define a physics engine
  18225. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18226. */
  18227. export interface IPhysicsEngine {
  18228. /**
  18229. * Gets the gravity vector used by the simulation
  18230. */
  18231. gravity: Vector3;
  18232. /**
  18233. * Sets the gravity vector used by the simulation
  18234. * @param gravity defines the gravity vector to use
  18235. */
  18236. setGravity(gravity: Vector3): void;
  18237. /**
  18238. * Set the time step of the physics engine.
  18239. * Default is 1/60.
  18240. * To slow it down, enter 1/600 for example.
  18241. * To speed it up, 1/30
  18242. * @param newTimeStep the new timestep to apply to this world.
  18243. */
  18244. setTimeStep(newTimeStep: number): void;
  18245. /**
  18246. * Get the time step of the physics engine.
  18247. * @returns the current time step
  18248. */
  18249. getTimeStep(): number;
  18250. /**
  18251. * Release all resources
  18252. */
  18253. dispose(): void;
  18254. /**
  18255. * Gets the name of the current physics plugin
  18256. * @returns the name of the plugin
  18257. */
  18258. getPhysicsPluginName(): string;
  18259. /**
  18260. * Adding a new impostor for the impostor tracking.
  18261. * This will be done by the impostor itself.
  18262. * @param impostor the impostor to add
  18263. */
  18264. addImpostor(impostor: PhysicsImpostor): void;
  18265. /**
  18266. * Remove an impostor from the engine.
  18267. * This impostor and its mesh will not longer be updated by the physics engine.
  18268. * @param impostor the impostor to remove
  18269. */
  18270. removeImpostor(impostor: PhysicsImpostor): void;
  18271. /**
  18272. * Add a joint to the physics engine
  18273. * @param mainImpostor defines the main impostor to which the joint is added.
  18274. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  18275. * @param joint defines the joint that will connect both impostors.
  18276. */
  18277. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18278. /**
  18279. * Removes a joint from the simulation
  18280. * @param mainImpostor defines the impostor used with the joint
  18281. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  18282. * @param joint defines the joint to remove
  18283. */
  18284. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18285. /**
  18286. * Gets the current plugin used to run the simulation
  18287. * @returns current plugin
  18288. */
  18289. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18290. /**
  18291. * Gets the list of physic impostors
  18292. * @returns an array of PhysicsImpostor
  18293. */
  18294. getImpostors(): Array<PhysicsImpostor>;
  18295. /**
  18296. * Gets the impostor for a physics enabled object
  18297. * @param object defines the object impersonated by the impostor
  18298. * @returns the PhysicsImpostor or null if not found
  18299. */
  18300. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18301. /**
  18302. * Gets the impostor for a physics body object
  18303. * @param body defines physics body used by the impostor
  18304. * @returns the PhysicsImpostor or null if not found
  18305. */
  18306. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18307. /**
  18308. * Called by the scene. No need to call it.
  18309. * @param delta defines the timespam between frames
  18310. */ step(delta: number): void;
  18311. }
  18312. }
  18313. declare module BABYLON {
  18314. /**
  18315. * The interface for the physics imposter parameters
  18316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18317. */
  18318. export interface PhysicsImpostorParameters {
  18319. /**
  18320. * The mass of the physics imposter
  18321. */
  18322. mass: number;
  18323. /**
  18324. * The friction of the physics imposter
  18325. */
  18326. friction?: number;
  18327. /**
  18328. * The coefficient of restitution of the physics imposter
  18329. */
  18330. restitution?: number;
  18331. /**
  18332. * The native options of the physics imposter
  18333. */
  18334. nativeOptions?: any;
  18335. /**
  18336. * Specifies if the parent should be ignored
  18337. */
  18338. ignoreParent?: boolean;
  18339. /**
  18340. * Specifies if bi-directional transformations should be disabled
  18341. */
  18342. disableBidirectionalTransformation?: boolean;
  18343. }
  18344. /**
  18345. * Interface for a physics-enabled object
  18346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18347. */
  18348. export interface IPhysicsEnabledObject {
  18349. /**
  18350. * The position of the physics-enabled object
  18351. */
  18352. position: Vector3;
  18353. /**
  18354. * The rotation of the physics-enabled object
  18355. */
  18356. rotationQuaternion: Nullable<Quaternion>;
  18357. /**
  18358. * The scale of the physics-enabled object
  18359. */
  18360. scaling: Vector3;
  18361. /**
  18362. * The rotation of the physics-enabled object
  18363. */
  18364. rotation?: Vector3;
  18365. /**
  18366. * The parent of the physics-enabled object
  18367. */
  18368. parent?: any;
  18369. /**
  18370. * The bounding info of the physics-enabled object
  18371. * @returns The bounding info of the physics-enabled object
  18372. */
  18373. getBoundingInfo(): BoundingInfo;
  18374. /**
  18375. * Computes the world matrix
  18376. * @param force Specifies if the world matrix should be computed by force
  18377. * @returns A world matrix
  18378. */
  18379. computeWorldMatrix(force: boolean): Matrix;
  18380. /**
  18381. * Gets the world matrix
  18382. * @returns A world matrix
  18383. */
  18384. getWorldMatrix?(): Matrix;
  18385. /**
  18386. * Gets the child meshes
  18387. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  18388. * @returns An array of abstract meshes
  18389. */
  18390. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  18391. /**
  18392. * Gets the vertex data
  18393. * @param kind The type of vertex data
  18394. * @returns A nullable array of numbers, or a float32 array
  18395. */
  18396. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  18397. /**
  18398. * Gets the indices from the mesh
  18399. * @returns A nullable array of index arrays
  18400. */
  18401. getIndices?(): Nullable<IndicesArray>;
  18402. /**
  18403. * Gets the scene from the mesh
  18404. * @returns the indices array or null
  18405. */
  18406. getScene?(): Scene;
  18407. /**
  18408. * Gets the absolute position from the mesh
  18409. * @returns the absolute position
  18410. */
  18411. getAbsolutePosition(): Vector3;
  18412. /**
  18413. * Gets the absolute pivot point from the mesh
  18414. * @returns the absolute pivot point
  18415. */
  18416. getAbsolutePivotPoint(): Vector3;
  18417. /**
  18418. * Rotates the mesh
  18419. * @param axis The axis of rotation
  18420. * @param amount The amount of rotation
  18421. * @param space The space of the rotation
  18422. * @returns The rotation transform node
  18423. */
  18424. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18425. /**
  18426. * Translates the mesh
  18427. * @param axis The axis of translation
  18428. * @param distance The distance of translation
  18429. * @param space The space of the translation
  18430. * @returns The transform node
  18431. */
  18432. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18433. /**
  18434. * Sets the absolute position of the mesh
  18435. * @param absolutePosition The absolute position of the mesh
  18436. * @returns The transform node
  18437. */
  18438. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18439. /**
  18440. * Gets the class name of the mesh
  18441. * @returns The class name
  18442. */
  18443. getClassName(): string;
  18444. }
  18445. /**
  18446. * Represents a physics imposter
  18447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18448. */
  18449. export class PhysicsImpostor {
  18450. /**
  18451. * The physics-enabled object used as the physics imposter
  18452. */
  18453. object: IPhysicsEnabledObject;
  18454. /**
  18455. * The type of the physics imposter
  18456. */
  18457. type: number;
  18458. private _options;
  18459. private _scene?;
  18460. /**
  18461. * The default object size of the imposter
  18462. */
  18463. static DEFAULT_OBJECT_SIZE: Vector3;
  18464. /**
  18465. * The identity quaternion of the imposter
  18466. */
  18467. static IDENTITY_QUATERNION: Quaternion;
  18468. /** @hidden */ pluginData: any;
  18469. private _physicsEngine;
  18470. private _physicsBody;
  18471. private _bodyUpdateRequired;
  18472. private _onBeforePhysicsStepCallbacks;
  18473. private _onAfterPhysicsStepCallbacks;
  18474. /** @hidden */ onPhysicsCollideCallbacks: Array<{
  18475. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  18476. otherImpostors: Array<PhysicsImpostor>;
  18477. }>;
  18478. private _deltaPosition;
  18479. private _deltaRotation;
  18480. private _deltaRotationConjugated;
  18481. private _parent;
  18482. private _isDisposed;
  18483. private static _tmpVecs;
  18484. private static _tmpQuat;
  18485. /**
  18486. * Specifies if the physics imposter is disposed
  18487. */
  18488. readonly isDisposed: boolean;
  18489. /**
  18490. * Gets the mass of the physics imposter
  18491. */
  18492. mass: number;
  18493. /**
  18494. * Gets the coefficient of friction
  18495. */
  18496. /**
  18497. * Sets the coefficient of friction
  18498. */
  18499. friction: number;
  18500. /**
  18501. * Gets the coefficient of restitution
  18502. */
  18503. /**
  18504. * Sets the coefficient of restitution
  18505. */
  18506. restitution: number;
  18507. /**
  18508. * The unique id of the physics imposter
  18509. * set by the physics engine when adding this impostor to the array
  18510. */
  18511. uniqueId: number;
  18512. private _joints;
  18513. /**
  18514. * Initializes the physics imposter
  18515. * @param object The physics-enabled object used as the physics imposter
  18516. * @param type The type of the physics imposter
  18517. * @param _options The options for the physics imposter
  18518. * @param _scene The Babylon scene
  18519. */
  18520. constructor(
  18521. /**
  18522. * The physics-enabled object used as the physics imposter
  18523. */
  18524. object: IPhysicsEnabledObject,
  18525. /**
  18526. * The type of the physics imposter
  18527. */
  18528. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  18529. /**
  18530. * This function will completly initialize this impostor.
  18531. * It will create a new body - but only if this mesh has no parent.
  18532. * If it has, this impostor will not be used other than to define the impostor
  18533. * of the child mesh.
  18534. * @hidden
  18535. */ init(): void;
  18536. private _getPhysicsParent;
  18537. /**
  18538. * Should a new body be generated.
  18539. * @returns boolean specifying if body initialization is required
  18540. */
  18541. isBodyInitRequired(): boolean;
  18542. /**
  18543. * Sets the updated scaling
  18544. * @param updated Specifies if the scaling is updated
  18545. */
  18546. setScalingUpdated(): void;
  18547. /**
  18548. * Force a regeneration of this or the parent's impostor's body.
  18549. * Use under cautious - This will remove all joints already implemented.
  18550. */
  18551. forceUpdate(): void;
  18552. /**
  18553. * Gets the body that holds this impostor. Either its own, or its parent.
  18554. */
  18555. /**
  18556. * Set the physics body. Used mainly by the physics engine/plugin
  18557. */
  18558. physicsBody: any;
  18559. /**
  18560. * Get the parent of the physics imposter
  18561. * @returns Physics imposter or null
  18562. */
  18563. /**
  18564. * Sets the parent of the physics imposter
  18565. */
  18566. parent: Nullable<PhysicsImpostor>;
  18567. /**
  18568. * Resets the update flags
  18569. */
  18570. resetUpdateFlags(): void;
  18571. /**
  18572. * Gets the object extend size
  18573. * @returns the object extend size
  18574. */
  18575. getObjectExtendSize(): Vector3;
  18576. /**
  18577. * Gets the object center
  18578. * @returns The object center
  18579. */
  18580. getObjectCenter(): Vector3;
  18581. /**
  18582. * Get a specific parametes from the options parameter
  18583. * @param paramName The object parameter name
  18584. * @returns The object parameter
  18585. */
  18586. getParam(paramName: string): any;
  18587. /**
  18588. * Sets a specific parameter in the options given to the physics plugin
  18589. * @param paramName The parameter name
  18590. * @param value The value of the parameter
  18591. */
  18592. setParam(paramName: string, value: number): void;
  18593. /**
  18594. * Specifically change the body's mass option. Won't recreate the physics body object
  18595. * @param mass The mass of the physics imposter
  18596. */
  18597. setMass(mass: number): void;
  18598. /**
  18599. * Gets the linear velocity
  18600. * @returns linear velocity or null
  18601. */
  18602. getLinearVelocity(): Nullable<Vector3>;
  18603. /**
  18604. * Sets the linear velocity
  18605. * @param velocity linear velocity or null
  18606. */
  18607. setLinearVelocity(velocity: Nullable<Vector3>): void;
  18608. /**
  18609. * Gets the angular velocity
  18610. * @returns angular velocity or null
  18611. */
  18612. getAngularVelocity(): Nullable<Vector3>;
  18613. /**
  18614. * Sets the angular velocity
  18615. * @param velocity The velocity or null
  18616. */
  18617. setAngularVelocity(velocity: Nullable<Vector3>): void;
  18618. /**
  18619. * Execute a function with the physics plugin native code
  18620. * Provide a function the will have two variables - the world object and the physics body object
  18621. * @param func The function to execute with the physics plugin native code
  18622. */
  18623. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  18624. /**
  18625. * Register a function that will be executed before the physics world is stepping forward
  18626. * @param func The function to execute before the physics world is stepped forward
  18627. */
  18628. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18629. /**
  18630. * Unregister a function that will be executed before the physics world is stepping forward
  18631. * @param func The function to execute before the physics world is stepped forward
  18632. */
  18633. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18634. /**
  18635. * Register a function that will be executed after the physics step
  18636. * @param func The function to execute after physics step
  18637. */
  18638. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18639. /**
  18640. * Unregisters a function that will be executed after the physics step
  18641. * @param func The function to execute after physics step
  18642. */
  18643. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18644. /**
  18645. * register a function that will be executed when this impostor collides against a different body
  18646. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  18647. * @param func Callback that is executed on collision
  18648. */
  18649. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  18650. /**
  18651. * Unregisters the physics imposter on contact
  18652. * @param collideAgainst The physics object to collide against
  18653. * @param func Callback to execute on collision
  18654. */
  18655. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  18656. private _tmpQuat;
  18657. private _tmpQuat2;
  18658. /**
  18659. * Get the parent rotation
  18660. * @returns The parent rotation
  18661. */
  18662. getParentsRotation(): Quaternion;
  18663. /**
  18664. * this function is executed by the physics engine.
  18665. */
  18666. beforeStep: () => void;
  18667. /**
  18668. * this function is executed by the physics engine
  18669. */
  18670. afterStep: () => void;
  18671. /**
  18672. * Legacy collision detection event support
  18673. */
  18674. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  18675. /**
  18676. * event and body object due to cannon's event-based architecture.
  18677. */
  18678. onCollide: (e: {
  18679. body: any;
  18680. }) => void;
  18681. /**
  18682. * Apply a force
  18683. * @param force The force to apply
  18684. * @param contactPoint The contact point for the force
  18685. * @returns The physics imposter
  18686. */
  18687. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18688. /**
  18689. * Apply an impulse
  18690. * @param force The impulse force
  18691. * @param contactPoint The contact point for the impulse force
  18692. * @returns The physics imposter
  18693. */
  18694. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18695. /**
  18696. * A help function to create a joint
  18697. * @param otherImpostor A physics imposter used to create a joint
  18698. * @param jointType The type of joint
  18699. * @param jointData The data for the joint
  18700. * @returns The physics imposter
  18701. */
  18702. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  18703. /**
  18704. * Add a joint to this impostor with a different impostor
  18705. * @param otherImpostor A physics imposter used to add a joint
  18706. * @param joint The joint to add
  18707. * @returns The physics imposter
  18708. */
  18709. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  18710. /**
  18711. * Will keep this body still, in a sleep mode.
  18712. * @returns the physics imposter
  18713. */
  18714. sleep(): PhysicsImpostor;
  18715. /**
  18716. * Wake the body up.
  18717. * @returns The physics imposter
  18718. */
  18719. wakeUp(): PhysicsImpostor;
  18720. /**
  18721. * Clones the physics imposter
  18722. * @param newObject The physics imposter clones to this physics-enabled object
  18723. * @returns A nullable physics imposter
  18724. */
  18725. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18726. /**
  18727. * Disposes the physics imposter
  18728. */
  18729. dispose(): void;
  18730. /**
  18731. * Sets the delta position
  18732. * @param position The delta position amount
  18733. */
  18734. setDeltaPosition(position: Vector3): void;
  18735. /**
  18736. * Sets the delta rotation
  18737. * @param rotation The delta rotation amount
  18738. */
  18739. setDeltaRotation(rotation: Quaternion): void;
  18740. /**
  18741. * Gets the box size of the physics imposter and stores the result in the input parameter
  18742. * @param result Stores the box size
  18743. * @returns The physics imposter
  18744. */
  18745. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  18746. /**
  18747. * Gets the radius of the physics imposter
  18748. * @returns Radius of the physics imposter
  18749. */
  18750. getRadius(): number;
  18751. /**
  18752. * Sync a bone with this impostor
  18753. * @param bone The bone to sync to the impostor.
  18754. * @param boneMesh The mesh that the bone is influencing.
  18755. * @param jointPivot The pivot of the joint / bone in local space.
  18756. * @param distToJoint Optional distance from the impostor to the joint.
  18757. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18758. */
  18759. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  18760. /**
  18761. * Sync impostor to a bone
  18762. * @param bone The bone that the impostor will be synced to.
  18763. * @param boneMesh The mesh that the bone is influencing.
  18764. * @param jointPivot The pivot of the joint / bone in local space.
  18765. * @param distToJoint Optional distance from the impostor to the joint.
  18766. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18767. * @param boneAxis Optional vector3 axis the bone is aligned with
  18768. */
  18769. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  18770. /**
  18771. * No-Imposter type
  18772. */
  18773. static NoImpostor: number;
  18774. /**
  18775. * Sphere-Imposter type
  18776. */
  18777. static SphereImpostor: number;
  18778. /**
  18779. * Box-Imposter type
  18780. */
  18781. static BoxImpostor: number;
  18782. /**
  18783. * Plane-Imposter type
  18784. */
  18785. static PlaneImpostor: number;
  18786. /**
  18787. * Mesh-imposter type
  18788. */
  18789. static MeshImpostor: number;
  18790. /**
  18791. * Cylinder-Imposter type
  18792. */
  18793. static CylinderImpostor: number;
  18794. /**
  18795. * Particle-Imposter type
  18796. */
  18797. static ParticleImpostor: number;
  18798. /**
  18799. * Heightmap-Imposter type
  18800. */
  18801. static HeightmapImpostor: number;
  18802. }
  18803. }
  18804. declare module BABYLON {
  18805. /**
  18806. * Class used to represent a specific level of detail of a mesh
  18807. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  18808. */
  18809. export class MeshLODLevel {
  18810. /** Defines the distance where this level should star being displayed */
  18811. distance: number;
  18812. /** Defines the mesh to use to render this level */
  18813. mesh: Nullable<Mesh>;
  18814. /**
  18815. * Creates a new LOD level
  18816. * @param distance defines the distance where this level should star being displayed
  18817. * @param mesh defines the mesh to use to render this level
  18818. */
  18819. constructor(
  18820. /** Defines the distance where this level should star being displayed */
  18821. distance: number,
  18822. /** Defines the mesh to use to render this level */
  18823. mesh: Nullable<Mesh>);
  18824. }
  18825. /**
  18826. * @hidden
  18827. **/
  18828. export class _CreationDataStorage {
  18829. closePath?: boolean;
  18830. closeArray?: boolean;
  18831. idx: number[];
  18832. dashSize: number;
  18833. gapSize: number;
  18834. path3D: Path3D;
  18835. pathArray: Vector3[][];
  18836. arc: number;
  18837. radius: number;
  18838. cap: number;
  18839. tessellation: number;
  18840. }
  18841. /**
  18842. * @hidden
  18843. **/ private class _InstanceDataStorage {
  18844. visibleInstances: any;
  18845. renderIdForInstances: number[];
  18846. batchCache: _InstancesBatch;
  18847. instancesBufferSize: number;
  18848. instancesBuffer: Nullable<Buffer>;
  18849. instancesData: Float32Array;
  18850. overridenInstanceCount: number;
  18851. }
  18852. /**
  18853. * @hidden
  18854. **/
  18855. export class _InstancesBatch {
  18856. mustReturn: boolean;
  18857. visibleInstances: Nullable<InstancedMesh[]>[];
  18858. renderSelf: boolean[];
  18859. }
  18860. /**
  18861. * Class used to represent renderable models
  18862. */
  18863. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  18864. /**
  18865. * Mesh side orientation : usually the external or front surface
  18866. */
  18867. static readonly FRONTSIDE: number;
  18868. /**
  18869. * Mesh side orientation : usually the internal or back surface
  18870. */
  18871. static readonly BACKSIDE: number;
  18872. /**
  18873. * Mesh side orientation : both internal and external or front and back surfaces
  18874. */
  18875. static readonly DOUBLESIDE: number;
  18876. /**
  18877. * Mesh side orientation : by default, `FRONTSIDE`
  18878. */
  18879. static readonly DEFAULTSIDE: number;
  18880. /**
  18881. * Mesh cap setting : no cap
  18882. */
  18883. static readonly NO_CAP: number;
  18884. /**
  18885. * Mesh cap setting : one cap at the beginning of the mesh
  18886. */
  18887. static readonly CAP_START: number;
  18888. /**
  18889. * Mesh cap setting : one cap at the end of the mesh
  18890. */
  18891. static readonly CAP_END: number;
  18892. /**
  18893. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  18894. */
  18895. static readonly CAP_ALL: number;
  18896. /**
  18897. * Gets the default side orientation.
  18898. * @param orientation the orientation to value to attempt to get
  18899. * @returns the default orientation
  18900. * @hidden
  18901. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  18902. private _onBeforeRenderObservable;
  18903. private _onBeforeBindObservable;
  18904. private _onAfterRenderObservable;
  18905. private _onBeforeDrawObservable;
  18906. /**
  18907. * An event triggered before rendering the mesh
  18908. */
  18909. readonly onBeforeRenderObservable: Observable<Mesh>;
  18910. /**
  18911. * An event triggered before binding the mesh
  18912. */
  18913. readonly onBeforeBindObservable: Observable<Mesh>;
  18914. /**
  18915. * An event triggered after rendering the mesh
  18916. */
  18917. readonly onAfterRenderObservable: Observable<Mesh>;
  18918. /**
  18919. * An event triggered before drawing the mesh
  18920. */
  18921. readonly onBeforeDrawObservable: Observable<Mesh>;
  18922. private _onBeforeDrawObserver;
  18923. /**
  18924. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  18925. */
  18926. onBeforeDraw: () => void;
  18927. /**
  18928. * Gets the delay loading state of the mesh (when delay loading is turned on)
  18929. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  18930. */
  18931. delayLoadState: number;
  18932. /**
  18933. * Gets the list of instances created from this mesh
  18934. * it is not supposed to be modified manually.
  18935. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  18936. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18937. */
  18938. instances: InstancedMesh[];
  18939. /**
  18940. * Gets the file containing delay loading data for this mesh
  18941. */
  18942. delayLoadingFile: string;
  18943. /** @hidden */ binaryInfo: any;
  18944. private _LODLevels;
  18945. /**
  18946. * User defined function used to change how LOD level selection is done
  18947. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  18948. */
  18949. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  18950. private _morphTargetManager;
  18951. /**
  18952. * Gets or sets the morph target manager
  18953. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18954. */
  18955. morphTargetManager: Nullable<MorphTargetManager>;
  18956. /** @hidden */ creationDataStorage: Nullable<_CreationDataStorage>;
  18957. /** @hidden */ geometry: Nullable<Geometry>;
  18958. /** @hidden */ delayInfo: Array<string>;
  18959. /** @hidden */ delayLoadingFunction: (any: any, mesh: Mesh) => void;
  18960. /** @hidden */ instanceDataStorage: _InstanceDataStorage;
  18961. private _effectiveMaterial;
  18962. /** @hidden */ shouldGenerateFlatShading: boolean;
  18963. private _preActivateId;
  18964. /** @hidden */ originalBuilderSideOrientation: number;
  18965. /**
  18966. * Use this property to change the original side orientation defined at construction time
  18967. */
  18968. overrideMaterialSideOrientation: Nullable<number>;
  18969. private _areNormalsFrozen;
  18970. private _sourcePositions;
  18971. private _sourceNormals;
  18972. private _source;
  18973. private meshMap;
  18974. /**
  18975. * Gets the source mesh (the one used to clone this one from)
  18976. */
  18977. readonly source: Nullable<Mesh>;
  18978. /**
  18979. * Gets or sets a boolean indicating that this mesh does not use index buffer
  18980. */
  18981. isUnIndexed: boolean;
  18982. /**
  18983. * @constructor
  18984. * @param name The value used by scene.getMeshByName() to do a lookup.
  18985. * @param scene The scene to add this mesh to.
  18986. * @param parent The parent of this mesh, if it has one
  18987. * @param source An optional Mesh from which geometry is shared, cloned.
  18988. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18989. * When false, achieved by calling a clone(), also passing False.
  18990. * This will make creation of children, recursive.
  18991. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  18992. */
  18993. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  18994. /**
  18995. * Gets the class name
  18996. * @returns the string "Mesh".
  18997. */
  18998. getClassName(): string;
  18999. /** @hidden */ protected readonly _isMesh: boolean;
  19000. /**
  19001. * Returns a description of this mesh
  19002. * @param fullDetails define if full details about this mesh must be used
  19003. * @returns a descriptive string representing this mesh
  19004. */
  19005. toString(fullDetails?: boolean): string;
  19006. /** @hidden */ unBindEffect(): void;
  19007. /**
  19008. * Gets a boolean indicating if this mesh has LOD
  19009. */
  19010. readonly hasLODLevels: boolean;
  19011. /**
  19012. * Gets the list of MeshLODLevel associated with the current mesh
  19013. * @returns an array of MeshLODLevel
  19014. */
  19015. getLODLevels(): MeshLODLevel[];
  19016. private _sortLODLevels;
  19017. /**
  19018. * Add a mesh as LOD level triggered at the given distance.
  19019. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19020. * @param distance The distance from the center of the object to show this level
  19021. * @param mesh The mesh to be added as LOD level (can be null)
  19022. * @return This mesh (for chaining)
  19023. */
  19024. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19025. /**
  19026. * Returns the LOD level mesh at the passed distance or null if not found.
  19027. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19028. * @param distance The distance from the center of the object to show this level
  19029. * @returns a Mesh or `null`
  19030. */
  19031. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19032. /**
  19033. * Remove a mesh from the LOD array
  19034. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19035. * @param mesh defines the mesh to be removed
  19036. * @return This mesh (for chaining)
  19037. */
  19038. removeLODLevel(mesh: Mesh): Mesh;
  19039. /**
  19040. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19041. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19042. * @param camera defines the camera to use to compute distance
  19043. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19044. * @return This mesh (for chaining)
  19045. */
  19046. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19047. /**
  19048. * Gets the mesh internal Geometry object
  19049. */
  19050. readonly geometry: Nullable<Geometry>;
  19051. /**
  19052. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19053. * @returns the total number of vertices
  19054. */
  19055. getTotalVertices(): number;
  19056. /**
  19057. * Returns the content of an associated vertex buffer
  19058. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19059. * - VertexBuffer.PositionKind
  19060. * - VertexBuffer.UVKind
  19061. * - VertexBuffer.UV2Kind
  19062. * - VertexBuffer.UV3Kind
  19063. * - VertexBuffer.UV4Kind
  19064. * - VertexBuffer.UV5Kind
  19065. * - VertexBuffer.UV6Kind
  19066. * - VertexBuffer.ColorKind
  19067. * - VertexBuffer.MatricesIndicesKind
  19068. * - VertexBuffer.MatricesIndicesExtraKind
  19069. * - VertexBuffer.MatricesWeightsKind
  19070. * - VertexBuffer.MatricesWeightsExtraKind
  19071. * @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
  19072. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19073. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19074. */
  19075. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19076. /**
  19077. * Returns the mesh VertexBuffer object from the requested `kind`
  19078. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19079. * - VertexBuffer.PositionKind
  19080. * - VertexBuffer.UVKind
  19081. * - VertexBuffer.UV2Kind
  19082. * - VertexBuffer.UV3Kind
  19083. * - VertexBuffer.UV4Kind
  19084. * - VertexBuffer.UV5Kind
  19085. * - VertexBuffer.UV6Kind
  19086. * - VertexBuffer.ColorKind
  19087. * - VertexBuffer.MatricesIndicesKind
  19088. * - VertexBuffer.MatricesIndicesExtraKind
  19089. * - VertexBuffer.MatricesWeightsKind
  19090. * - VertexBuffer.MatricesWeightsExtraKind
  19091. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19092. */
  19093. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19094. /**
  19095. * Tests if a specific vertex buffer is associated with this mesh
  19096. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19097. * - VertexBuffer.PositionKind
  19098. * - VertexBuffer.UVKind
  19099. * - VertexBuffer.UV2Kind
  19100. * - VertexBuffer.UV3Kind
  19101. * - VertexBuffer.UV4Kind
  19102. * - VertexBuffer.UV5Kind
  19103. * - VertexBuffer.UV6Kind
  19104. * - VertexBuffer.ColorKind
  19105. * - VertexBuffer.MatricesIndicesKind
  19106. * - VertexBuffer.MatricesIndicesExtraKind
  19107. * - VertexBuffer.MatricesWeightsKind
  19108. * - VertexBuffer.MatricesWeightsExtraKind
  19109. * @returns a boolean
  19110. */
  19111. isVerticesDataPresent(kind: string): boolean;
  19112. /**
  19113. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19114. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19115. * - VertexBuffer.PositionKind
  19116. * - VertexBuffer.UVKind
  19117. * - VertexBuffer.UV2Kind
  19118. * - VertexBuffer.UV3Kind
  19119. * - VertexBuffer.UV4Kind
  19120. * - VertexBuffer.UV5Kind
  19121. * - VertexBuffer.UV6Kind
  19122. * - VertexBuffer.ColorKind
  19123. * - VertexBuffer.MatricesIndicesKind
  19124. * - VertexBuffer.MatricesIndicesExtraKind
  19125. * - VertexBuffer.MatricesWeightsKind
  19126. * - VertexBuffer.MatricesWeightsExtraKind
  19127. * @returns a boolean
  19128. */
  19129. isVertexBufferUpdatable(kind: string): boolean;
  19130. /**
  19131. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19132. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19133. * - VertexBuffer.PositionKind
  19134. * - VertexBuffer.UVKind
  19135. * - VertexBuffer.UV2Kind
  19136. * - VertexBuffer.UV3Kind
  19137. * - VertexBuffer.UV4Kind
  19138. * - VertexBuffer.UV5Kind
  19139. * - VertexBuffer.UV6Kind
  19140. * - VertexBuffer.ColorKind
  19141. * - VertexBuffer.MatricesIndicesKind
  19142. * - VertexBuffer.MatricesIndicesExtraKind
  19143. * - VertexBuffer.MatricesWeightsKind
  19144. * - VertexBuffer.MatricesWeightsExtraKind
  19145. * @returns an array of strings
  19146. */
  19147. getVerticesDataKinds(): string[];
  19148. /**
  19149. * Returns a positive integer : the total number of indices in this mesh geometry.
  19150. * @returns the numner of indices or zero if the mesh has no geometry.
  19151. */
  19152. getTotalIndices(): number;
  19153. /**
  19154. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19155. * @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.
  19156. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19157. * @returns the indices array or an empty array if the mesh has no geometry
  19158. */
  19159. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19160. readonly isBlocked: boolean;
  19161. /**
  19162. * Determine if the current mesh is ready to be rendered
  19163. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19164. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19165. * @returns true if all associated assets are ready (material, textures, shaders)
  19166. */
  19167. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19168. /**
  19169. * 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.
  19170. */
  19171. readonly areNormalsFrozen: boolean;
  19172. /**
  19173. * 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.
  19174. * @returns the current mesh
  19175. */
  19176. freezeNormals(): Mesh;
  19177. /**
  19178. * 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
  19179. * @returns the current mesh
  19180. */
  19181. unfreezeNormals(): Mesh;
  19182. /**
  19183. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19184. */
  19185. overridenInstanceCount: number;
  19186. /** @hidden */ preActivate(): Mesh;
  19187. /** @hidden */ preActivateForIntermediateRendering(renderId: number): Mesh;
  19188. /** @hidden */ registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19189. /**
  19190. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19191. * This means the mesh underlying bounding box and sphere are recomputed.
  19192. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19193. * @returns the current mesh
  19194. */
  19195. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19196. /** @hidden */ createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19197. /**
  19198. * This function will subdivide the mesh into multiple submeshes
  19199. * @param count defines the expected number of submeshes
  19200. */
  19201. subdivide(count: number): void;
  19202. /**
  19203. * Copy a FloatArray into a specific associated vertex buffer
  19204. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19205. * - VertexBuffer.PositionKind
  19206. * - VertexBuffer.UVKind
  19207. * - VertexBuffer.UV2Kind
  19208. * - VertexBuffer.UV3Kind
  19209. * - VertexBuffer.UV4Kind
  19210. * - VertexBuffer.UV5Kind
  19211. * - VertexBuffer.UV6Kind
  19212. * - VertexBuffer.ColorKind
  19213. * - VertexBuffer.MatricesIndicesKind
  19214. * - VertexBuffer.MatricesIndicesExtraKind
  19215. * - VertexBuffer.MatricesWeightsKind
  19216. * - VertexBuffer.MatricesWeightsExtraKind
  19217. * @param data defines the data source
  19218. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19219. * @param stride defines the data stride size (can be null)
  19220. * @returns the current mesh
  19221. */
  19222. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19223. /**
  19224. * Flags an associated vertex buffer as updatable
  19225. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  19226. * - VertexBuffer.PositionKind
  19227. * - VertexBuffer.UVKind
  19228. * - VertexBuffer.UV2Kind
  19229. * - VertexBuffer.UV3Kind
  19230. * - VertexBuffer.UV4Kind
  19231. * - VertexBuffer.UV5Kind
  19232. * - VertexBuffer.UV6Kind
  19233. * - VertexBuffer.ColorKind
  19234. * - VertexBuffer.MatricesIndicesKind
  19235. * - VertexBuffer.MatricesIndicesExtraKind
  19236. * - VertexBuffer.MatricesWeightsKind
  19237. * - VertexBuffer.MatricesWeightsExtraKind
  19238. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19239. */
  19240. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  19241. /**
  19242. * Sets the mesh global Vertex Buffer
  19243. * @param buffer defines the buffer to use
  19244. * @returns the current mesh
  19245. */
  19246. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  19247. /**
  19248. * Update a specific associated vertex buffer
  19249. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19250. * - VertexBuffer.PositionKind
  19251. * - VertexBuffer.UVKind
  19252. * - VertexBuffer.UV2Kind
  19253. * - VertexBuffer.UV3Kind
  19254. * - VertexBuffer.UV4Kind
  19255. * - VertexBuffer.UV5Kind
  19256. * - VertexBuffer.UV6Kind
  19257. * - VertexBuffer.ColorKind
  19258. * - VertexBuffer.MatricesIndicesKind
  19259. * - VertexBuffer.MatricesIndicesExtraKind
  19260. * - VertexBuffer.MatricesWeightsKind
  19261. * - VertexBuffer.MatricesWeightsExtraKind
  19262. * @param data defines the data source
  19263. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  19264. * @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)
  19265. * @returns the current mesh
  19266. */
  19267. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19268. /**
  19269. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  19270. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  19271. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  19272. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  19273. * @returns the current mesh
  19274. */
  19275. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  19276. /**
  19277. * Creates a un-shared specific occurence of the geometry for the mesh.
  19278. * @returns the current mesh
  19279. */
  19280. makeGeometryUnique(): Mesh;
  19281. /**
  19282. * Set the index buffer of this mesh
  19283. * @param indices defines the source data
  19284. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  19285. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  19286. * @returns the current mesh
  19287. */
  19288. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  19289. /**
  19290. * Update the current index buffer
  19291. * @param indices defines the source data
  19292. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  19293. * @returns the current mesh
  19294. */
  19295. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  19296. /**
  19297. * Invert the geometry to move from a right handed system to a left handed one.
  19298. * @returns the current mesh
  19299. */
  19300. toLeftHanded(): Mesh;
  19301. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19302. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  19303. /**
  19304. * Registers for this mesh a javascript function called just before the rendering process
  19305. * @param func defines the function to call before rendering this mesh
  19306. * @returns the current mesh
  19307. */
  19308. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19309. /**
  19310. * Disposes a previously registered javascript function called before the rendering
  19311. * @param func defines the function to remove
  19312. * @returns the current mesh
  19313. */
  19314. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19315. /**
  19316. * Registers for this mesh a javascript function called just after the rendering is complete
  19317. * @param func defines the function to call after rendering this mesh
  19318. * @returns the current mesh
  19319. */
  19320. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19321. /**
  19322. * Disposes a previously registered javascript function called after the rendering.
  19323. * @param func defines the function to remove
  19324. * @returns the current mesh
  19325. */
  19326. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19327. /** @hidden */ getInstancesRenderList(subMeshId: number): _InstancesBatch;
  19328. /** @hidden */ renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  19329. /** @hidden */ processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  19330. /**
  19331. * 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
  19332. * @param subMesh defines the subMesh to render
  19333. * @param enableAlphaMode defines if alpha mode can be changed
  19334. * @returns the current mesh
  19335. */
  19336. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  19337. private _onBeforeDraw;
  19338. /**
  19339. * Renormalize the mesh and patch it up if there are no weights
  19340. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  19341. * However in the case of zero weights then we set just a single influence to 1.
  19342. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  19343. */
  19344. cleanMatrixWeights(): void;
  19345. private normalizeSkinFourWeights;
  19346. private normalizeSkinWeightsAndExtra;
  19347. /**
  19348. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  19349. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  19350. * the user know there was an issue with importing the mesh
  19351. * @returns a validation object with skinned, valid and report string
  19352. */
  19353. validateSkinning(): {
  19354. skinned: boolean;
  19355. valid: boolean;
  19356. report: string;
  19357. };
  19358. /** @hidden */ checkDelayState(): Mesh;
  19359. private _queueLoad;
  19360. /**
  19361. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19362. * A mesh is in the frustum if its bounding box intersects the frustum
  19363. * @param frustumPlanes defines the frustum to test
  19364. * @returns true if the mesh is in the frustum planes
  19365. */
  19366. isInFrustum(frustumPlanes: Plane[]): boolean;
  19367. /**
  19368. * Sets the mesh material by the material or multiMaterial `id` property
  19369. * @param id is a string identifying the material or the multiMaterial
  19370. * @returns the current mesh
  19371. */
  19372. setMaterialByID(id: string): Mesh;
  19373. /**
  19374. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  19375. * @returns an array of IAnimatable
  19376. */
  19377. getAnimatables(): IAnimatable[];
  19378. /**
  19379. * Modifies the mesh geometry according to the passed transformation matrix.
  19380. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  19381. * The mesh normals are modified using the same transformation.
  19382. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19383. * @param transform defines the transform matrix to use
  19384. * @see http://doc.babylonjs.com/resources/baking_transformations
  19385. * @returns the current mesh
  19386. */
  19387. bakeTransformIntoVertices(transform: Matrix): Mesh;
  19388. /**
  19389. * Modifies the mesh geometry according to its own current World Matrix.
  19390. * The mesh World Matrix is then reset.
  19391. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  19392. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19393. * @see http://doc.babylonjs.com/resources/baking_transformations
  19394. * @returns the current mesh
  19395. */
  19396. bakeCurrentTransformIntoVertices(): Mesh;
  19397. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  19398. /** @hidden */ resetPointsArrayCache(): Mesh;
  19399. /** @hidden */ generatePointsArray(): boolean;
  19400. /**
  19401. * Returns a new Mesh object generated from the current mesh properties.
  19402. * This method must not get confused with createInstance()
  19403. * @param name is a string, the name given to the new mesh
  19404. * @param newParent can be any Node object (default `null`)
  19405. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  19406. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  19407. * @returns a new mesh
  19408. */
  19409. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  19410. /**
  19411. * Releases resources associated with this mesh.
  19412. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19413. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19414. */
  19415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19416. /**
  19417. * Modifies the mesh geometry according to a displacement map.
  19418. * 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.
  19419. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19420. * @param url is a string, the URL from the image file is to be downloaded.
  19421. * @param minHeight is the lower limit of the displacement.
  19422. * @param maxHeight is the upper limit of the displacement.
  19423. * @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.
  19424. * @param uvOffset is an optional vector2 used to offset UV.
  19425. * @param uvScale is an optional vector2 used to scale UV.
  19426. * @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.
  19427. * @returns the Mesh.
  19428. */
  19429. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19430. /**
  19431. * Modifies the mesh geometry according to a displacementMap buffer.
  19432. * 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.
  19433. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19434. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  19435. * @param heightMapWidth is the width of the buffer image.
  19436. * @param heightMapHeight is the height of the buffer image.
  19437. * @param minHeight is the lower limit of the displacement.
  19438. * @param maxHeight is the upper limit of the displacement.
  19439. * @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.
  19440. * @param uvOffset is an optional vector2 used to offset UV.
  19441. * @param uvScale is an optional vector2 used to scale UV.
  19442. * @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.
  19443. * @returns the Mesh.
  19444. */
  19445. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19446. /**
  19447. * Modify the mesh to get a flat shading rendering.
  19448. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  19449. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  19450. * @returns current mesh
  19451. */
  19452. convertToFlatShadedMesh(): Mesh;
  19453. /**
  19454. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  19455. * In other words, more vertices, no more indices and a single bigger VBO.
  19456. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  19457. * @returns current mesh
  19458. */
  19459. convertToUnIndexedMesh(): Mesh;
  19460. /**
  19461. * Inverses facet orientations.
  19462. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  19463. * @param flipNormals will also inverts the normals
  19464. * @returns current mesh
  19465. */
  19466. flipFaces(flipNormals?: boolean): Mesh;
  19467. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  19468. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  19469. /**
  19470. * Creates a new InstancedMesh object from the mesh model.
  19471. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19472. * @param name defines the name of the new instance
  19473. * @returns a new InstancedMesh
  19474. */
  19475. createInstance(name: string): InstancedMesh;
  19476. /**
  19477. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  19478. * After this call, all the mesh instances have the same submeshes than the current mesh.
  19479. * @returns the current mesh
  19480. */
  19481. synchronizeInstances(): Mesh;
  19482. /**
  19483. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  19484. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  19485. * This should be used together with the simplification to avoid disappearing triangles.
  19486. * @param successCallback an optional success callback to be called after the optimization finished.
  19487. * @returns the current mesh
  19488. */
  19489. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  19490. /**
  19491. * Serialize current mesh
  19492. * @param serializationObject defines the object which will receive the serialization data
  19493. */
  19494. serialize(serializationObject: any): void;
  19495. /** @hidden */ syncGeometryWithMorphTargetManager(): void;
  19496. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  19497. /**
  19498. * Returns a new Mesh object parsed from the source provided.
  19499. * @param parsedMesh is the source
  19500. * @param scene defines the hosting scene
  19501. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  19502. * @returns a new Mesh
  19503. */
  19504. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  19505. /**
  19506. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  19507. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19508. * @param name defines the name of the mesh to create
  19509. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  19510. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  19511. * @param closePath creates a seam between the first and the last points of each path of the path array
  19512. * @param offset is taken in account only if the `pathArray` is containing a single path
  19513. * @param scene defines the hosting scene
  19514. * @param updatable defines if the mesh must be flagged as updatable
  19515. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19516. * @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)
  19517. * @returns a new Mesh
  19518. */
  19519. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19520. /**
  19521. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  19522. * @param name defines the name of the mesh to create
  19523. * @param radius sets the radius size (float) of the polygon (default 0.5)
  19524. * @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
  19525. * @param scene defines the hosting scene
  19526. * @param updatable defines if the mesh must be flagged as updatable
  19527. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19528. * @returns a new Mesh
  19529. */
  19530. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19531. /**
  19532. * Creates a box 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 size sets the size (float) of each box side (default 1)
  19535. * @param scene defines the hosting scene
  19536. * @param updatable defines if the mesh must be flagged as updatable
  19537. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19538. * @returns a new Mesh
  19539. */
  19540. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19541. /**
  19542. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  19543. * @param name defines the name of the mesh to create
  19544. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  19545. * @param diameter sets the diameter size (float) of the sphere (default 1)
  19546. * @param scene defines the hosting scene
  19547. * @param updatable defines if the mesh must be flagged as updatable
  19548. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19549. * @returns a new Mesh
  19550. */
  19551. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19552. /**
  19553. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  19554. * @param name defines the name of the mesh to create
  19555. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  19556. * @param diameterTop set the top cap diameter (floats, default 1)
  19557. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  19558. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  19559. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  19560. * @param scene defines the hosting scene
  19561. * @param updatable defines if the mesh must be flagged as updatable
  19562. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19563. * @returns a new Mesh
  19564. */
  19565. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  19566. /**
  19567. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  19568. * @param name defines the name of the mesh to create
  19569. * @param diameter sets the diameter size (float) of the torus (default 1)
  19570. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  19571. * @param tessellation sets the number of torus sides (postive integer, default 16)
  19572. * @param scene defines the hosting scene
  19573. * @param updatable defines if the mesh must be flagged as updatable
  19574. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19575. * @returns a new Mesh
  19576. */
  19577. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19578. /**
  19579. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  19580. * @param name defines the name of the mesh to create
  19581. * @param radius sets the global radius size (float) of the torus knot (default 2)
  19582. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  19583. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  19584. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  19585. * @param p the number of windings on X axis (positive integers, default 2)
  19586. * @param q the number of windings on Y axis (positive integers, default 3)
  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. * @returns a new Mesh
  19591. */
  19592. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19593. /**
  19594. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  19595. * @param name defines the name of the mesh to create
  19596. * @param points is an array successive Vector3
  19597. * @param scene defines the hosting scene
  19598. * @param updatable defines if the mesh must be flagged as updatable
  19599. * @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).
  19600. * @returns a new Mesh
  19601. */
  19602. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  19603. /**
  19604. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  19605. * @param name defines the name of the mesh to create
  19606. * @param points is an array successive Vector3
  19607. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  19608. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  19609. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  19610. * @param scene defines the hosting scene
  19611. * @param updatable defines if the mesh must be flagged as updatable
  19612. * @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)
  19613. * @returns a new Mesh
  19614. */
  19615. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  19616. /**
  19617. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  19618. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  19619. * 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.
  19620. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19621. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19622. * Remember you can only change the shape positions, not their number when updating a polygon.
  19623. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  19624. * @param name defines the name of the mesh to create
  19625. * @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
  19626. * @param scene defines the hosting scene
  19627. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19628. * @param updatable defines if the mesh must be flagged as updatable
  19629. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19630. * @param earcutInjection can be used to inject your own earcut reference
  19631. * @returns a new Mesh
  19632. */
  19633. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  19634. /**
  19635. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  19636. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  19637. * @param name defines the name of the mesh to create
  19638. * @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
  19639. * @param depth defines the height of extrusion
  19640. * @param scene defines the hosting scene
  19641. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19642. * @param updatable defines if the mesh must be flagged as updatable
  19643. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19644. * @param earcutInjection can be used to inject your own earcut reference
  19645. * @returns a new Mesh
  19646. */
  19647. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  19648. /**
  19649. * Creates an extruded shape mesh.
  19650. * 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
  19651. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19652. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19653. * @param name defines the name of the mesh to create
  19654. * @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
  19655. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19656. * @param scale is the value to scale the shape
  19657. * @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
  19658. * @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
  19659. * @param scene defines the hosting scene
  19660. * @param updatable defines if the mesh must be flagged as updatable
  19661. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19662. * @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)
  19663. * @returns a new Mesh
  19664. */
  19665. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19666. /**
  19667. * Creates an custom extruded shape mesh.
  19668. * The custom extrusion is a parametric shape.
  19669. * It has no predefined shape. Its final shape will depend on the input parameters.
  19670. * Please consider using the same method from the MeshBuilder class instead
  19671. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19672. * @param name defines the name of the mesh to create
  19673. * @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
  19674. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19675. * @param scaleFunction is a custom Javascript function called on each path point
  19676. * @param rotationFunction is a custom Javascript function called on each path point
  19677. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  19678. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  19679. * @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
  19680. * @param scene defines the hosting scene
  19681. * @param updatable defines if the mesh must be flagged as updatable
  19682. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19683. * @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)
  19684. * @returns a new Mesh
  19685. */
  19686. 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;
  19687. /**
  19688. * Creates lathe mesh.
  19689. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  19690. * Please consider using the same method from the MeshBuilder class instead
  19691. * @param name defines the name of the mesh to create
  19692. * @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
  19693. * @param radius is the radius value of the lathe
  19694. * @param tessellation is the side number of the lathe.
  19695. * @param scene defines the hosting scene
  19696. * @param updatable defines if the mesh must be flagged as updatable
  19697. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19698. * @returns a new Mesh
  19699. */
  19700. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19701. /**
  19702. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  19703. * @param name defines the name of the mesh to create
  19704. * @param size sets the size (float) of both sides of the plane at once (default 1)
  19705. * @param scene defines the hosting scene
  19706. * @param updatable defines if the mesh must be flagged as updatable
  19707. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19708. * @returns a new Mesh
  19709. */
  19710. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19711. /**
  19712. * Creates a ground mesh.
  19713. * Please consider using the same method from the MeshBuilder class instead
  19714. * @param name defines the name of the mesh to create
  19715. * @param width set the width of the ground
  19716. * @param height set the height of the ground
  19717. * @param subdivisions sets the number of subdivisions per side
  19718. * @param scene defines the hosting scene
  19719. * @param updatable defines if the mesh must be flagged as updatable
  19720. * @returns a new Mesh
  19721. */
  19722. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  19723. /**
  19724. * Creates a tiled ground mesh.
  19725. * Please consider using the same method from the MeshBuilder class instead
  19726. * @param name defines the name of the mesh to create
  19727. * @param xmin set the ground minimum X coordinate
  19728. * @param zmin set the ground minimum Y coordinate
  19729. * @param xmax set the ground maximum X coordinate
  19730. * @param zmax set the ground maximum Z coordinate
  19731. * @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
  19732. * @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
  19733. * @param scene defines the hosting scene
  19734. * @param updatable defines if the mesh must be flagged as updatable
  19735. * @returns a new Mesh
  19736. */
  19737. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  19738. w: number;
  19739. h: number;
  19740. }, precision: {
  19741. w: number;
  19742. h: number;
  19743. }, scene: Scene, updatable?: boolean): Mesh;
  19744. /**
  19745. * Creates a ground mesh from a height map.
  19746. * Please consider using the same method from the MeshBuilder class instead
  19747. * @see http://doc.babylonjs.com/babylon101/height_map
  19748. * @param name defines the name of the mesh to create
  19749. * @param url sets the URL of the height map image resource
  19750. * @param width set the ground width size
  19751. * @param height set the ground height size
  19752. * @param subdivisions sets the number of subdivision per side
  19753. * @param minHeight is the minimum altitude on the ground
  19754. * @param maxHeight is the maximum altitude on the ground
  19755. * @param scene defines the hosting scene
  19756. * @param updatable defines if the mesh must be flagged as updatable
  19757. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  19758. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  19759. * @returns a new Mesh
  19760. */
  19761. 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;
  19762. /**
  19763. * Creates a tube mesh.
  19764. * The tube is a parametric shape.
  19765. * It has no predefined shape. Its final shape will depend on the input parameters.
  19766. * Please consider using the same method from the MeshBuilder class instead
  19767. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19768. * @param name defines the name of the mesh to create
  19769. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  19770. * @param radius sets the tube radius size
  19771. * @param tessellation is the number of sides on the tubular surface
  19772. * @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
  19773. * @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
  19774. * @param scene defines the hosting scene
  19775. * @param updatable defines if the mesh must be flagged as updatable
  19776. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19777. * @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)
  19778. * @returns a new Mesh
  19779. */
  19780. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  19781. (i: number, distance: number): number;
  19782. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19783. /**
  19784. * Creates a polyhedron mesh.
  19785. * Please consider using the same method from the MeshBuilder class instead.
  19786. * * 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
  19787. * * The parameter `size` (positive float, default 1) sets the polygon size
  19788. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  19789. * * 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`
  19790. * * 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
  19791. * * 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)`)
  19792. * * 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
  19793. * * 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
  19794. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19795. * * 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
  19796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19797. * @param name defines the name of the mesh to create
  19798. * @param options defines the options used to create the mesh
  19799. * @param scene defines the hosting scene
  19800. * @returns a new Mesh
  19801. */
  19802. static CreatePolyhedron(name: string, options: {
  19803. type?: number;
  19804. size?: number;
  19805. sizeX?: number;
  19806. sizeY?: number;
  19807. sizeZ?: number;
  19808. custom?: any;
  19809. faceUV?: Vector4[];
  19810. faceColors?: Color4[];
  19811. updatable?: boolean;
  19812. sideOrientation?: number;
  19813. }, scene: Scene): Mesh;
  19814. /**
  19815. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  19816. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  19817. * * 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`)
  19818. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  19819. * * 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
  19820. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19821. * * 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
  19822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19823. * @param name defines the name of the mesh
  19824. * @param options defines the options used to create the mesh
  19825. * @param scene defines the hosting scene
  19826. * @returns a new Mesh
  19827. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  19828. */
  19829. static CreateIcoSphere(name: string, options: {
  19830. radius?: number;
  19831. flat?: boolean;
  19832. subdivisions?: number;
  19833. sideOrientation?: number;
  19834. updatable?: boolean;
  19835. }, scene: Scene): Mesh;
  19836. /**
  19837. * Creates a decal mesh.
  19838. * Please consider using the same method from the MeshBuilder class instead.
  19839. * A decal is a mesh usually applied as a model onto the surface of another mesh
  19840. * @param name defines the name of the mesh
  19841. * @param sourceMesh defines the mesh receiving the decal
  19842. * @param position sets the position of the decal in world coordinates
  19843. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  19844. * @param size sets the decal scaling
  19845. * @param angle sets the angle to rotate the decal
  19846. * @returns a new Mesh
  19847. */
  19848. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  19849. /**
  19850. * Prepare internal position array for software CPU skinning
  19851. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  19852. */
  19853. setPositionsForCPUSkinning(): Float32Array;
  19854. /**
  19855. * Prepare internal normal array for software CPU skinning
  19856. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  19857. */
  19858. setNormalsForCPUSkinning(): Float32Array;
  19859. /**
  19860. * Updates the vertex buffer by applying transformation from the bones
  19861. * @param skeleton defines the skeleton to apply to current mesh
  19862. * @returns the current mesh
  19863. */
  19864. applySkeleton(skeleton: Skeleton): Mesh;
  19865. /**
  19866. * 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
  19867. * @param meshes defines the list of meshes to scan
  19868. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  19869. */
  19870. static MinMax(meshes: AbstractMesh[]): {
  19871. min: Vector3;
  19872. max: Vector3;
  19873. };
  19874. /**
  19875. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  19876. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  19877. * @returns a vector3
  19878. */
  19879. static Center(meshesOrMinMaxVector: {
  19880. min: Vector3;
  19881. max: Vector3;
  19882. } | AbstractMesh[]): Vector3;
  19883. /**
  19884. * Merge the array of meshes into a single mesh for performance reasons.
  19885. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  19886. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  19887. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  19888. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  19889. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  19890. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  19891. * @returns a new mesh
  19892. */
  19893. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  19894. /** @hidden */
  19895. addInstance(instance: InstancedMesh): void;
  19896. /** @hidden */
  19897. removeInstance(instance: InstancedMesh): void;
  19898. }
  19899. }
  19900. declare module BABYLON {
  19901. /**
  19902. * Base class for the main features of a material in Babylon.js
  19903. */
  19904. export class Material implements IAnimatable {
  19905. /**
  19906. * Returns the triangle fill mode
  19907. */
  19908. static readonly TriangleFillMode: number;
  19909. /**
  19910. * Returns the wireframe mode
  19911. */
  19912. static readonly WireFrameFillMode: number;
  19913. /**
  19914. * Returns the point fill mode
  19915. */
  19916. static readonly PointFillMode: number;
  19917. /**
  19918. * Returns the point list draw mode
  19919. */
  19920. static readonly PointListDrawMode: number;
  19921. /**
  19922. * Returns the line list draw mode
  19923. */
  19924. static readonly LineListDrawMode: number;
  19925. /**
  19926. * Returns the line loop draw mode
  19927. */
  19928. static readonly LineLoopDrawMode: number;
  19929. /**
  19930. * Returns the line strip draw mode
  19931. */
  19932. static readonly LineStripDrawMode: number;
  19933. /**
  19934. * Returns the triangle strip draw mode
  19935. */
  19936. static readonly TriangleStripDrawMode: number;
  19937. /**
  19938. * Returns the triangle fan draw mode
  19939. */
  19940. static readonly TriangleFanDrawMode: number;
  19941. /**
  19942. * Stores the clock-wise side orientation
  19943. */
  19944. static readonly ClockWiseSideOrientation: number;
  19945. /**
  19946. * Stores the counter clock-wise side orientation
  19947. */
  19948. static readonly CounterClockWiseSideOrientation: number;
  19949. /**
  19950. * The dirty texture flag value
  19951. */
  19952. static readonly TextureDirtyFlag: number;
  19953. /**
  19954. * The dirty light flag value
  19955. */
  19956. static readonly LightDirtyFlag: number;
  19957. /**
  19958. * The dirty fresnel flag value
  19959. */
  19960. static readonly FresnelDirtyFlag: number;
  19961. /**
  19962. * The dirty attribute flag value
  19963. */
  19964. static readonly AttributesDirtyFlag: number;
  19965. /**
  19966. * The dirty misc flag value
  19967. */
  19968. static readonly MiscDirtyFlag: number;
  19969. /**
  19970. * The all dirty flag value
  19971. */
  19972. static readonly AllDirtyFlag: number;
  19973. /**
  19974. * The ID of the material
  19975. */
  19976. id: string;
  19977. /**
  19978. * Gets or sets the unique id of the material
  19979. */
  19980. uniqueId: number;
  19981. /**
  19982. * The name of the material
  19983. */
  19984. name: string;
  19985. /**
  19986. * Gets or sets user defined metadata
  19987. */
  19988. metadata: any;
  19989. /**
  19990. * For internal use only. Please do not use.
  19991. */
  19992. reservedDataStore: any;
  19993. /**
  19994. * Specifies if the ready state should be checked on each call
  19995. */
  19996. checkReadyOnEveryCall: boolean;
  19997. /**
  19998. * Specifies if the ready state should be checked once
  19999. */
  20000. checkReadyOnlyOnce: boolean;
  20001. /**
  20002. * The state of the material
  20003. */
  20004. state: string;
  20005. /**
  20006. * The alpha value of the material
  20007. */
  20008. protected _alpha: number;
  20009. /**
  20010. * Sets the alpha value of the material
  20011. */
  20012. /**
  20013. * Gets the alpha value of the material
  20014. */
  20015. alpha: number;
  20016. /**
  20017. * Specifies if back face culling is enabled
  20018. */
  20019. protected _backFaceCulling: boolean;
  20020. /**
  20021. * Sets the back-face culling state
  20022. */
  20023. /**
  20024. * Gets the back-face culling state
  20025. */
  20026. backFaceCulling: boolean;
  20027. /**
  20028. * Stores the value for side orientation
  20029. */
  20030. sideOrientation: number;
  20031. /**
  20032. * Callback triggered when the material is compiled
  20033. */
  20034. onCompiled: (effect: Effect) => void;
  20035. /**
  20036. * Callback triggered when an error occurs
  20037. */
  20038. onError: (effect: Effect, errors: string) => void;
  20039. /**
  20040. * Callback triggered to get the render target textures
  20041. */
  20042. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  20043. /**
  20044. * Gets a boolean indicating that current material needs to register RTT
  20045. */
  20046. readonly hasRenderTargetTextures: boolean;
  20047. /**
  20048. * Specifies if the material should be serialized
  20049. */
  20050. doNotSerialize: boolean;
  20051. /**
  20052. * @hidden
  20053. */ storeEffectOnSubMeshes: boolean;
  20054. /**
  20055. * Stores the animations for the material
  20056. */
  20057. animations: Array<Animation>;
  20058. /**
  20059. * An event triggered when the material is disposed
  20060. */
  20061. onDisposeObservable: Observable<Material>;
  20062. /**
  20063. * An observer which watches for dispose events
  20064. */
  20065. private _onDisposeObserver;
  20066. private _onUnBindObservable;
  20067. /**
  20068. * Called during a dispose event
  20069. */
  20070. onDispose: () => void;
  20071. private _onBindObservable;
  20072. /**
  20073. * An event triggered when the material is bound
  20074. */
  20075. readonly onBindObservable: Observable<AbstractMesh>;
  20076. /**
  20077. * An observer which watches for bind events
  20078. */
  20079. private _onBindObserver;
  20080. /**
  20081. * Called during a bind event
  20082. */
  20083. onBind: (Mesh: AbstractMesh) => void;
  20084. /**
  20085. * An event triggered when the material is unbound
  20086. */
  20087. readonly onUnBindObservable: Observable<Material>;
  20088. /**
  20089. * Stores the value of the alpha mode
  20090. */
  20091. private _alphaMode;
  20092. /**
  20093. * Sets the value of the alpha mode.
  20094. *
  20095. * | Value | Type | Description |
  20096. * | --- | --- | --- |
  20097. * | 0 | ALPHA_DISABLE | |
  20098. * | 1 | ALPHA_ADD | |
  20099. * | 2 | ALPHA_COMBINE | |
  20100. * | 3 | ALPHA_SUBTRACT | |
  20101. * | 4 | ALPHA_MULTIPLY | |
  20102. * | 5 | ALPHA_MAXIMIZED | |
  20103. * | 6 | ALPHA_ONEONE | |
  20104. * | 7 | ALPHA_PREMULTIPLIED | |
  20105. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20106. * | 9 | ALPHA_INTERPOLATE | |
  20107. * | 10 | ALPHA_SCREENMODE | |
  20108. *
  20109. */
  20110. /**
  20111. * Gets the value of the alpha mode
  20112. */
  20113. alphaMode: number;
  20114. /**
  20115. * Stores the state of the need depth pre-pass value
  20116. */
  20117. private _needDepthPrePass;
  20118. /**
  20119. * Sets the need depth pre-pass value
  20120. */
  20121. /**
  20122. * Gets the depth pre-pass value
  20123. */
  20124. needDepthPrePass: boolean;
  20125. /**
  20126. * Specifies if depth writing should be disabled
  20127. */
  20128. disableDepthWrite: boolean;
  20129. /**
  20130. * Specifies if depth writing should be forced
  20131. */
  20132. forceDepthWrite: boolean;
  20133. /**
  20134. * Specifies if there should be a separate pass for culling
  20135. */
  20136. separateCullingPass: boolean;
  20137. /**
  20138. * Stores the state specifing if fog should be enabled
  20139. */
  20140. private _fogEnabled;
  20141. /**
  20142. * Sets the state for enabling fog
  20143. */
  20144. /**
  20145. * Gets the value of the fog enabled state
  20146. */
  20147. fogEnabled: boolean;
  20148. /**
  20149. * Stores the size of points
  20150. */
  20151. pointSize: number;
  20152. /**
  20153. * Stores the z offset value
  20154. */
  20155. zOffset: number;
  20156. /**
  20157. * Gets a value specifying if wireframe mode is enabled
  20158. */
  20159. /**
  20160. * Sets the state of wireframe mode
  20161. */
  20162. wireframe: boolean;
  20163. /**
  20164. * Gets the value specifying if point clouds are enabled
  20165. */
  20166. /**
  20167. * Sets the state of point cloud mode
  20168. */
  20169. pointsCloud: boolean;
  20170. /**
  20171. * Gets the material fill mode
  20172. */
  20173. /**
  20174. * Sets the material fill mode
  20175. */
  20176. fillMode: number;
  20177. /**
  20178. * @hidden
  20179. * Stores the effects for the material
  20180. */ effect: Nullable<Effect>;
  20181. /**
  20182. * @hidden
  20183. * Specifies if the material was previously ready
  20184. */ wasPreviouslyReady: boolean;
  20185. /**
  20186. * Specifies if uniform buffers should be used
  20187. */
  20188. private _useUBO;
  20189. /**
  20190. * Stores a reference to the scene
  20191. */
  20192. private _scene;
  20193. /**
  20194. * Stores the fill mode state
  20195. */
  20196. private _fillMode;
  20197. /**
  20198. * Specifies if the depth write state should be cached
  20199. */
  20200. private _cachedDepthWriteState;
  20201. /**
  20202. * Stores the uniform buffer
  20203. */
  20204. protected _uniformBuffer: UniformBuffer;
  20205. /** @hidden */ indexInSceneMaterialArray: number;
  20206. /** @hidden */
  20207. meshMap: Nullable<{
  20208. [id: string]: AbstractMesh | undefined;
  20209. }>;
  20210. /**
  20211. * Creates a material instance
  20212. * @param name defines the name of the material
  20213. * @param scene defines the scene to reference
  20214. * @param doNotAdd specifies if the material should be added to the scene
  20215. */
  20216. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20217. /**
  20218. * Returns a string representation of the current material
  20219. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20220. * @returns a string with material information
  20221. */
  20222. toString(fullDetails?: boolean): string;
  20223. /**
  20224. * Gets the class name of the material
  20225. * @returns a string with the class name of the material
  20226. */
  20227. getClassName(): string;
  20228. /**
  20229. * Specifies if updates for the material been locked
  20230. */
  20231. readonly isFrozen: boolean;
  20232. /**
  20233. * Locks updates for the material
  20234. */
  20235. freeze(): void;
  20236. /**
  20237. * Unlocks updates for the material
  20238. */
  20239. unfreeze(): void;
  20240. /**
  20241. * Specifies if the material is ready to be used
  20242. * @param mesh defines the mesh to check
  20243. * @param useInstances specifies if instances should be used
  20244. * @returns a boolean indicating if the material is ready to be used
  20245. */
  20246. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20247. /**
  20248. * Specifies that the submesh is ready to be used
  20249. * @param mesh defines the mesh to check
  20250. * @param subMesh defines which submesh to check
  20251. * @param useInstances specifies that instances should be used
  20252. * @returns a boolean indicating that the submesh is ready or not
  20253. */
  20254. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20255. /**
  20256. * Returns the material effect
  20257. * @returns the effect associated with the material
  20258. */
  20259. getEffect(): Nullable<Effect>;
  20260. /**
  20261. * Returns the current scene
  20262. * @returns a Scene
  20263. */
  20264. getScene(): Scene;
  20265. /**
  20266. * Specifies if the material will require alpha blending
  20267. * @returns a boolean specifying if alpha blending is needed
  20268. */
  20269. needAlphaBlending(): boolean;
  20270. /**
  20271. * Specifies if the mesh will require alpha blending
  20272. * @param mesh defines the mesh to check
  20273. * @returns a boolean specifying if alpha blending is needed for the mesh
  20274. */
  20275. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20276. /**
  20277. * Specifies if this material should be rendered in alpha test mode
  20278. * @returns a boolean specifying if an alpha test is needed.
  20279. */
  20280. needAlphaTesting(): boolean;
  20281. /**
  20282. * Gets the texture used for the alpha test
  20283. * @returns the texture to use for alpha testing
  20284. */
  20285. getAlphaTestTexture(): Nullable<BaseTexture>;
  20286. /**
  20287. * Marks the material to indicate that it needs to be re-calculated
  20288. */
  20289. markDirty(): void;
  20290. /** @hidden */ preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20291. /**
  20292. * Binds the material to the mesh
  20293. * @param world defines the world transformation matrix
  20294. * @param mesh defines the mesh to bind the material to
  20295. */
  20296. bind(world: Matrix, mesh?: Mesh): void;
  20297. /**
  20298. * Binds the submesh to the material
  20299. * @param world defines the world transformation matrix
  20300. * @param mesh defines the mesh containing the submesh
  20301. * @param subMesh defines the submesh to bind the material to
  20302. */
  20303. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20304. /**
  20305. * Binds the world matrix to the material
  20306. * @param world defines the world transformation matrix
  20307. */
  20308. bindOnlyWorldMatrix(world: Matrix): void;
  20309. /**
  20310. * Binds the scene's uniform buffer to the effect.
  20311. * @param effect defines the effect to bind to the scene uniform buffer
  20312. * @param sceneUbo defines the uniform buffer storing scene data
  20313. */
  20314. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20315. /**
  20316. * Binds the view matrix to the effect
  20317. * @param effect defines the effect to bind the view matrix to
  20318. */
  20319. bindView(effect: Effect): void;
  20320. /**
  20321. * Binds the view projection matrix to the effect
  20322. * @param effect defines the effect to bind the view projection matrix to
  20323. */
  20324. bindViewProjection(effect: Effect): void;
  20325. /**
  20326. * Specifies if material alpha testing should be turned on for the mesh
  20327. * @param mesh defines the mesh to check
  20328. */
  20329. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20330. /**
  20331. * Processes to execute after binding the material to a mesh
  20332. * @param mesh defines the rendered mesh
  20333. */
  20334. protected _afterBind(mesh?: Mesh): void;
  20335. /**
  20336. * Unbinds the material from the mesh
  20337. */
  20338. unbind(): void;
  20339. /**
  20340. * Gets the active textures from the material
  20341. * @returns an array of textures
  20342. */
  20343. getActiveTextures(): BaseTexture[];
  20344. /**
  20345. * Specifies if the material uses a texture
  20346. * @param texture defines the texture to check against the material
  20347. * @returns a boolean specifying if the material uses the texture
  20348. */
  20349. hasTexture(texture: BaseTexture): boolean;
  20350. /**
  20351. * Makes a duplicate of the material, and gives it a new name
  20352. * @param name defines the new name for the duplicated material
  20353. * @returns the cloned material
  20354. */
  20355. clone(name: string): Nullable<Material>;
  20356. /**
  20357. * Gets the meshes bound to the material
  20358. * @returns an array of meshes bound to the material
  20359. */
  20360. getBindedMeshes(): AbstractMesh[];
  20361. /**
  20362. * Force shader compilation
  20363. * @param mesh defines the mesh associated with this material
  20364. * @param onCompiled defines a function to execute once the material is compiled
  20365. * @param options defines the options to configure the compilation
  20366. */
  20367. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20368. clipPlane: boolean;
  20369. }>): void;
  20370. /**
  20371. * Force shader compilation
  20372. * @param mesh defines the mesh that will use this material
  20373. * @param options defines additional options for compiling the shaders
  20374. * @returns a promise that resolves when the compilation completes
  20375. */
  20376. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20377. clipPlane: boolean;
  20378. }>): Promise<void>;
  20379. private static readonly _ImageProcessingDirtyCallBack;
  20380. private static readonly _TextureDirtyCallBack;
  20381. private static readonly _FresnelDirtyCallBack;
  20382. private static readonly _MiscDirtyCallBack;
  20383. private static readonly _LightsDirtyCallBack;
  20384. private static readonly _AttributeDirtyCallBack;
  20385. private static _FresnelAndMiscDirtyCallBack;
  20386. private static _TextureAndMiscDirtyCallBack;
  20387. private static readonly _DirtyCallbackArray;
  20388. private static readonly _RunDirtyCallBacks;
  20389. /**
  20390. * Marks a define in the material to indicate that it needs to be re-computed
  20391. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20392. */
  20393. markAsDirty(flag: number): void;
  20394. /**
  20395. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20396. * @param func defines a function which checks material defines against the submeshes
  20397. */
  20398. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20399. /**
  20400. * Indicates that image processing needs to be re-calculated for all submeshes
  20401. */
  20402. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20403. /**
  20404. * Indicates that textures need to be re-calculated for all submeshes
  20405. */
  20406. protected _markAllSubMeshesAsTexturesDirty(): void;
  20407. /**
  20408. * Indicates that fresnel needs to be re-calculated for all submeshes
  20409. */
  20410. protected _markAllSubMeshesAsFresnelDirty(): void;
  20411. /**
  20412. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20413. */
  20414. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20415. /**
  20416. * Indicates that lights need to be re-calculated for all submeshes
  20417. */
  20418. protected _markAllSubMeshesAsLightsDirty(): void;
  20419. /**
  20420. * Indicates that attributes need to be re-calculated for all submeshes
  20421. */
  20422. protected _markAllSubMeshesAsAttributesDirty(): void;
  20423. /**
  20424. * Indicates that misc needs to be re-calculated for all submeshes
  20425. */
  20426. protected _markAllSubMeshesAsMiscDirty(): void;
  20427. /**
  20428. * Indicates that textures and misc need to be re-calculated for all submeshes
  20429. */
  20430. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20431. /**
  20432. * Disposes the material
  20433. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20434. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20435. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20436. */
  20437. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20438. /** @hidden */
  20439. private releaseVertexArrayObject;
  20440. /**
  20441. * Serializes this material
  20442. * @returns the serialized material object
  20443. */
  20444. serialize(): any;
  20445. /**
  20446. * Creates a material from parsed material data
  20447. * @param parsedMaterial defines parsed material data
  20448. * @param scene defines the hosting scene
  20449. * @param rootUrl defines the root URL to use to load textures
  20450. * @returns a new material
  20451. */
  20452. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  20453. }
  20454. }
  20455. declare module BABYLON {
  20456. /**
  20457. * Base class for submeshes
  20458. */
  20459. export class BaseSubMesh {
  20460. /** @hidden */ materialDefines: Nullable<MaterialDefines>;
  20461. /** @hidden */ materialEffect: Nullable<Effect>;
  20462. /**
  20463. * Gets associated effect
  20464. */
  20465. readonly effect: Nullable<Effect>;
  20466. /**
  20467. * Sets associated effect (effect used to render this submesh)
  20468. * @param effect defines the effect to associate with
  20469. * @param defines defines the set of defines used to compile this effect
  20470. */
  20471. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20472. }
  20473. /**
  20474. * Defines a subdivision inside a mesh
  20475. */
  20476. export class SubMesh extends BaseSubMesh implements ICullable {
  20477. /** the material index to use */
  20478. materialIndex: number;
  20479. /** vertex index start */
  20480. verticesStart: number;
  20481. /** vertices count */
  20482. verticesCount: number;
  20483. /** index start */
  20484. indexStart: number;
  20485. /** indices count */
  20486. indexCount: number;
  20487. /** @hidden */ linesIndexCount: number;
  20488. private _mesh;
  20489. private _renderingMesh;
  20490. private _boundingInfo;
  20491. private _linesIndexBuffer;
  20492. /** @hidden */ lastColliderWorldVertices: Nullable<Vector3[]>;
  20493. /** @hidden */ trianglePlanes: Plane[];
  20494. /** @hidden */ lastColliderTransformMatrix: Matrix;
  20495. /** @hidden */ renderId: number;
  20496. /** @hidden */ alphaIndex: number;
  20497. /** @hidden */ distanceToCamera: number;
  20498. /** @hidden */ id: number;
  20499. private _currentMaterial;
  20500. /**
  20501. * Add a new submesh to a mesh
  20502. * @param materialIndex defines the material index to use
  20503. * @param verticesStart defines vertex index start
  20504. * @param verticesCount defines vertices count
  20505. * @param indexStart defines index start
  20506. * @param indexCount defines indices count
  20507. * @param mesh defines the parent mesh
  20508. * @param renderingMesh defines an optional rendering mesh
  20509. * @param createBoundingBox defines if bounding box should be created for this submesh
  20510. * @returns the new submesh
  20511. */
  20512. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20513. /**
  20514. * Creates a new submesh
  20515. * @param materialIndex defines the material index to use
  20516. * @param verticesStart defines vertex index start
  20517. * @param verticesCount defines vertices count
  20518. * @param indexStart defines index start
  20519. * @param indexCount defines indices count
  20520. * @param mesh defines the parent mesh
  20521. * @param renderingMesh defines an optional rendering mesh
  20522. * @param createBoundingBox defines if bounding box should be created for this submesh
  20523. */
  20524. constructor(
  20525. /** the material index to use */
  20526. materialIndex: number,
  20527. /** vertex index start */
  20528. verticesStart: number,
  20529. /** vertices count */
  20530. verticesCount: number,
  20531. /** index start */
  20532. indexStart: number,
  20533. /** indices count */
  20534. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20535. /**
  20536. * Returns true if this submesh covers the entire parent mesh
  20537. * @ignorenaming
  20538. */
  20539. readonly IsGlobal: boolean;
  20540. /**
  20541. * Returns the submesh BoudingInfo object
  20542. * @returns current bounding info (or mesh's one if the submesh is global)
  20543. */
  20544. getBoundingInfo(): BoundingInfo;
  20545. /**
  20546. * Sets the submesh BoundingInfo
  20547. * @param boundingInfo defines the new bounding info to use
  20548. * @returns the SubMesh
  20549. */
  20550. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20551. /**
  20552. * Returns the mesh of the current submesh
  20553. * @return the parent mesh
  20554. */
  20555. getMesh(): AbstractMesh;
  20556. /**
  20557. * Returns the rendering mesh of the submesh
  20558. * @returns the rendering mesh (could be different from parent mesh)
  20559. */
  20560. getRenderingMesh(): Mesh;
  20561. /**
  20562. * Returns the submesh material
  20563. * @returns null or the current material
  20564. */
  20565. getMaterial(): Nullable<Material>;
  20566. /**
  20567. * Sets a new updated BoundingInfo object to the submesh
  20568. * @returns the SubMesh
  20569. */
  20570. refreshBoundingInfo(): SubMesh;
  20571. /** @hidden */ checkCollision(collider: Collider): boolean;
  20572. /**
  20573. * Updates the submesh BoundingInfo
  20574. * @param world defines the world matrix to use to update the bounding info
  20575. * @returns the submesh
  20576. */
  20577. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20578. /**
  20579. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20580. * @param frustumPlanes defines the frustum planes
  20581. * @returns true if the submesh is intersecting with the frustum
  20582. */
  20583. isInFrustum(frustumPlanes: Plane[]): boolean;
  20584. /**
  20585. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20586. * @param frustumPlanes defines the frustum planes
  20587. * @returns true if the submesh is inside the frustum
  20588. */
  20589. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20590. /**
  20591. * Renders the submesh
  20592. * @param enableAlphaMode defines if alpha needs to be used
  20593. * @returns the submesh
  20594. */
  20595. render(enableAlphaMode: boolean): SubMesh;
  20596. /**
  20597. * @hidden
  20598. */ getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  20599. /**
  20600. * Checks if the submesh intersects with a ray
  20601. * @param ray defines the ray to test
  20602. * @returns true is the passed ray intersects the submesh bounding box
  20603. */
  20604. canIntersects(ray: Ray): boolean;
  20605. /**
  20606. * Intersects current submesh with a ray
  20607. * @param ray defines the ray to test
  20608. * @param positions defines mesh's positions array
  20609. * @param indices defines mesh's indices array
  20610. * @param fastCheck defines if only bounding info should be used
  20611. * @returns intersection info or null if no intersection
  20612. */
  20613. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  20614. /** @hidden */
  20615. private _intersectLines;
  20616. /** @hidden */
  20617. private _intersectTriangles;
  20618. /** @hidden */ rebuild(): void;
  20619. /**
  20620. * Creates a new submesh from the passed mesh
  20621. * @param newMesh defines the new hosting mesh
  20622. * @param newRenderingMesh defines an optional rendering mesh
  20623. * @returns the new submesh
  20624. */
  20625. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20626. /**
  20627. * Release associated resources
  20628. */
  20629. dispose(): void;
  20630. /**
  20631. * Gets the class name
  20632. * @returns the string "SubMesh".
  20633. */
  20634. getClassName(): string;
  20635. /**
  20636. * Creates a new submesh from indices data
  20637. * @param materialIndex the index of the main mesh material
  20638. * @param startIndex the index where to start the copy in the mesh indices array
  20639. * @param indexCount the number of indices to copy then from the startIndex
  20640. * @param mesh the main mesh to create the submesh from
  20641. * @param renderingMesh the optional rendering mesh
  20642. * @returns a new submesh
  20643. */
  20644. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20645. }
  20646. }
  20647. declare module BABYLON {
  20648. /**
  20649. * Class used to store geometry data (vertex buffers + index buffer)
  20650. */
  20651. export class Geometry implements IGetSetVerticesData {
  20652. /**
  20653. * Gets or sets the ID of the geometry
  20654. */
  20655. id: string;
  20656. /**
  20657. * Gets or sets the unique ID of the geometry
  20658. */
  20659. uniqueId: number;
  20660. /**
  20661. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20662. */
  20663. delayLoadState: number;
  20664. /**
  20665. * Gets the file containing the data to load when running in delay load state
  20666. */
  20667. delayLoadingFile: Nullable<string>;
  20668. /**
  20669. * Callback called when the geometry is updated
  20670. */
  20671. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20672. private _scene;
  20673. private _engine;
  20674. private _meshes;
  20675. private _totalVertices;
  20676. /** @hidden */ indices: IndicesArray;
  20677. /** @hidden */ vertexBuffers: {
  20678. [key: string]: VertexBuffer;
  20679. };
  20680. private _isDisposed;
  20681. private _extend;
  20682. private _boundingBias;
  20683. /** @hidden */ delayInfo: Array<string>;
  20684. private _indexBuffer;
  20685. private _indexBufferIsUpdatable;
  20686. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  20687. /** @hidden */ delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20688. /** @hidden */ softwareSkinningFrameId: number;
  20689. private _vertexArrayObjects;
  20690. private _updatable;
  20691. /** @hidden */ positions: Nullable<Vector3[]>;
  20692. /**
  20693. * 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
  20694. */
  20695. /**
  20696. * 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
  20697. */
  20698. boundingBias: Vector2;
  20699. /**
  20700. * Static function used to attach a new empty geometry to a mesh
  20701. * @param mesh defines the mesh to attach the geometry to
  20702. * @returns the new Geometry
  20703. */
  20704. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20705. /**
  20706. * Creates a new geometry
  20707. * @param id defines the unique ID
  20708. * @param scene defines the hosting scene
  20709. * @param vertexData defines the VertexData used to get geometry data
  20710. * @param updatable defines if geometry must be updatable (false by default)
  20711. * @param mesh defines the mesh that will be associated with the geometry
  20712. */
  20713. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20714. /**
  20715. * Gets the current extend of the geometry
  20716. */
  20717. readonly extend: {
  20718. minimum: Vector3;
  20719. maximum: Vector3;
  20720. };
  20721. /**
  20722. * Gets the hosting scene
  20723. * @returns the hosting Scene
  20724. */
  20725. getScene(): Scene;
  20726. /**
  20727. * Gets the hosting engine
  20728. * @returns the hosting Engine
  20729. */
  20730. getEngine(): Engine;
  20731. /**
  20732. * Defines if the geometry is ready to use
  20733. * @returns true if the geometry is ready to be used
  20734. */
  20735. isReady(): boolean;
  20736. /**
  20737. * Gets a value indicating that the geometry should not be serialized
  20738. */
  20739. readonly doNotSerialize: boolean;
  20740. /** @hidden */ rebuild(): void;
  20741. /**
  20742. * Affects all geometry data in one call
  20743. * @param vertexData defines the geometry data
  20744. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20745. */
  20746. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20747. /**
  20748. * Set specific vertex data
  20749. * @param kind defines the data kind (Position, normal, etc...)
  20750. * @param data defines the vertex data to use
  20751. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20752. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20753. */
  20754. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20755. /**
  20756. * Removes a specific vertex data
  20757. * @param kind defines the data kind (Position, normal, etc...)
  20758. */
  20759. removeVerticesData(kind: string): void;
  20760. /**
  20761. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20762. * @param buffer defines the vertex buffer to use
  20763. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20764. */
  20765. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20766. /**
  20767. * Update a specific vertex buffer
  20768. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20769. * It will do nothing if the buffer is not updatable
  20770. * @param kind defines the data kind (Position, normal, etc...)
  20771. * @param data defines the data to use
  20772. * @param offset defines the offset in the target buffer where to store the data
  20773. * @param useBytes set to true if the offset is in bytes
  20774. */
  20775. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20776. /**
  20777. * Update a specific vertex buffer
  20778. * This function will create a new buffer if the current one is not updatable
  20779. * @param kind defines the data kind (Position, normal, etc...)
  20780. * @param data defines the data to use
  20781. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20782. */
  20783. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20784. private _updateBoundingInfo;
  20785. /** @hidden */ bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  20786. /**
  20787. * Gets total number of vertices
  20788. * @returns the total number of vertices
  20789. */
  20790. getTotalVertices(): number;
  20791. /**
  20792. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20793. * @param kind defines the data kind (Position, normal, etc...)
  20794. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20795. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20796. * @returns a float array containing vertex data
  20797. */
  20798. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20799. /**
  20800. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20801. * @param kind defines the data kind (Position, normal, etc...)
  20802. * @returns true if the vertex buffer with the specified kind is updatable
  20803. */
  20804. isVertexBufferUpdatable(kind: string): boolean;
  20805. /**
  20806. * Gets a specific vertex buffer
  20807. * @param kind defines the data kind (Position, normal, etc...)
  20808. * @returns a VertexBuffer
  20809. */
  20810. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20811. /**
  20812. * Returns all vertex buffers
  20813. * @return an object holding all vertex buffers indexed by kind
  20814. */
  20815. getVertexBuffers(): Nullable<{
  20816. [key: string]: VertexBuffer;
  20817. }>;
  20818. /**
  20819. * Gets a boolean indicating if specific vertex buffer is present
  20820. * @param kind defines the data kind (Position, normal, etc...)
  20821. * @returns true if data is present
  20822. */
  20823. isVerticesDataPresent(kind: string): boolean;
  20824. /**
  20825. * Gets a list of all attached data kinds (Position, normal, etc...)
  20826. * @returns a list of string containing all kinds
  20827. */
  20828. getVerticesDataKinds(): string[];
  20829. /**
  20830. * Update index buffer
  20831. * @param indices defines the indices to store in the index buffer
  20832. * @param offset defines the offset in the target buffer where to store the data
  20833. */
  20834. updateIndices(indices: IndicesArray, offset?: number): void;
  20835. /**
  20836. * Creates a new index buffer
  20837. * @param indices defines the indices to store in the index buffer
  20838. * @param totalVertices defines the total number of vertices (could be null)
  20839. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20840. */
  20841. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20842. /**
  20843. * Return the total number of indices
  20844. * @returns the total number of indices
  20845. */
  20846. getTotalIndices(): number;
  20847. /**
  20848. * Gets the index buffer array
  20849. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20850. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20851. * @returns the index buffer array
  20852. */
  20853. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20854. /**
  20855. * Gets the index buffer
  20856. * @return the index buffer
  20857. */
  20858. getIndexBuffer(): Nullable<WebGLBuffer>;
  20859. /** @hidden */ releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20860. /**
  20861. * Release the associated resources for a specific mesh
  20862. * @param mesh defines the source mesh
  20863. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20864. */
  20865. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20866. /**
  20867. * Apply current geometry to a given mesh
  20868. * @param mesh defines the mesh to apply geometry to
  20869. */
  20870. applyToMesh(mesh: Mesh): void;
  20871. private _updateExtend;
  20872. private _applyToMesh;
  20873. private notifyUpdate;
  20874. /**
  20875. * Load the geometry if it was flagged as delay loaded
  20876. * @param scene defines the hosting scene
  20877. * @param onLoaded defines a callback called when the geometry is loaded
  20878. */
  20879. load(scene: Scene, onLoaded?: () => void): void;
  20880. private _queueLoad;
  20881. /**
  20882. * Invert the geometry to move from a right handed system to a left handed one.
  20883. */
  20884. toLeftHanded(): void;
  20885. /** @hidden */ resetPointsArrayCache(): void;
  20886. /** @hidden */ generatePointsArray(): boolean;
  20887. /**
  20888. * Gets a value indicating if the geometry is disposed
  20889. * @returns true if the geometry was disposed
  20890. */
  20891. isDisposed(): boolean;
  20892. private _disposeVertexArrayObjects;
  20893. /**
  20894. * Free all associated resources
  20895. */
  20896. dispose(): void;
  20897. /**
  20898. * Clone the current geometry into a new geometry
  20899. * @param id defines the unique ID of the new geometry
  20900. * @returns a new geometry object
  20901. */
  20902. copy(id: string): Geometry;
  20903. /**
  20904. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20905. * @return a JSON representation of the current geometry data (without the vertices data)
  20906. */
  20907. serialize(): any;
  20908. private toNumberArray;
  20909. /**
  20910. * Serialize all vertices data into a JSON oject
  20911. * @returns a JSON representation of the current geometry data
  20912. */
  20913. serializeVerticeData(): any;
  20914. /**
  20915. * Extracts a clone of a mesh geometry
  20916. * @param mesh defines the source mesh
  20917. * @param id defines the unique ID of the new geometry object
  20918. * @returns the new geometry object
  20919. */
  20920. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20921. /**
  20922. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20923. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20924. * Be aware Math.random() could cause collisions, but:
  20925. * "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"
  20926. * @returns a string containing a new GUID
  20927. */
  20928. static RandomId(): string;
  20929. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20930. private static _CleanMatricesWeights;
  20931. /**
  20932. * Create a new geometry from persisted data (Using .babylon file format)
  20933. * @param parsedVertexData defines the persisted data
  20934. * @param scene defines the hosting scene
  20935. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20936. * @returns the new geometry object
  20937. */
  20938. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20939. }
  20940. }
  20941. declare module BABYLON {
  20942. /**
  20943. * Define an interface for all classes that will get and set the data on vertices
  20944. */
  20945. export interface IGetSetVerticesData {
  20946. /**
  20947. * Gets a boolean indicating if specific vertex data is present
  20948. * @param kind defines the vertex data kind to use
  20949. * @returns true is data kind is present
  20950. */
  20951. isVerticesDataPresent(kind: string): boolean;
  20952. /**
  20953. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20954. * @param kind defines the data kind (Position, normal, etc...)
  20955. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20956. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20957. * @returns a float array containing vertex data
  20958. */
  20959. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20960. /**
  20961. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20962. * @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.
  20963. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20964. * @returns the indices array or an empty array if the mesh has no geometry
  20965. */
  20966. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20967. /**
  20968. * Set specific vertex data
  20969. * @param kind defines the data kind (Position, normal, etc...)
  20970. * @param data defines the vertex data to use
  20971. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20972. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20973. */
  20974. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  20975. /**
  20976. * Update a specific associated vertex buffer
  20977. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20978. * - VertexBuffer.PositionKind
  20979. * - VertexBuffer.UVKind
  20980. * - VertexBuffer.UV2Kind
  20981. * - VertexBuffer.UV3Kind
  20982. * - VertexBuffer.UV4Kind
  20983. * - VertexBuffer.UV5Kind
  20984. * - VertexBuffer.UV6Kind
  20985. * - VertexBuffer.ColorKind
  20986. * - VertexBuffer.MatricesIndicesKind
  20987. * - VertexBuffer.MatricesIndicesExtraKind
  20988. * - VertexBuffer.MatricesWeightsKind
  20989. * - VertexBuffer.MatricesWeightsExtraKind
  20990. * @param data defines the data source
  20991. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20992. * @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)
  20993. */
  20994. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  20995. /**
  20996. * Creates a new index buffer
  20997. * @param indices defines the indices to store in the index buffer
  20998. * @param totalVertices defines the total number of vertices (could be null)
  20999. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21000. */
  21001. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21002. }
  21003. /**
  21004. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21005. */
  21006. export class VertexData {
  21007. /**
  21008. * Mesh side orientation : usually the external or front surface
  21009. */
  21010. static readonly FRONTSIDE: number;
  21011. /**
  21012. * Mesh side orientation : usually the internal or back surface
  21013. */
  21014. static readonly BACKSIDE: number;
  21015. /**
  21016. * Mesh side orientation : both internal and external or front and back surfaces
  21017. */
  21018. static readonly DOUBLESIDE: number;
  21019. /**
  21020. * Mesh side orientation : by default, `FRONTSIDE`
  21021. */
  21022. static readonly DEFAULTSIDE: number;
  21023. /**
  21024. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21025. */
  21026. positions: Nullable<FloatArray>;
  21027. /**
  21028. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21029. */
  21030. normals: Nullable<FloatArray>;
  21031. /**
  21032. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21033. */
  21034. tangents: Nullable<FloatArray>;
  21035. /**
  21036. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21037. */
  21038. uvs: Nullable<FloatArray>;
  21039. /**
  21040. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21041. */
  21042. uvs2: Nullable<FloatArray>;
  21043. /**
  21044. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21045. */
  21046. uvs3: Nullable<FloatArray>;
  21047. /**
  21048. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21049. */
  21050. uvs4: Nullable<FloatArray>;
  21051. /**
  21052. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21053. */
  21054. uvs5: Nullable<FloatArray>;
  21055. /**
  21056. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21057. */
  21058. uvs6: Nullable<FloatArray>;
  21059. /**
  21060. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21061. */
  21062. colors: Nullable<FloatArray>;
  21063. /**
  21064. * 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).
  21065. */
  21066. matricesIndices: Nullable<FloatArray>;
  21067. /**
  21068. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21069. */
  21070. matricesWeights: Nullable<FloatArray>;
  21071. /**
  21072. * An array extending the number of possible indices
  21073. */
  21074. matricesIndicesExtra: Nullable<FloatArray>;
  21075. /**
  21076. * An array extending the number of possible weights when the number of indices is extended
  21077. */
  21078. matricesWeightsExtra: Nullable<FloatArray>;
  21079. /**
  21080. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21081. */
  21082. indices: Nullable<IndicesArray>;
  21083. /**
  21084. * Uses the passed data array to set the set the values for the specified kind of data
  21085. * @param data a linear array of floating numbers
  21086. * @param kind the type of data that is being set, eg positions, colors etc
  21087. */
  21088. set(data: FloatArray, kind: string): void;
  21089. /**
  21090. * Associates the vertexData to the passed Mesh.
  21091. * Sets it as updatable or not (default `false`)
  21092. * @param mesh the mesh the vertexData is applied to
  21093. * @param updatable when used and having the value true allows new data to update the vertexData
  21094. * @returns the VertexData
  21095. */
  21096. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21097. /**
  21098. * Associates the vertexData to the passed Geometry.
  21099. * Sets it as updatable or not (default `false`)
  21100. * @param geometry the geometry the vertexData is applied to
  21101. * @param updatable when used and having the value true allows new data to update the vertexData
  21102. * @returns VertexData
  21103. */
  21104. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21105. /**
  21106. * Updates the associated mesh
  21107. * @param mesh the mesh to be updated
  21108. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21109. * @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
  21110. * @returns VertexData
  21111. */
  21112. updateMesh(mesh: Mesh): VertexData;
  21113. /**
  21114. * Updates the associated geometry
  21115. * @param geometry the geometry to be updated
  21116. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21117. * @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
  21118. * @returns VertexData.
  21119. */
  21120. updateGeometry(geometry: Geometry): VertexData;
  21121. private _applyTo;
  21122. private _update;
  21123. /**
  21124. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21125. * @param matrix the transforming matrix
  21126. * @returns the VertexData
  21127. */
  21128. transform(matrix: Matrix): VertexData;
  21129. /**
  21130. * Merges the passed VertexData into the current one
  21131. * @param other the VertexData to be merged into the current one
  21132. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21133. * @returns the modified VertexData
  21134. */
  21135. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21136. private _mergeElement;
  21137. private _validate;
  21138. /**
  21139. * Serializes the VertexData
  21140. * @returns a serialized object
  21141. */
  21142. serialize(): any;
  21143. /**
  21144. * Extracts the vertexData from a mesh
  21145. * @param mesh the mesh from which to extract the VertexData
  21146. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21147. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21148. * @returns the object VertexData associated to the passed mesh
  21149. */
  21150. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21151. /**
  21152. * Extracts the vertexData from the geometry
  21153. * @param geometry the geometry from which to extract the VertexData
  21154. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21155. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21156. * @returns the object VertexData associated to the passed mesh
  21157. */
  21158. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21159. private static _ExtractFrom;
  21160. /**
  21161. * Creates the VertexData for a Ribbon
  21162. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21163. * * pathArray array of paths, each of which an array of successive Vector3
  21164. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21165. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21166. * * 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
  21167. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21168. * * 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)
  21169. * * 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)
  21170. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21171. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21172. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21173. * @returns the VertexData of the ribbon
  21174. */
  21175. static CreateRibbon(options: {
  21176. pathArray: Vector3[][];
  21177. closeArray?: boolean;
  21178. closePath?: boolean;
  21179. offset?: number;
  21180. sideOrientation?: number;
  21181. frontUVs?: Vector4;
  21182. backUVs?: Vector4;
  21183. invertUV?: boolean;
  21184. uvs?: Vector2[];
  21185. colors?: Color4[];
  21186. }): VertexData;
  21187. /**
  21188. * Creates the VertexData for a box
  21189. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21190. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21191. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21192. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21193. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21194. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21195. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21196. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21197. * * 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)
  21198. * * 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)
  21199. * @returns the VertexData of the box
  21200. */
  21201. static CreateBox(options: {
  21202. size?: number;
  21203. width?: number;
  21204. height?: number;
  21205. depth?: number;
  21206. faceUV?: Vector4[];
  21207. faceColors?: Color4[];
  21208. sideOrientation?: number;
  21209. frontUVs?: Vector4;
  21210. backUVs?: Vector4;
  21211. }): VertexData;
  21212. /**
  21213. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21214. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21215. * * segments sets the number of horizontal strips optional, default 32
  21216. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21217. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21218. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21219. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21220. * * 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
  21221. * * 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
  21222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21223. * * 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)
  21224. * * 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)
  21225. * @returns the VertexData of the ellipsoid
  21226. */
  21227. static CreateSphere(options: {
  21228. segments?: number;
  21229. diameter?: number;
  21230. diameterX?: number;
  21231. diameterY?: number;
  21232. diameterZ?: number;
  21233. arc?: number;
  21234. slice?: number;
  21235. sideOrientation?: number;
  21236. frontUVs?: Vector4;
  21237. backUVs?: Vector4;
  21238. }): VertexData;
  21239. /**
  21240. * Creates the VertexData for a cylinder, cone or prism
  21241. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21242. * * height sets the height (y direction) of the cylinder, optional, default 2
  21243. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21244. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21245. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21246. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21247. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21248. * * 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
  21249. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21250. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21251. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21252. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21253. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21254. * * 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)
  21255. * * 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)
  21256. * @returns the VertexData of the cylinder, cone or prism
  21257. */
  21258. static CreateCylinder(options: {
  21259. height?: number;
  21260. diameterTop?: number;
  21261. diameterBottom?: number;
  21262. diameter?: number;
  21263. tessellation?: number;
  21264. subdivisions?: number;
  21265. arc?: number;
  21266. faceColors?: Color4[];
  21267. faceUV?: Vector4[];
  21268. hasRings?: boolean;
  21269. enclose?: boolean;
  21270. sideOrientation?: number;
  21271. frontUVs?: Vector4;
  21272. backUVs?: Vector4;
  21273. }): VertexData;
  21274. /**
  21275. * Creates the VertexData for a torus
  21276. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21277. * * diameter the diameter of the torus, optional default 1
  21278. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21279. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21280. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21281. * * 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)
  21282. * * 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)
  21283. * @returns the VertexData of the torus
  21284. */
  21285. static CreateTorus(options: {
  21286. diameter?: number;
  21287. thickness?: number;
  21288. tessellation?: number;
  21289. sideOrientation?: number;
  21290. frontUVs?: Vector4;
  21291. backUVs?: Vector4;
  21292. }): VertexData;
  21293. /**
  21294. * Creates the VertexData of the LineSystem
  21295. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21296. * - lines an array of lines, each line being an array of successive Vector3
  21297. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21298. * @returns the VertexData of the LineSystem
  21299. */
  21300. static CreateLineSystem(options: {
  21301. lines: Vector3[][];
  21302. colors?: Nullable<Color4[][]>;
  21303. }): VertexData;
  21304. /**
  21305. * Create the VertexData for a DashedLines
  21306. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21307. * - points an array successive Vector3
  21308. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21309. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21310. * - dashNb the intended total number of dashes, optional, default 200
  21311. * @returns the VertexData for the DashedLines
  21312. */
  21313. static CreateDashedLines(options: {
  21314. points: Vector3[];
  21315. dashSize?: number;
  21316. gapSize?: number;
  21317. dashNb?: number;
  21318. }): VertexData;
  21319. /**
  21320. * Creates the VertexData for a Ground
  21321. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21322. * - width the width (x direction) of the ground, optional, default 1
  21323. * - height the height (z direction) of the ground, optional, default 1
  21324. * - subdivisions the number of subdivisions per side, optional, default 1
  21325. * @returns the VertexData of the Ground
  21326. */
  21327. static CreateGround(options: {
  21328. width?: number;
  21329. height?: number;
  21330. subdivisions?: number;
  21331. subdivisionsX?: number;
  21332. subdivisionsY?: number;
  21333. }): VertexData;
  21334. /**
  21335. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21336. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21337. * * xmin the ground minimum X coordinate, optional, default -1
  21338. * * zmin the ground minimum Z coordinate, optional, default -1
  21339. * * xmax the ground maximum X coordinate, optional, default 1
  21340. * * zmax the ground maximum Z coordinate, optional, default 1
  21341. * * 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}
  21342. * * 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}
  21343. * @returns the VertexData of the TiledGround
  21344. */
  21345. static CreateTiledGround(options: {
  21346. xmin: number;
  21347. zmin: number;
  21348. xmax: number;
  21349. zmax: number;
  21350. subdivisions?: {
  21351. w: number;
  21352. h: number;
  21353. };
  21354. precision?: {
  21355. w: number;
  21356. h: number;
  21357. };
  21358. }): VertexData;
  21359. /**
  21360. * Creates the VertexData of the Ground designed from a heightmap
  21361. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21362. * * width the width (x direction) of the ground
  21363. * * height the height (z direction) of the ground
  21364. * * subdivisions the number of subdivisions per side
  21365. * * minHeight the minimum altitude on the ground, optional, default 0
  21366. * * maxHeight the maximum altitude on the ground, optional default 1
  21367. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21368. * * buffer the array holding the image color data
  21369. * * bufferWidth the width of image
  21370. * * bufferHeight the height of image
  21371. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21372. * @returns the VertexData of the Ground designed from a heightmap
  21373. */
  21374. static CreateGroundFromHeightMap(options: {
  21375. width: number;
  21376. height: number;
  21377. subdivisions: number;
  21378. minHeight: number;
  21379. maxHeight: number;
  21380. colorFilter: Color3;
  21381. buffer: Uint8Array;
  21382. bufferWidth: number;
  21383. bufferHeight: number;
  21384. alphaFilter: number;
  21385. }): VertexData;
  21386. /**
  21387. * Creates the VertexData for a Plane
  21388. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21389. * * size sets the width and height of the plane to the value of size, optional default 1
  21390. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21391. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21392. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21393. * * 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)
  21394. * * 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)
  21395. * @returns the VertexData of the box
  21396. */
  21397. static CreatePlane(options: {
  21398. size?: number;
  21399. width?: number;
  21400. height?: number;
  21401. sideOrientation?: number;
  21402. frontUVs?: Vector4;
  21403. backUVs?: Vector4;
  21404. }): VertexData;
  21405. /**
  21406. * Creates the VertexData of the Disc or regular Polygon
  21407. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21408. * * radius the radius of the disc, optional default 0.5
  21409. * * tessellation the number of polygon sides, optional, default 64
  21410. * * 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
  21411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21412. * * 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)
  21413. * * 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)
  21414. * @returns the VertexData of the box
  21415. */
  21416. static CreateDisc(options: {
  21417. radius?: number;
  21418. tessellation?: number;
  21419. arc?: number;
  21420. sideOrientation?: number;
  21421. frontUVs?: Vector4;
  21422. backUVs?: Vector4;
  21423. }): VertexData;
  21424. /**
  21425. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21426. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21427. * @param polygon a mesh built from polygonTriangulation.build()
  21428. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21429. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21430. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21431. * @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)
  21432. * @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)
  21433. * @returns the VertexData of the Polygon
  21434. */
  21435. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21436. /**
  21437. * Creates the VertexData of the IcoSphere
  21438. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21439. * * radius the radius of the IcoSphere, optional default 1
  21440. * * radiusX allows stretching in the x direction, optional, default radius
  21441. * * radiusY allows stretching in the y direction, optional, default radius
  21442. * * radiusZ allows stretching in the z direction, optional, default radius
  21443. * * flat when true creates a flat shaded mesh, optional, default true
  21444. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21445. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21446. * * 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)
  21447. * * 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)
  21448. * @returns the VertexData of the IcoSphere
  21449. */
  21450. static CreateIcoSphere(options: {
  21451. radius?: number;
  21452. radiusX?: number;
  21453. radiusY?: number;
  21454. radiusZ?: number;
  21455. flat?: boolean;
  21456. subdivisions?: number;
  21457. sideOrientation?: number;
  21458. frontUVs?: Vector4;
  21459. backUVs?: Vector4;
  21460. }): VertexData;
  21461. /**
  21462. * Creates the VertexData for a Polyhedron
  21463. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21464. * * type provided types are:
  21465. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21466. * * 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)
  21467. * * size the size of the IcoSphere, optional default 1
  21468. * * sizeX allows stretching in the x direction, optional, default size
  21469. * * sizeY allows stretching in the y direction, optional, default size
  21470. * * sizeZ allows stretching in the z direction, optional, default size
  21471. * * 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
  21472. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21473. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21474. * * flat when true creates a flat shaded mesh, optional, default true
  21475. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21476. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21477. * * 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)
  21478. * * 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)
  21479. * @returns the VertexData of the Polyhedron
  21480. */
  21481. static CreatePolyhedron(options: {
  21482. type?: number;
  21483. size?: number;
  21484. sizeX?: number;
  21485. sizeY?: number;
  21486. sizeZ?: number;
  21487. custom?: any;
  21488. faceUV?: Vector4[];
  21489. faceColors?: Color4[];
  21490. flat?: boolean;
  21491. sideOrientation?: number;
  21492. frontUVs?: Vector4;
  21493. backUVs?: Vector4;
  21494. }): VertexData;
  21495. /**
  21496. * Creates the VertexData for a TorusKnot
  21497. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21498. * * radius the radius of the torus knot, optional, default 2
  21499. * * tube the thickness of the tube, optional, default 0.5
  21500. * * radialSegments the number of sides on each tube segments, optional, default 32
  21501. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21502. * * p the number of windings around the z axis, optional, default 2
  21503. * * q the number of windings around the x axis, optional, default 3
  21504. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21505. * * 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)
  21506. * * 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)
  21507. * @returns the VertexData of the Torus Knot
  21508. */
  21509. static CreateTorusKnot(options: {
  21510. radius?: number;
  21511. tube?: number;
  21512. radialSegments?: number;
  21513. tubularSegments?: number;
  21514. p?: number;
  21515. q?: number;
  21516. sideOrientation?: number;
  21517. frontUVs?: Vector4;
  21518. backUVs?: Vector4;
  21519. }): VertexData;
  21520. /**
  21521. * Compute normals for given positions and indices
  21522. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21523. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21524. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21525. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21526. * * facetNormals : optional array of facet normals (vector3)
  21527. * * facetPositions : optional array of facet positions (vector3)
  21528. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21529. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21530. * * bInfo : optional bounding info, required for facetPartitioning computation
  21531. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21532. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21533. * * useRightHandedSystem: optional boolean to for right handed system computation
  21534. * * depthSort : optional boolean to enable the facet depth sort computation
  21535. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21536. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21537. */
  21538. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21539. facetNormals?: any;
  21540. facetPositions?: any;
  21541. facetPartitioning?: any;
  21542. ratio?: number;
  21543. bInfo?: any;
  21544. bbSize?: Vector3;
  21545. subDiv?: any;
  21546. useRightHandedSystem?: boolean;
  21547. depthSort?: boolean;
  21548. distanceTo?: Vector3;
  21549. depthSortedFacets?: any;
  21550. }): void;
  21551. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21552. /**
  21553. * Applies VertexData created from the imported parameters to the geometry
  21554. * @param parsedVertexData the parsed data from an imported file
  21555. * @param geometry the geometry to apply the VertexData to
  21556. */
  21557. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21558. }
  21559. }
  21560. declare module BABYLON {
  21561. /**
  21562. * Class containing static functions to help procedurally build meshes
  21563. */
  21564. export class DiscBuilder {
  21565. /**
  21566. * Creates a plane polygonal mesh. By default, this is a disc
  21567. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  21568. * * 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
  21569. * * 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
  21570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21571. * * 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
  21572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21573. * @param name defines the name of the mesh
  21574. * @param options defines the options used to create the mesh
  21575. * @param scene defines the hosting scene
  21576. * @returns the plane polygonal mesh
  21577. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21578. */
  21579. static CreateDisc(name: string, options: {
  21580. radius?: number;
  21581. tessellation?: number;
  21582. arc?: number;
  21583. updatable?: boolean;
  21584. sideOrientation?: number;
  21585. frontUVs?: Vector4;
  21586. backUVs?: Vector4;
  21587. }, scene?: Nullable<Scene>): Mesh;
  21588. }
  21589. }
  21590. declare module BABYLON {
  21591. /**
  21592. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  21593. *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.
  21594. * The SPS is also a particle system. It provides some methods to manage the particles.
  21595. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  21596. *
  21597. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  21598. */
  21599. export class SolidParticleSystem implements IDisposable {
  21600. /**
  21601. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  21602. * Example : var p = SPS.particles[i];
  21603. */
  21604. particles: SolidParticle[];
  21605. /**
  21606. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  21607. */
  21608. nbParticles: number;
  21609. /**
  21610. * If the particles must ever face the camera (default false). Useful for planar particles.
  21611. */
  21612. billboard: boolean;
  21613. /**
  21614. * Recompute normals when adding a shape
  21615. */
  21616. recomputeNormals: boolean;
  21617. /**
  21618. * This a counter ofr your own usage. It's not set by any SPS functions.
  21619. */
  21620. counter: number;
  21621. /**
  21622. * The SPS name. This name is also given to the underlying mesh.
  21623. */
  21624. name: string;
  21625. /**
  21626. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  21627. */
  21628. mesh: Mesh;
  21629. /**
  21630. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  21631. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  21632. */
  21633. vars: any;
  21634. /**
  21635. * This array is populated when the SPS is set as 'pickable'.
  21636. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  21637. * Each element of this array is an object `{idx: int, faceId: int}`.
  21638. * `idx` is the picked particle index in the `SPS.particles` array
  21639. * `faceId` is the picked face index counted within this particle.
  21640. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  21641. */
  21642. pickedParticles: {
  21643. idx: number;
  21644. faceId: number;
  21645. }[];
  21646. /**
  21647. * This array is populated when `enableDepthSort` is set to true.
  21648. * Each element of this array is an instance of the class DepthSortedParticle.
  21649. */
  21650. depthSortedParticles: DepthSortedParticle[];
  21651. /**
  21652. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  21653. * @hidden
  21654. */ bSphereOnly: boolean;
  21655. /**
  21656. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  21657. * @hidden
  21658. */ bSphereRadiusFactor: number;
  21659. private _scene;
  21660. private _positions;
  21661. private _indices;
  21662. private _normals;
  21663. private _colors;
  21664. private _uvs;
  21665. private _indices32;
  21666. private _positions32;
  21667. private _normals32;
  21668. private _fixedNormal32;
  21669. private _colors32;
  21670. private _uvs32;
  21671. private _index;
  21672. private _updatable;
  21673. private _pickable;
  21674. private _isVisibilityBoxLocked;
  21675. private _alwaysVisible;
  21676. private _depthSort;
  21677. private _shapeCounter;
  21678. private _copy;
  21679. private _color;
  21680. private _computeParticleColor;
  21681. private _computeParticleTexture;
  21682. private _computeParticleRotation;
  21683. private _computeParticleVertex;
  21684. private _computeBoundingBox;
  21685. private _depthSortParticles;
  21686. private _camera;
  21687. private _mustUnrotateFixedNormals;
  21688. private _particlesIntersect;
  21689. private _needs32Bits;
  21690. /**
  21691. * Creates a SPS (Solid Particle System) object.
  21692. * @param name (String) is the SPS name, this will be the underlying mesh name.
  21693. * @param scene (Scene) is the scene in which the SPS is added.
  21694. * @param options defines the options of the sps e.g.
  21695. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  21696. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  21697. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  21698. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  21699. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  21700. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  21701. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  21702. */
  21703. constructor(name: string, scene: Scene, options?: {
  21704. updatable?: boolean;
  21705. isPickable?: boolean;
  21706. enableDepthSort?: boolean;
  21707. particleIntersection?: boolean;
  21708. boundingSphereOnly?: boolean;
  21709. bSphereRadiusFactor?: number;
  21710. });
  21711. /**
  21712. * Builds the SPS underlying mesh. Returns a standard Mesh.
  21713. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  21714. * @returns the created mesh
  21715. */
  21716. buildMesh(): Mesh;
  21717. /**
  21718. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  21719. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  21720. * Thus the particles generated from `digest()` have their property `position` set yet.
  21721. * @param mesh ( Mesh ) is the mesh to be digested
  21722. * @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
  21723. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  21724. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  21725. * @returns the current SPS
  21726. */
  21727. digest(mesh: Mesh, options?: {
  21728. facetNb?: number;
  21729. number?: number;
  21730. delta?: number;
  21731. }): SolidParticleSystem;
  21732. private _unrotateFixedNormals;
  21733. private _resetCopy;
  21734. private _meshBuilder;
  21735. private _posToShape;
  21736. private _uvsToShapeUV;
  21737. private _addParticle;
  21738. /**
  21739. * Adds some particles to the SPS from the model shape. Returns the shape id.
  21740. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  21741. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  21742. * @param nb (positive integer) the number of particles to be created from this model
  21743. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  21744. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  21745. * @returns the number of shapes in the system
  21746. */
  21747. addShape(mesh: Mesh, nb: number, options?: {
  21748. positionFunction?: any;
  21749. vertexFunction?: any;
  21750. }): number;
  21751. private _rebuildParticle;
  21752. /**
  21753. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  21754. * @returns the SPS.
  21755. */
  21756. rebuildMesh(): SolidParticleSystem;
  21757. /**
  21758. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  21759. * This method calls `updateParticle()` for each particle of the SPS.
  21760. * For an animated SPS, it is usually called within the render loop.
  21761. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  21762. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  21763. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  21764. * @returns the SPS.
  21765. */
  21766. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  21767. /**
  21768. * Disposes the SPS.
  21769. */
  21770. dispose(): void;
  21771. /**
  21772. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  21773. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21774. * @returns the SPS.
  21775. */
  21776. refreshVisibleSize(): SolidParticleSystem;
  21777. /**
  21778. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  21779. * @param size the size (float) of the visibility box
  21780. * note : this doesn't lock the SPS mesh bounding box.
  21781. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21782. */
  21783. setVisibilityBox(size: number): void;
  21784. /**
  21785. * Gets whether the SPS as always visible or not
  21786. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21787. */
  21788. /**
  21789. * Sets the SPS as always visible or not
  21790. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21791. */
  21792. isAlwaysVisible: boolean;
  21793. /**
  21794. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  21795. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21796. */
  21797. /**
  21798. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  21799. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21800. */
  21801. isVisibilityBoxLocked: boolean;
  21802. /**
  21803. * Tells to `setParticles()` to compute the particle rotations or not.
  21804. * Default value : true. The SPS is faster when it's set to false.
  21805. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  21806. */
  21807. /**
  21808. * Gets if `setParticles()` computes the particle rotations or not.
  21809. * Default value : true. The SPS is faster when it's set to false.
  21810. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  21811. */
  21812. computeParticleRotation: boolean;
  21813. /**
  21814. * Tells to `setParticles()` to compute the particle colors or not.
  21815. * Default value : true. The SPS is faster when it's set to false.
  21816. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  21817. */
  21818. /**
  21819. * Gets if `setParticles()` computes the particle colors or not.
  21820. * Default value : true. The SPS is faster when it's set to false.
  21821. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  21822. */
  21823. computeParticleColor: boolean;
  21824. /**
  21825. * Gets if `setParticles()` computes the particle textures or not.
  21826. * Default value : true. The SPS is faster when it's set to false.
  21827. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  21828. */
  21829. computeParticleTexture: boolean;
  21830. /**
  21831. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  21832. * Default value : false. The SPS is faster when it's set to false.
  21833. * Note : the particle custom vertex positions aren't stored values.
  21834. */
  21835. /**
  21836. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  21837. * Default value : false. The SPS is faster when it's set to false.
  21838. * Note : the particle custom vertex positions aren't stored values.
  21839. */
  21840. computeParticleVertex: boolean;
  21841. /**
  21842. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  21843. */
  21844. /**
  21845. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  21846. */
  21847. computeBoundingBox: boolean;
  21848. /**
  21849. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  21850. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  21851. * Default : `true`
  21852. */
  21853. /**
  21854. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  21855. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  21856. * Default : `true`
  21857. */
  21858. depthSortParticles: boolean;
  21859. /**
  21860. * This function does nothing. It may be overwritten to set all the particle first values.
  21861. * The SPS doesn't call this function, you may have to call it by your own.
  21862. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  21863. */
  21864. initParticles(): void;
  21865. /**
  21866. * This function does nothing. It may be overwritten to recycle a particle.
  21867. * The SPS doesn't call this function, you may have to call it by your own.
  21868. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  21869. * @param particle The particle to recycle
  21870. * @returns the recycled particle
  21871. */
  21872. recycleParticle(particle: SolidParticle): SolidParticle;
  21873. /**
  21874. * Updates a particle : this function should be overwritten by the user.
  21875. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  21876. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  21877. * @example : just set a particle position or velocity and recycle conditions
  21878. * @param particle The particle to update
  21879. * @returns the updated particle
  21880. */
  21881. updateParticle(particle: SolidParticle): SolidParticle;
  21882. /**
  21883. * Updates a vertex of a particle : it can be overwritten by the user.
  21884. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  21885. * @param particle the current particle
  21886. * @param vertex the current index of the current particle
  21887. * @param pt the index of the current vertex in the particle shape
  21888. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  21889. * @example : just set a vertex particle position
  21890. * @returns the updated vertex
  21891. */
  21892. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  21893. /**
  21894. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  21895. * This does nothing and may be overwritten by the user.
  21896. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21897. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21898. * @param update the boolean update value actually passed to setParticles()
  21899. */
  21900. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  21901. /**
  21902. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  21903. * This will be passed three parameters.
  21904. * This does nothing and may be overwritten by the user.
  21905. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21906. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21907. * @param update the boolean update value actually passed to setParticles()
  21908. */
  21909. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  21910. }
  21911. }
  21912. declare module BABYLON {
  21913. /**
  21914. * Represents one particle of a solid particle system.
  21915. */
  21916. export class SolidParticle {
  21917. /**
  21918. * particle global index
  21919. */
  21920. idx: number;
  21921. /**
  21922. * The color of the particle
  21923. */
  21924. color: Nullable<Color4>;
  21925. /**
  21926. * The world space position of the particle.
  21927. */
  21928. position: Vector3;
  21929. /**
  21930. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  21931. */
  21932. rotation: Vector3;
  21933. /**
  21934. * The world space rotation quaternion of the particle.
  21935. */
  21936. rotationQuaternion: Nullable<Quaternion>;
  21937. /**
  21938. * The scaling of the particle.
  21939. */
  21940. scaling: Vector3;
  21941. /**
  21942. * The uvs of the particle.
  21943. */
  21944. uvs: Vector4;
  21945. /**
  21946. * The current speed of the particle.
  21947. */
  21948. velocity: Vector3;
  21949. /**
  21950. * The pivot point in the particle local space.
  21951. */
  21952. pivot: Vector3;
  21953. /**
  21954. * Must the particle be translated from its pivot point in its local space ?
  21955. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  21956. * Default : false
  21957. */
  21958. translateFromPivot: boolean;
  21959. /**
  21960. * Is the particle active or not ?
  21961. */
  21962. alive: boolean;
  21963. /**
  21964. * Is the particle visible or not ?
  21965. */
  21966. isVisible: boolean;
  21967. /**
  21968. * Index of this particle in the global "positions" array (Internal use)
  21969. * @hidden
  21970. */ pos: number;
  21971. /**
  21972. * @hidden Index of this particle in the global "indices" array (Internal use)
  21973. */ ind: number;
  21974. /**
  21975. * @hidden ModelShape of this particle (Internal use)
  21976. */ model: ModelShape;
  21977. /**
  21978. * ModelShape id of this particle
  21979. */
  21980. shapeId: number;
  21981. /**
  21982. * Index of the particle in its shape id (Internal use)
  21983. */
  21984. idxInShape: number;
  21985. /**
  21986. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  21987. */ modelBoundingInfo: BoundingInfo;
  21988. /**
  21989. * @hidden Particle BoundingInfo object (Internal use)
  21990. */ boundingInfo: BoundingInfo;
  21991. /**
  21992. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  21993. */ sps: SolidParticleSystem;
  21994. /**
  21995. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  21996. */ stillInvisible: boolean;
  21997. /**
  21998. * @hidden Last computed particle rotation matrix
  21999. */ rotationMatrix: number[];
  22000. /**
  22001. * Parent particle Id, if any.
  22002. * Default null.
  22003. */
  22004. parentId: Nullable<number>;
  22005. /**
  22006. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  22007. * The possible values are :
  22008. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22009. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22010. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22011. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22012. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22013. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  22014. * */
  22015. cullingStrategy: number;
  22016. /**
  22017. * @hidden Internal global position in the SPS.
  22018. */ globalPosition: Vector3;
  22019. /**
  22020. * Creates a Solid Particle object.
  22021. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  22022. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  22023. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  22024. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  22025. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  22026. * @param shapeId (integer) is the model shape identifier in the SPS.
  22027. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  22028. * @param sps defines the sps it is associated to
  22029. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  22030. */
  22031. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  22032. /**
  22033. * Legacy support, changed scale to scaling
  22034. */
  22035. /**
  22036. * Legacy support, changed scale to scaling
  22037. */
  22038. scale: Vector3;
  22039. /**
  22040. * Legacy support, changed quaternion to rotationQuaternion
  22041. */
  22042. /**
  22043. * Legacy support, changed quaternion to rotationQuaternion
  22044. */
  22045. quaternion: Nullable<Quaternion>;
  22046. /**
  22047. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  22048. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  22049. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  22050. * @returns true if it intersects
  22051. */
  22052. intersectsMesh(target: Mesh | SolidParticle): boolean;
  22053. /**
  22054. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  22055. * A particle is in the frustum if its bounding box intersects the frustum
  22056. * @param frustumPlanes defines the frustum to test
  22057. * @returns true if the particle is in the frustum planes
  22058. */
  22059. isInFrustum(frustumPlanes: Plane[]): boolean;
  22060. /**
  22061. * get the rotation matrix of the particle
  22062. * @hidden
  22063. */
  22064. getRotationMatrix(m: Matrix): void;
  22065. }
  22066. /**
  22067. * Represents the shape of the model used by one particle of a solid particle system.
  22068. * SPS internal tool, don't use it manually.
  22069. */
  22070. export class ModelShape {
  22071. /**
  22072. * The shape id
  22073. * @hidden
  22074. */
  22075. shapeID: number;
  22076. /**
  22077. * flat array of model positions (internal use)
  22078. * @hidden
  22079. */ shape: Vector3[];
  22080. /**
  22081. * flat array of model UVs (internal use)
  22082. * @hidden
  22083. */ shapeUV: number[];
  22084. /**
  22085. * length of the shape in the model indices array (internal use)
  22086. * @hidden
  22087. */ indicesLength: number;
  22088. /**
  22089. * Custom position function (internal use)
  22090. * @hidden
  22091. */ positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  22092. /**
  22093. * Custom vertex function (internal use)
  22094. * @hidden
  22095. */ vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  22096. /**
  22097. * 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.
  22098. * SPS internal tool, don't use it manually.
  22099. * @hidden
  22100. */
  22101. 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>);
  22102. }
  22103. /**
  22104. * Represents a Depth Sorted Particle in the solid particle system.
  22105. */
  22106. export class DepthSortedParticle {
  22107. /**
  22108. * Index of the particle in the "indices" array
  22109. */
  22110. ind: number;
  22111. /**
  22112. * Length of the particle shape in the "indices" array
  22113. */
  22114. indicesLength: number;
  22115. /**
  22116. * Squared distance from the particle to the camera
  22117. */
  22118. sqDistance: number;
  22119. }
  22120. }
  22121. declare module BABYLON {
  22122. /**
  22123. * Class used to store all common mesh properties
  22124. */
  22125. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  22126. /** No occlusion */
  22127. static OCCLUSION_TYPE_NONE: number;
  22128. /** Occlusion set to optimisitic */
  22129. static OCCLUSION_TYPE_OPTIMISTIC: number;
  22130. /** Occlusion set to strict */
  22131. static OCCLUSION_TYPE_STRICT: number;
  22132. /** Use an accurante occlusion algorithm */
  22133. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  22134. /** Use a conservative occlusion algorithm */
  22135. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  22136. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  22137. * Test order :
  22138. * Is the bounding sphere outside the frustum ?
  22139. * If not, are the bounding box vertices outside the frustum ?
  22140. * It not, then the cullable object is in the frustum.
  22141. */
  22142. static readonly CULLINGSTRATEGY_STANDARD: number;
  22143. /** Culling strategy : Bounding Sphere Only.
  22144. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  22145. * It's also less accurate than the standard because some not visible objects can still be selected.
  22146. * Test : is the bounding sphere outside the frustum ?
  22147. * If not, then the cullable object is in the frustum.
  22148. */
  22149. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  22150. /** Culling strategy : Optimistic Inclusion.
  22151. * This in an inclusion test first, then the standard exclusion test.
  22152. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  22153. * 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.
  22154. * Anyway, it's as accurate as the standard strategy.
  22155. * Test :
  22156. * Is the cullable object bounding sphere center in the frustum ?
  22157. * If not, apply the default culling strategy.
  22158. */
  22159. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  22160. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  22161. * This in an inclusion test first, then the bounding sphere only exclusion test.
  22162. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  22163. * 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.
  22164. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  22165. * Test :
  22166. * Is the cullable object bounding sphere center in the frustum ?
  22167. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  22168. */
  22169. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  22170. /**
  22171. * No billboard
  22172. */
  22173. static readonly BILLBOARDMODE_NONE: number;
  22174. /** Billboard on X axis */
  22175. static readonly BILLBOARDMODE_X: number;
  22176. /** Billboard on Y axis */
  22177. static readonly BILLBOARDMODE_Y: number;
  22178. /** Billboard on Z axis */
  22179. static readonly BILLBOARDMODE_Z: number;
  22180. /** Billboard on all axes */
  22181. static readonly BILLBOARDMODE_ALL: number;
  22182. private _facetData;
  22183. /**
  22184. * The culling strategy to use to check whether the mesh must be rendered or not.
  22185. * This value can be changed at any time and will be used on the next render mesh selection.
  22186. * The possible values are :
  22187. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22188. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22189. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22190. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22191. * Please read each static variable documentation to get details about the culling process.
  22192. * */
  22193. cullingStrategy: number;
  22194. /**
  22195. * Gets the number of facets in the mesh
  22196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22197. */
  22198. readonly facetNb: number;
  22199. /**
  22200. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  22201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22202. */
  22203. partitioningSubdivisions: number;
  22204. /**
  22205. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  22206. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  22207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22208. */
  22209. partitioningBBoxRatio: number;
  22210. /**
  22211. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  22212. * Works only for updatable meshes.
  22213. * Doesn't work with multi-materials
  22214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22215. */
  22216. mustDepthSortFacets: boolean;
  22217. /**
  22218. * The location (Vector3) where the facet depth sort must be computed from.
  22219. * By default, the active camera position.
  22220. * Used only when facet depth sort is enabled
  22221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22222. */
  22223. facetDepthSortFrom: Vector3;
  22224. /**
  22225. * gets a boolean indicating if facetData is enabled
  22226. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22227. */
  22228. readonly isFacetDataEnabled: boolean;
  22229. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  22230. /**
  22231. * An event triggered when this mesh collides with another one
  22232. */
  22233. onCollideObservable: Observable<AbstractMesh>;
  22234. private _onCollideObserver;
  22235. /** Set a function to call when this mesh collides with another one */
  22236. onCollide: () => void;
  22237. /**
  22238. * An event triggered when the collision's position changes
  22239. */
  22240. onCollisionPositionChangeObservable: Observable<Vector3>;
  22241. private _onCollisionPositionChangeObserver;
  22242. /** Set a function to call when the collision's position changes */
  22243. onCollisionPositionChange: () => void;
  22244. /**
  22245. * An event triggered when material is changed
  22246. */
  22247. onMaterialChangedObservable: Observable<AbstractMesh>;
  22248. /**
  22249. * Gets or sets the orientation for POV movement & rotation
  22250. */
  22251. definedFacingForward: boolean;
  22252. /** @hidden */ occlusionQuery: Nullable<WebGLQuery>;
  22253. private _visibility;
  22254. /**
  22255. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22256. */
  22257. /**
  22258. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22259. */
  22260. visibility: number;
  22261. /** Gets or sets the alpha index used to sort transparent meshes
  22262. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  22263. */
  22264. alphaIndex: number;
  22265. /**
  22266. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  22267. */
  22268. isVisible: boolean;
  22269. /**
  22270. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  22271. */
  22272. isPickable: boolean;
  22273. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  22274. showSubMeshesBoundingBox: boolean;
  22275. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  22276. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  22277. */
  22278. isBlocker: boolean;
  22279. /**
  22280. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  22281. */
  22282. enablePointerMoveEvents: boolean;
  22283. /**
  22284. * Specifies the rendering group id for this mesh (0 by default)
  22285. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  22286. */
  22287. renderingGroupId: number;
  22288. private _material;
  22289. /** Gets or sets current material */
  22290. material: Nullable<Material>;
  22291. private _receiveShadows;
  22292. /**
  22293. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  22294. * @see http://doc.babylonjs.com/babylon101/shadows
  22295. */
  22296. receiveShadows: boolean;
  22297. /** Defines color to use when rendering outline */
  22298. outlineColor: Color3;
  22299. /** Define width to use when rendering outline */
  22300. outlineWidth: number;
  22301. /** Defines color to use when rendering overlay */
  22302. overlayColor: Color3;
  22303. /** Defines alpha to use when rendering overlay */
  22304. overlayAlpha: number;
  22305. private _hasVertexAlpha;
  22306. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  22307. hasVertexAlpha: boolean;
  22308. private _useVertexColors;
  22309. /** 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) */
  22310. useVertexColors: boolean;
  22311. private _computeBonesUsingShaders;
  22312. /**
  22313. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  22314. */
  22315. computeBonesUsingShaders: boolean;
  22316. private _numBoneInfluencers;
  22317. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  22318. numBoneInfluencers: number;
  22319. private _applyFog;
  22320. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  22321. applyFog: boolean;
  22322. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  22323. useOctreeForRenderingSelection: boolean;
  22324. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  22325. useOctreeForPicking: boolean;
  22326. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  22327. useOctreeForCollisions: boolean;
  22328. private _layerMask;
  22329. /**
  22330. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  22331. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  22332. */
  22333. layerMask: number;
  22334. /**
  22335. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  22336. */
  22337. alwaysSelectAsActiveMesh: boolean;
  22338. /**
  22339. * Gets or sets the current action manager
  22340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  22341. */
  22342. actionManager: Nullable<AbstractActionManager>;
  22343. private _checkCollisions;
  22344. private _collisionMask;
  22345. private _collisionGroup;
  22346. /**
  22347. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  22348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22349. */
  22350. ellipsoid: Vector3;
  22351. /**
  22352. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  22353. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22354. */
  22355. ellipsoidOffset: Vector3;
  22356. private _collider;
  22357. private _oldPositionForCollisions;
  22358. private _diffPositionForCollisions;
  22359. /**
  22360. * Gets or sets a collision mask used to mask collisions (default is -1).
  22361. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22362. */
  22363. collisionMask: number;
  22364. /**
  22365. * Gets or sets the current collision group mask (-1 by default).
  22366. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22367. */
  22368. collisionGroup: number;
  22369. /**
  22370. * Defines edge width used when edgesRenderer is enabled
  22371. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22372. */
  22373. edgesWidth: number;
  22374. /**
  22375. * Defines edge color used when edgesRenderer is enabled
  22376. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22377. */
  22378. edgesColor: Color4;
  22379. /** @hidden */ edgesRenderer: Nullable<IEdgesRenderer>;
  22380. /** @hidden */ masterMesh: Nullable<AbstractMesh>;
  22381. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  22382. /** @hidden */ renderId: number;
  22383. /**
  22384. * Gets or sets the list of subMeshes
  22385. * @see http://doc.babylonjs.com/how_to/multi_materials
  22386. */
  22387. subMeshes: SubMesh[];
  22388. /** @hidden */ intersectionsInProgress: AbstractMesh[];
  22389. /** @hidden */ unIndexed: boolean;
  22390. /** @hidden */ lightSources: Light[];
  22391. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  22392. /** @hidden */ waitingActions: any;
  22393. /** @hidden */ waitingFreezeWorldMatrix: Nullable<boolean>;
  22394. private _skeleton;
  22395. /** @hidden */ bonesTransformMatrices: Nullable<Float32Array>;
  22396. /**
  22397. * Gets or sets a skeleton to apply skining transformations
  22398. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  22399. */
  22400. skeleton: Nullable<Skeleton>;
  22401. /**
  22402. * An event triggered when the mesh is rebuilt.
  22403. */
  22404. onRebuildObservable: Observable<AbstractMesh>;
  22405. /**
  22406. * Creates a new AbstractMesh
  22407. * @param name defines the name of the mesh
  22408. * @param scene defines the hosting scene
  22409. */
  22410. constructor(name: string, scene?: Nullable<Scene>);
  22411. /**
  22412. * Returns the string "AbstractMesh"
  22413. * @returns "AbstractMesh"
  22414. */
  22415. getClassName(): string;
  22416. /**
  22417. * Gets a string representation of the current mesh
  22418. * @param fullDetails defines a boolean indicating if full details must be included
  22419. * @returns a string representation of the current mesh
  22420. */
  22421. toString(fullDetails?: boolean): string;
  22422. /** @hidden */ rebuild(): void;
  22423. /** @hidden */ resyncLightSources(): void;
  22424. /** @hidden */ resyncLighSource(light: Light): void;
  22425. /** @hidden */ unBindEffect(): void;
  22426. /** @hidden */ removeLightSource(light: Light): void;
  22427. private _markSubMeshesAsDirty;
  22428. /** @hidden */ markSubMeshesAsLightDirty(): void;
  22429. /** @hidden */ markSubMeshesAsAttributesDirty(): void;
  22430. /** @hidden */ markSubMeshesAsMiscDirty(): void;
  22431. /**
  22432. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  22433. */
  22434. scaling: Vector3;
  22435. /**
  22436. * Returns true if the mesh is blocked. Implemented by child classes
  22437. */
  22438. readonly isBlocked: boolean;
  22439. /**
  22440. * Returns the mesh itself by default. Implemented by child classes
  22441. * @param camera defines the camera to use to pick the right LOD level
  22442. * @returns the currentAbstractMesh
  22443. */
  22444. getLOD(camera: Camera): Nullable<AbstractMesh>;
  22445. /**
  22446. * Returns 0 by default. Implemented by child classes
  22447. * @returns an integer
  22448. */
  22449. getTotalVertices(): number;
  22450. /**
  22451. * Returns a positive integer : the total number of indices in this mesh geometry.
  22452. * @returns the numner of indices or zero if the mesh has no geometry.
  22453. */
  22454. getTotalIndices(): number;
  22455. /**
  22456. * Returns null by default. Implemented by child classes
  22457. * @returns null
  22458. */
  22459. getIndices(): Nullable<IndicesArray>;
  22460. /**
  22461. * Returns the array of the requested vertex data kind. Implemented by child classes
  22462. * @param kind defines the vertex data kind to use
  22463. * @returns null
  22464. */
  22465. getVerticesData(kind: string): Nullable<FloatArray>;
  22466. /**
  22467. * Sets the vertex data of the mesh geometry for the requested `kind`.
  22468. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  22469. * Note that a new underlying VertexBuffer object is created each call.
  22470. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  22471. * @param kind defines vertex data kind:
  22472. * * VertexBuffer.PositionKind
  22473. * * VertexBuffer.UVKind
  22474. * * VertexBuffer.UV2Kind
  22475. * * VertexBuffer.UV3Kind
  22476. * * VertexBuffer.UV4Kind
  22477. * * VertexBuffer.UV5Kind
  22478. * * VertexBuffer.UV6Kind
  22479. * * VertexBuffer.ColorKind
  22480. * * VertexBuffer.MatricesIndicesKind
  22481. * * VertexBuffer.MatricesIndicesExtraKind
  22482. * * VertexBuffer.MatricesWeightsKind
  22483. * * VertexBuffer.MatricesWeightsExtraKind
  22484. * @param data defines the data source
  22485. * @param updatable defines if the data must be flagged as updatable (or static)
  22486. * @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
  22487. * @returns the current mesh
  22488. */
  22489. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  22490. /**
  22491. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  22492. * If the mesh has no geometry, it is simply returned as it is.
  22493. * @param kind defines vertex data kind:
  22494. * * VertexBuffer.PositionKind
  22495. * * VertexBuffer.UVKind
  22496. * * VertexBuffer.UV2Kind
  22497. * * VertexBuffer.UV3Kind
  22498. * * VertexBuffer.UV4Kind
  22499. * * VertexBuffer.UV5Kind
  22500. * * VertexBuffer.UV6Kind
  22501. * * VertexBuffer.ColorKind
  22502. * * VertexBuffer.MatricesIndicesKind
  22503. * * VertexBuffer.MatricesIndicesExtraKind
  22504. * * VertexBuffer.MatricesWeightsKind
  22505. * * VertexBuffer.MatricesWeightsExtraKind
  22506. * @param data defines the data source
  22507. * @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
  22508. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  22509. * @returns the current mesh
  22510. */
  22511. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  22512. /**
  22513. * Sets the mesh indices,
  22514. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  22515. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  22516. * @param totalVertices Defines the total number of vertices
  22517. * @returns the current mesh
  22518. */
  22519. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  22520. /**
  22521. * Gets a boolean indicating if specific vertex data is present
  22522. * @param kind defines the vertex data kind to use
  22523. * @returns true is data kind is present
  22524. */
  22525. isVerticesDataPresent(kind: string): boolean;
  22526. /**
  22527. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  22528. * @returns a BoundingInfo
  22529. */
  22530. getBoundingInfo(): BoundingInfo;
  22531. /**
  22532. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  22533. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  22534. * @returns the current mesh
  22535. */
  22536. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  22537. /**
  22538. * Overwrite the current bounding info
  22539. * @param boundingInfo defines the new bounding info
  22540. * @returns the current mesh
  22541. */
  22542. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  22543. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  22544. readonly useBones: boolean;
  22545. /** @hidden */ preActivate(): void;
  22546. /** @hidden */ preActivateForIntermediateRendering(renderId: number): void;
  22547. /** @hidden */ activate(renderId: number): void;
  22548. /**
  22549. * Gets the current world matrix
  22550. * @returns a Matrix
  22551. */
  22552. getWorldMatrix(): Matrix;
  22553. /** @hidden */ getWorldMatrixDeterminant(): number;
  22554. /**
  22555. * Perform relative position change from the point of view of behind the front of the mesh.
  22556. * This is performed taking into account the meshes current rotation, so you do not have to care.
  22557. * Supports definition of mesh facing forward or backward
  22558. * @param amountRight defines the distance on the right axis
  22559. * @param amountUp defines the distance on the up axis
  22560. * @param amountForward defines the distance on the forward axis
  22561. * @returns the current mesh
  22562. */
  22563. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  22564. /**
  22565. * Calculate relative position change from the point of view of behind the front of the mesh.
  22566. * This is performed taking into account the meshes current rotation, so you do not have to care.
  22567. * Supports definition of mesh facing forward or backward
  22568. * @param amountRight defines the distance on the right axis
  22569. * @param amountUp defines the distance on the up axis
  22570. * @param amountForward defines the distance on the forward axis
  22571. * @returns the new displacement vector
  22572. */
  22573. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  22574. /**
  22575. * Perform relative rotation change from the point of view of behind the front of the mesh.
  22576. * Supports definition of mesh facing forward or backward
  22577. * @param flipBack defines the flip
  22578. * @param twirlClockwise defines the twirl
  22579. * @param tiltRight defines the tilt
  22580. * @returns the current mesh
  22581. */
  22582. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  22583. /**
  22584. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  22585. * Supports definition of mesh facing forward or backward.
  22586. * @param flipBack defines the flip
  22587. * @param twirlClockwise defines the twirl
  22588. * @param tiltRight defines the tilt
  22589. * @returns the new rotation vector
  22590. */
  22591. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  22592. /**
  22593. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  22594. * @param includeDescendants Include bounding info from descendants as well (true by default)
  22595. * @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
  22596. * @returns the new bounding vectors
  22597. */
  22598. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  22599. min: Vector3;
  22600. max: Vector3;
  22601. };
  22602. /**
  22603. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  22604. * This means the mesh underlying bounding box and sphere are recomputed.
  22605. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  22606. * @returns the current mesh
  22607. */
  22608. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  22609. /** @hidden */ refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  22610. /** @hidden */ getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  22611. /** @hidden */ updateBoundingInfo(): AbstractMesh;
  22612. /** @hidden */ updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  22613. /** @hidden */
  22614. protected _afterComputeWorldMatrix(): void;
  22615. /**
  22616. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  22617. * A mesh is in the frustum if its bounding box intersects the frustum
  22618. * @param frustumPlanes defines the frustum to test
  22619. * @returns true if the mesh is in the frustum planes
  22620. */
  22621. isInFrustum(frustumPlanes: Plane[]): boolean;
  22622. /**
  22623. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  22624. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  22625. * @param frustumPlanes defines the frustum to test
  22626. * @returns true if the mesh is completely in the frustum planes
  22627. */
  22628. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22629. /**
  22630. * True if the mesh intersects another mesh or a SolidParticle object
  22631. * @param mesh defines a target mesh or SolidParticle to test
  22632. * @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)
  22633. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  22634. * @returns true if there is an intersection
  22635. */
  22636. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  22637. /**
  22638. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  22639. * @param point defines the point to test
  22640. * @returns true if there is an intersection
  22641. */
  22642. intersectsPoint(point: Vector3): boolean;
  22643. /**
  22644. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  22645. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22646. */
  22647. checkCollisions: boolean;
  22648. /**
  22649. * Gets Collider object used to compute collisions (not physics)
  22650. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22651. */
  22652. readonly collider: Collider;
  22653. /**
  22654. * Move the mesh using collision engine
  22655. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22656. * @param displacement defines the requested displacement vector
  22657. * @returns the current mesh
  22658. */
  22659. moveWithCollisions(displacement: Vector3): AbstractMesh;
  22660. private _onCollisionPositionChange;
  22661. /** @hidden */ collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  22662. /** @hidden */ processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  22663. /** @hidden */ checkCollision(collider: Collider): AbstractMesh;
  22664. /** @hidden */ generatePointsArray(): boolean;
  22665. /**
  22666. * Checks if the passed Ray intersects with the mesh
  22667. * @param ray defines the ray to use
  22668. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  22669. * @returns the picking info
  22670. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  22671. */
  22672. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  22673. /**
  22674. * Clones the current mesh
  22675. * @param name defines the mesh name
  22676. * @param newParent defines the new mesh parent
  22677. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  22678. * @returns the new mesh
  22679. */
  22680. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  22681. /**
  22682. * Disposes all the submeshes of the current meshnp
  22683. * @returns the current mesh
  22684. */
  22685. releaseSubMeshes(): AbstractMesh;
  22686. /**
  22687. * Releases resources associated with this abstract mesh.
  22688. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22689. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22690. */
  22691. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22692. /**
  22693. * Adds the passed mesh as a child to the current mesh
  22694. * @param mesh defines the child mesh
  22695. * @returns the current mesh
  22696. */
  22697. addChild(mesh: AbstractMesh): AbstractMesh;
  22698. /**
  22699. * Removes the passed mesh from the current mesh children list
  22700. * @param mesh defines the child mesh
  22701. * @returns the current mesh
  22702. */
  22703. removeChild(mesh: AbstractMesh): AbstractMesh;
  22704. /** @hidden */
  22705. private _initFacetData;
  22706. /**
  22707. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  22708. * This method can be called within the render loop.
  22709. * 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
  22710. * @returns the current mesh
  22711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22712. */
  22713. updateFacetData(): AbstractMesh;
  22714. /**
  22715. * Returns the facetLocalNormals array.
  22716. * The normals are expressed in the mesh local spac
  22717. * @returns an array of Vector3
  22718. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22719. */
  22720. getFacetLocalNormals(): Vector3[];
  22721. /**
  22722. * Returns the facetLocalPositions array.
  22723. * The facet positions are expressed in the mesh local space
  22724. * @returns an array of Vector3
  22725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22726. */
  22727. getFacetLocalPositions(): Vector3[];
  22728. /**
  22729. * Returns the facetLocalPartioning array
  22730. * @returns an array of array of numbers
  22731. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22732. */
  22733. getFacetLocalPartitioning(): number[][];
  22734. /**
  22735. * Returns the i-th facet position in the world system.
  22736. * This method allocates a new Vector3 per call
  22737. * @param i defines the facet index
  22738. * @returns a new Vector3
  22739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22740. */
  22741. getFacetPosition(i: number): Vector3;
  22742. /**
  22743. * Sets the reference Vector3 with the i-th facet position in the world system
  22744. * @param i defines the facet index
  22745. * @param ref defines the target vector
  22746. * @returns the current mesh
  22747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22748. */
  22749. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  22750. /**
  22751. * Returns the i-th facet normal in the world system.
  22752. * This method allocates a new Vector3 per call
  22753. * @param i defines the facet index
  22754. * @returns a new Vector3
  22755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22756. */
  22757. getFacetNormal(i: number): Vector3;
  22758. /**
  22759. * Sets the reference Vector3 with the i-th facet normal in the world system
  22760. * @param i defines the facet index
  22761. * @param ref defines the target vector
  22762. * @returns the current mesh
  22763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22764. */
  22765. getFacetNormalToRef(i: number, ref: Vector3): this;
  22766. /**
  22767. * 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)
  22768. * @param x defines x coordinate
  22769. * @param y defines y coordinate
  22770. * @param z defines z coordinate
  22771. * @returns the array of facet indexes
  22772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22773. */
  22774. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  22775. /**
  22776. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  22777. * @param projected sets as the (x,y,z) world projection on the facet
  22778. * @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
  22779. * @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
  22780. * @param x defines x coordinate
  22781. * @param y defines y coordinate
  22782. * @param z defines z coordinate
  22783. * @returns the face index if found (or null instead)
  22784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22785. */
  22786. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  22787. /**
  22788. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  22789. * @param projected sets as the (x,y,z) local projection on the facet
  22790. * @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
  22791. * @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
  22792. * @param x defines x coordinate
  22793. * @param y defines y coordinate
  22794. * @param z defines z coordinate
  22795. * @returns the face index if found (or null instead)
  22796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22797. */
  22798. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  22799. /**
  22800. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  22801. * @returns the parameters
  22802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22803. */
  22804. getFacetDataParameters(): any;
  22805. /**
  22806. * Disables the feature FacetData and frees the related memory
  22807. * @returns the current mesh
  22808. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22809. */
  22810. disableFacetData(): AbstractMesh;
  22811. /**
  22812. * Updates the AbstractMesh indices array
  22813. * @param indices defines the data source
  22814. * @returns the current mesh
  22815. */
  22816. updateIndices(indices: IndicesArray): AbstractMesh;
  22817. /**
  22818. * Creates new normals data for the mesh
  22819. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  22820. * @returns the current mesh
  22821. */
  22822. createNormals(updatable: boolean): AbstractMesh;
  22823. /**
  22824. * Align the mesh with a normal
  22825. * @param normal defines the normal to use
  22826. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  22827. * @returns the current mesh
  22828. */
  22829. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  22830. /** @hidden */ checkOcclusionQuery(): boolean;
  22831. }
  22832. }
  22833. declare module BABYLON {
  22834. /**
  22835. * Class used to handle skinning animations
  22836. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  22837. */
  22838. export class Skeleton implements IAnimatable {
  22839. /** defines the skeleton name */
  22840. name: string;
  22841. /** defines the skeleton Id */
  22842. id: string;
  22843. /**
  22844. * Defines the list of child bones
  22845. */
  22846. bones: Bone[];
  22847. /**
  22848. * Defines an estimate of the dimension of the skeleton at rest
  22849. */
  22850. dimensionsAtRest: Vector3;
  22851. /**
  22852. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  22853. */
  22854. needInitialSkinMatrix: boolean;
  22855. /**
  22856. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  22857. */
  22858. overrideMesh: Nullable<AbstractMesh>;
  22859. /**
  22860. * Gets the list of animations attached to this skeleton
  22861. */
  22862. animations: Array<Animation>;
  22863. private _scene;
  22864. private _isDirty;
  22865. private _transformMatrices;
  22866. private _transformMatrixTexture;
  22867. private _meshesWithPoseMatrix;
  22868. private _animatables;
  22869. private _identity;
  22870. private _synchronizedWithMesh;
  22871. private _ranges;
  22872. private _lastAbsoluteTransformsUpdateId;
  22873. private _canUseTextureForBones;
  22874. /** @hidden */ numBonesWithLinkedTransformNode: number;
  22875. /**
  22876. * Specifies if the skeleton should be serialized
  22877. */
  22878. doNotSerialize: boolean;
  22879. /**
  22880. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  22881. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  22882. */
  22883. useTextureToStoreBoneMatrices: boolean;
  22884. private _animationPropertiesOverride;
  22885. /**
  22886. * Gets or sets the animation properties override
  22887. */
  22888. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22889. /**
  22890. * An observable triggered before computing the skeleton's matrices
  22891. */
  22892. onBeforeComputeObservable: Observable<Skeleton>;
  22893. /**
  22894. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  22895. */
  22896. readonly isUsingTextureForMatrices: boolean;
  22897. /**
  22898. * Creates a new skeleton
  22899. * @param name defines the skeleton name
  22900. * @param id defines the skeleton Id
  22901. * @param scene defines the hosting scene
  22902. */
  22903. constructor(
  22904. /** defines the skeleton name */
  22905. name: string,
  22906. /** defines the skeleton Id */
  22907. id: string, scene: Scene);
  22908. /**
  22909. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  22910. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  22911. * @returns a Float32Array containing matrices data
  22912. */
  22913. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  22914. /**
  22915. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  22916. * @returns a raw texture containing the data
  22917. */
  22918. getTransformMatrixTexture(): Nullable<RawTexture>;
  22919. /**
  22920. * Gets the current hosting scene
  22921. * @returns a scene object
  22922. */
  22923. getScene(): Scene;
  22924. /**
  22925. * Gets a string representing the current skeleton data
  22926. * @param fullDetails defines a boolean indicating if we want a verbose version
  22927. * @returns a string representing the current skeleton data
  22928. */
  22929. toString(fullDetails?: boolean): string;
  22930. /**
  22931. * Get bone's index searching by name
  22932. * @param name defines bone's name to search for
  22933. * @return the indice of the bone. Returns -1 if not found
  22934. */
  22935. getBoneIndexByName(name: string): number;
  22936. /**
  22937. * Creater a new animation range
  22938. * @param name defines the name of the range
  22939. * @param from defines the start key
  22940. * @param to defines the end key
  22941. */
  22942. createAnimationRange(name: string, from: number, to: number): void;
  22943. /**
  22944. * Delete a specific animation range
  22945. * @param name defines the name of the range
  22946. * @param deleteFrames defines if frames must be removed as well
  22947. */
  22948. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  22949. /**
  22950. * Gets a specific animation range
  22951. * @param name defines the name of the range to look for
  22952. * @returns the requested animation range or null if not found
  22953. */
  22954. getAnimationRange(name: string): Nullable<AnimationRange>;
  22955. /**
  22956. * Gets the list of all animation ranges defined on this skeleton
  22957. * @returns an array
  22958. */
  22959. getAnimationRanges(): Nullable<AnimationRange>[];
  22960. /**
  22961. * Copy animation range from a source skeleton.
  22962. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  22963. * @param source defines the source skeleton
  22964. * @param name defines the name of the range to copy
  22965. * @param rescaleAsRequired defines if rescaling must be applied if required
  22966. * @returns true if operation was successful
  22967. */
  22968. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  22969. /**
  22970. * Forces the skeleton to go to rest pose
  22971. */
  22972. returnToRest(): void;
  22973. private _getHighestAnimationFrame;
  22974. /**
  22975. * Begin a specific animation range
  22976. * @param name defines the name of the range to start
  22977. * @param loop defines if looping must be turned on (false by default)
  22978. * @param speedRatio defines the speed ratio to apply (1 by default)
  22979. * @param onAnimationEnd defines a callback which will be called when animation will end
  22980. * @returns a new animatable
  22981. */
  22982. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  22983. /** @hidden */ markAsDirty(): void;
  22984. /** @hidden */ registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  22985. /** @hidden */ unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  22986. private _computeTransformMatrices;
  22987. /**
  22988. * Build all resources required to render a skeleton
  22989. */
  22990. prepare(): void;
  22991. /**
  22992. * Gets the list of animatables currently running for this skeleton
  22993. * @returns an array of animatables
  22994. */
  22995. getAnimatables(): IAnimatable[];
  22996. /**
  22997. * Clone the current skeleton
  22998. * @param name defines the name of the new skeleton
  22999. * @param id defines the id of the enw skeleton
  23000. * @returns the new skeleton
  23001. */
  23002. clone(name: string, id: string): Skeleton;
  23003. /**
  23004. * Enable animation blending for this skeleton
  23005. * @param blendingSpeed defines the blending speed to apply
  23006. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23007. */
  23008. enableBlending(blendingSpeed?: number): void;
  23009. /**
  23010. * Releases all resources associated with the current skeleton
  23011. */
  23012. dispose(): void;
  23013. /**
  23014. * Serialize the skeleton in a JSON object
  23015. * @returns a JSON object
  23016. */
  23017. serialize(): any;
  23018. /**
  23019. * Creates a new skeleton from serialized data
  23020. * @param parsedSkeleton defines the serialized data
  23021. * @param scene defines the hosting scene
  23022. * @returns a new skeleton
  23023. */
  23024. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  23025. /**
  23026. * Compute all node absolute transforms
  23027. * @param forceUpdate defines if computation must be done even if cache is up to date
  23028. */
  23029. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  23030. /**
  23031. * Gets the root pose matrix
  23032. * @returns a matrix
  23033. */
  23034. getPoseMatrix(): Nullable<Matrix>;
  23035. /**
  23036. * Sorts bones per internal index
  23037. */
  23038. sortBones(): void;
  23039. private _sortBones;
  23040. }
  23041. }
  23042. declare module BABYLON {
  23043. /**
  23044. * Class used to store bone information
  23045. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23046. */
  23047. export class Bone extends Node {
  23048. /**
  23049. * defines the bone name
  23050. */
  23051. name: string;
  23052. private static _tmpVecs;
  23053. private static _tmpQuat;
  23054. private static _tmpMats;
  23055. /**
  23056. * Gets the list of child bones
  23057. */
  23058. children: Bone[];
  23059. /** Gets the animations associated with this bone */
  23060. animations: Animation[];
  23061. /**
  23062. * Gets or sets bone length
  23063. */
  23064. length: number;
  23065. /**
  23066. * @hidden Internal only
  23067. * Set this value to map this bone to a different index in the transform matrices
  23068. * Set this value to -1 to exclude the bone from the transform matrices
  23069. */ index: Nullable<number>;
  23070. private _skeleton;
  23071. private _localMatrix;
  23072. private _restPose;
  23073. private _baseMatrix;
  23074. private _absoluteTransform;
  23075. private _invertedAbsoluteTransform;
  23076. private _parent;
  23077. private _scalingDeterminant;
  23078. private _worldTransform;
  23079. private _localScaling;
  23080. private _localRotation;
  23081. private _localPosition;
  23082. private _needToDecompose;
  23083. private _needToCompose;
  23084. /** @hidden */ linkedTransformNode: Nullable<TransformNode>;
  23085. /** @hidden */
  23086. /** @hidden */ matrix: Matrix;
  23087. /**
  23088. * Create a new bone
  23089. * @param name defines the bone name
  23090. * @param skeleton defines the parent skeleton
  23091. * @param parentBone defines the parent (can be null if the bone is the root)
  23092. * @param localMatrix defines the local matrix
  23093. * @param restPose defines the rest pose matrix
  23094. * @param baseMatrix defines the base matrix
  23095. * @param index defines index of the bone in the hiearchy
  23096. */
  23097. constructor(
  23098. /**
  23099. * defines the bone name
  23100. */
  23101. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  23102. /**
  23103. * Gets the parent skeleton
  23104. * @returns a skeleton
  23105. */
  23106. getSkeleton(): Skeleton;
  23107. /**
  23108. * Gets parent bone
  23109. * @returns a bone or null if the bone is the root of the bone hierarchy
  23110. */
  23111. getParent(): Nullable<Bone>;
  23112. /**
  23113. * Sets the parent bone
  23114. * @param parent defines the parent (can be null if the bone is the root)
  23115. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  23116. */
  23117. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  23118. /**
  23119. * Gets the local matrix
  23120. * @returns a matrix
  23121. */
  23122. getLocalMatrix(): Matrix;
  23123. /**
  23124. * Gets the base matrix (initial matrix which remains unchanged)
  23125. * @returns a matrix
  23126. */
  23127. getBaseMatrix(): Matrix;
  23128. /**
  23129. * Gets the rest pose matrix
  23130. * @returns a matrix
  23131. */
  23132. getRestPose(): Matrix;
  23133. /**
  23134. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  23135. */
  23136. getWorldMatrix(): Matrix;
  23137. /**
  23138. * Sets the local matrix to rest pose matrix
  23139. */
  23140. returnToRest(): void;
  23141. /**
  23142. * Gets the inverse of the absolute transform matrix.
  23143. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  23144. * @returns a matrix
  23145. */
  23146. getInvertedAbsoluteTransform(): Matrix;
  23147. /**
  23148. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  23149. * @returns a matrix
  23150. */
  23151. getAbsoluteTransform(): Matrix;
  23152. /**
  23153. * Links with the given transform node.
  23154. * The local matrix of this bone is copied from the transform node every frame.
  23155. * @param transformNode defines the transform node to link to
  23156. */
  23157. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  23158. /** Gets or sets current position (in local space) */
  23159. position: Vector3;
  23160. /** Gets or sets current rotation (in local space) */
  23161. rotation: Vector3;
  23162. /** Gets or sets current rotation quaternion (in local space) */
  23163. rotationQuaternion: Quaternion;
  23164. /** Gets or sets current scaling (in local space) */
  23165. scaling: Vector3;
  23166. /**
  23167. * Gets the animation properties override
  23168. */
  23169. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23170. private _decompose;
  23171. private _compose;
  23172. /**
  23173. * Update the base and local matrices
  23174. * @param matrix defines the new base or local matrix
  23175. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  23176. * @param updateLocalMatrix defines if the local matrix should be updated
  23177. */
  23178. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  23179. /** @hidden */ updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  23180. /**
  23181. * Flag the bone as dirty (Forcing it to update everything)
  23182. */
  23183. markAsDirty(): void;
  23184. private _markAsDirtyAndCompose;
  23185. private _markAsDirtyAndDecompose;
  23186. /**
  23187. * Translate the bone in local or world space
  23188. * @param vec The amount to translate the bone
  23189. * @param space The space that the translation is in
  23190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23191. */
  23192. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23193. /**
  23194. * Set the postion of the bone in local or world space
  23195. * @param position The position to set the bone
  23196. * @param space The space that the position is in
  23197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23198. */
  23199. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23200. /**
  23201. * Set the absolute position of the bone (world space)
  23202. * @param position The position to set the bone
  23203. * @param mesh The mesh that this bone is attached to
  23204. */
  23205. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  23206. /**
  23207. * Scale the bone on the x, y and z axes (in local space)
  23208. * @param x The amount to scale the bone on the x axis
  23209. * @param y The amount to scale the bone on the y axis
  23210. * @param z The amount to scale the bone on the z axis
  23211. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  23212. */
  23213. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  23214. /**
  23215. * Set the bone scaling in local space
  23216. * @param scale defines the scaling vector
  23217. */
  23218. setScale(scale: Vector3): void;
  23219. /**
  23220. * Gets the current scaling in local space
  23221. * @returns the current scaling vector
  23222. */
  23223. getScale(): Vector3;
  23224. /**
  23225. * Gets the current scaling in local space and stores it in a target vector
  23226. * @param result defines the target vector
  23227. */
  23228. getScaleToRef(result: Vector3): void;
  23229. /**
  23230. * Set the yaw, pitch, and roll of the bone in local or world space
  23231. * @param yaw The rotation of the bone on the y axis
  23232. * @param pitch The rotation of the bone on the x axis
  23233. * @param roll The rotation of the bone on the z axis
  23234. * @param space The space that the axes of rotation are in
  23235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23236. */
  23237. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  23238. /**
  23239. * Add a rotation to the bone on an axis in local or world space
  23240. * @param axis The axis to rotate the bone on
  23241. * @param amount The amount to rotate the bone
  23242. * @param space The space that the axis is in
  23243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23244. */
  23245. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  23246. /**
  23247. * Set the rotation of the bone to a particular axis angle in local or world space
  23248. * @param axis The axis to rotate the bone on
  23249. * @param angle The angle that the bone should be rotated to
  23250. * @param space The space that the axis is in
  23251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23252. */
  23253. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  23254. /**
  23255. * Set the euler rotation of the bone in local of world space
  23256. * @param rotation The euler rotation that the bone should be set to
  23257. * @param space The space that the rotation is in
  23258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23259. */
  23260. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23261. /**
  23262. * Set the quaternion rotation of the bone in local of world space
  23263. * @param quat The quaternion rotation that the bone should be set to
  23264. * @param space The space that the rotation is in
  23265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23266. */
  23267. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  23268. /**
  23269. * Set the rotation matrix of the bone in local of world space
  23270. * @param rotMat The rotation matrix that the bone should be set to
  23271. * @param space The space that the rotation is in
  23272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23273. */
  23274. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  23275. private _rotateWithMatrix;
  23276. private _getNegativeRotationToRef;
  23277. /**
  23278. * Get the position of the bone in local or world space
  23279. * @param space The space that the returned position is in
  23280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23281. * @returns The position of the bone
  23282. */
  23283. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  23284. /**
  23285. * Copy the position of the bone to a vector3 in local or world space
  23286. * @param space The space that the returned position is in
  23287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23288. * @param result The vector3 to copy the position to
  23289. */
  23290. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  23291. /**
  23292. * Get the absolute position of the bone (world space)
  23293. * @param mesh The mesh that this bone is attached to
  23294. * @returns The absolute position of the bone
  23295. */
  23296. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  23297. /**
  23298. * Copy the absolute position of the bone (world space) to the result param
  23299. * @param mesh The mesh that this bone is attached to
  23300. * @param result The vector3 to copy the absolute position to
  23301. */
  23302. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  23303. /**
  23304. * Compute the absolute transforms of this bone and its children
  23305. */
  23306. computeAbsoluteTransforms(): void;
  23307. /**
  23308. * Get the world direction from an axis that is in the local space of the bone
  23309. * @param localAxis The local direction that is used to compute the world direction
  23310. * @param mesh The mesh that this bone is attached to
  23311. * @returns The world direction
  23312. */
  23313. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23314. /**
  23315. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  23316. * @param localAxis The local direction that is used to compute the world direction
  23317. * @param mesh The mesh that this bone is attached to
  23318. * @param result The vector3 that the world direction will be copied to
  23319. */
  23320. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23321. /**
  23322. * Get the euler rotation of the bone in local or world space
  23323. * @param space The space that the rotation should be in
  23324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23325. * @returns The euler rotation
  23326. */
  23327. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  23328. /**
  23329. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  23330. * @param space The space that the rotation should be in
  23331. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23332. * @param result The vector3 that the rotation should be copied to
  23333. */
  23334. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23335. /**
  23336. * Get the quaternion rotation of the bone in either local or world space
  23337. * @param space The space that the rotation should be in
  23338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23339. * @returns The quaternion rotation
  23340. */
  23341. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  23342. /**
  23343. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  23344. * @param space The space that the rotation should be in
  23345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23346. * @param result The quaternion that the rotation should be copied to
  23347. */
  23348. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  23349. /**
  23350. * Get the rotation matrix of the bone in local or world space
  23351. * @param space The space that the rotation should be in
  23352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23353. * @returns The rotation matrix
  23354. */
  23355. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  23356. /**
  23357. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  23358. * @param space The space that the rotation should be in
  23359. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23360. * @param result The quaternion that the rotation should be copied to
  23361. */
  23362. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  23363. /**
  23364. * Get the world position of a point that is in the local space of the bone
  23365. * @param position The local position
  23366. * @param mesh The mesh that this bone is attached to
  23367. * @returns The world position
  23368. */
  23369. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23370. /**
  23371. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  23372. * @param position The local position
  23373. * @param mesh The mesh that this bone is attached to
  23374. * @param result The vector3 that the world position should be copied to
  23375. */
  23376. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23377. /**
  23378. * Get the local position of a point that is in world space
  23379. * @param position The world position
  23380. * @param mesh The mesh that this bone is attached to
  23381. * @returns The local position
  23382. */
  23383. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23384. /**
  23385. * Get the local position of a point that is in world space and copy it to the result param
  23386. * @param position The world position
  23387. * @param mesh The mesh that this bone is attached to
  23388. * @param result The vector3 that the local position should be copied to
  23389. */
  23390. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23391. }
  23392. }
  23393. declare module BABYLON {
  23394. /**
  23395. * Class used to store an actual running animation
  23396. */
  23397. export class Animatable {
  23398. /** defines the target object */
  23399. target: any;
  23400. /** defines the starting frame number (default is 0) */
  23401. fromFrame: number;
  23402. /** defines the ending frame number (default is 100) */
  23403. toFrame: number;
  23404. /** defines if the animation must loop (default is false) */
  23405. loopAnimation: boolean;
  23406. /** defines a callback to call when animation ends if it is not looping */
  23407. onAnimationEnd?: (() => void) | null | undefined;
  23408. /** defines a callback to call when animation loops */
  23409. onAnimationLoop?: (() => void) | null | undefined;
  23410. private _localDelayOffset;
  23411. private _pausedDelay;
  23412. private _runtimeAnimations;
  23413. private _paused;
  23414. private _scene;
  23415. private _speedRatio;
  23416. private _weight;
  23417. private _syncRoot;
  23418. /**
  23419. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  23420. * This will only apply for non looping animation (default is true)
  23421. */
  23422. disposeOnEnd: boolean;
  23423. /**
  23424. * Gets a boolean indicating if the animation has started
  23425. */
  23426. animationStarted: boolean;
  23427. /**
  23428. * Observer raised when the animation ends
  23429. */
  23430. onAnimationEndObservable: Observable<Animatable>;
  23431. /**
  23432. * Observer raised when the animation loops
  23433. */
  23434. onAnimationLoopObservable: Observable<Animatable>;
  23435. /**
  23436. * Gets the root Animatable used to synchronize and normalize animations
  23437. */
  23438. readonly syncRoot: Animatable;
  23439. /**
  23440. * Gets the current frame of the first RuntimeAnimation
  23441. * Used to synchronize Animatables
  23442. */
  23443. readonly masterFrame: number;
  23444. /**
  23445. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  23446. */
  23447. weight: number;
  23448. /**
  23449. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  23450. */
  23451. speedRatio: number;
  23452. /**
  23453. * Creates a new Animatable
  23454. * @param scene defines the hosting scene
  23455. * @param target defines the target object
  23456. * @param fromFrame defines the starting frame number (default is 0)
  23457. * @param toFrame defines the ending frame number (default is 100)
  23458. * @param loopAnimation defines if the animation must loop (default is false)
  23459. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  23460. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  23461. * @param animations defines a group of animation to add to the new Animatable
  23462. * @param onAnimationLoop defines a callback to call when animation loops
  23463. */
  23464. constructor(scene: Scene,
  23465. /** defines the target object */
  23466. target: any,
  23467. /** defines the starting frame number (default is 0) */
  23468. fromFrame?: number,
  23469. /** defines the ending frame number (default is 100) */
  23470. toFrame?: number,
  23471. /** defines if the animation must loop (default is false) */
  23472. loopAnimation?: boolean, speedRatio?: number,
  23473. /** defines a callback to call when animation ends if it is not looping */
  23474. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  23475. /** defines a callback to call when animation loops */
  23476. onAnimationLoop?: (() => void) | null | undefined);
  23477. /**
  23478. * Synchronize and normalize current Animatable with a source Animatable
  23479. * This is useful when using animation weights and when animations are not of the same length
  23480. * @param root defines the root Animatable to synchronize with
  23481. * @returns the current Animatable
  23482. */
  23483. syncWith(root: Animatable): Animatable;
  23484. /**
  23485. * Gets the list of runtime animations
  23486. * @returns an array of RuntimeAnimation
  23487. */
  23488. getAnimations(): RuntimeAnimation[];
  23489. /**
  23490. * Adds more animations to the current animatable
  23491. * @param target defines the target of the animations
  23492. * @param animations defines the new animations to add
  23493. */
  23494. appendAnimations(target: any, animations: Animation[]): void;
  23495. /**
  23496. * Gets the source animation for a specific property
  23497. * @param property defines the propertyu to look for
  23498. * @returns null or the source animation for the given property
  23499. */
  23500. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  23501. /**
  23502. * Gets the runtime animation for a specific property
  23503. * @param property defines the propertyu to look for
  23504. * @returns null or the runtime animation for the given property
  23505. */
  23506. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  23507. /**
  23508. * Resets the animatable to its original state
  23509. */
  23510. reset(): void;
  23511. /**
  23512. * Allows the animatable to blend with current running animations
  23513. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23514. * @param blendingSpeed defines the blending speed to use
  23515. */
  23516. enableBlending(blendingSpeed: number): void;
  23517. /**
  23518. * Disable animation blending
  23519. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23520. */
  23521. disableBlending(): void;
  23522. /**
  23523. * Jump directly to a given frame
  23524. * @param frame defines the frame to jump to
  23525. */
  23526. goToFrame(frame: number): void;
  23527. /**
  23528. * Pause the animation
  23529. */
  23530. pause(): void;
  23531. /**
  23532. * Restart the animation
  23533. */
  23534. restart(): void;
  23535. private _raiseOnAnimationEnd;
  23536. /**
  23537. * Stop and delete the current animation
  23538. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  23539. * @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)
  23540. */
  23541. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  23542. /**
  23543. * Wait asynchronously for the animation to end
  23544. * @returns a promise which will be fullfilled when the animation ends
  23545. */
  23546. waitAsync(): Promise<Animatable>;
  23547. /** @hidden */ animate(delay: number): boolean;
  23548. }
  23549. interface Scene {
  23550. /** @hidden */ registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  23551. /** @hidden */ processLateAnimationBindingsForMatrices(holder: {
  23552. totalWeight: number;
  23553. animations: RuntimeAnimation[];
  23554. originalValue: Matrix;
  23555. }): any;
  23556. /** @hidden */ processLateAnimationBindingsForQuaternions(holder: {
  23557. totalWeight: number;
  23558. animations: RuntimeAnimation[];
  23559. originalValue: Quaternion;
  23560. }, refQuaternion: Quaternion): Quaternion;
  23561. /** @hidden */ processLateAnimationBindings(): void;
  23562. /**
  23563. * Will start the animation sequence of a given target
  23564. * @param target defines the target
  23565. * @param from defines from which frame should animation start
  23566. * @param to defines until which frame should animation run.
  23567. * @param weight defines the weight to apply to the animation (1.0 by default)
  23568. * @param loop defines if the animation loops
  23569. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  23570. * @param onAnimationEnd defines the function to be executed when the animation ends
  23571. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  23572. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  23573. * @param onAnimationLoop defines the callback to call when an animation loops
  23574. * @returns the animatable object created for this animation
  23575. */
  23576. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  23577. /**
  23578. * Will start the animation sequence of a given target
  23579. * @param target defines the target
  23580. * @param from defines from which frame should animation start
  23581. * @param to defines until which frame should animation run.
  23582. * @param loop defines if the animation loops
  23583. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  23584. * @param onAnimationEnd defines the function to be executed when the animation ends
  23585. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  23586. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  23587. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  23588. * @param onAnimationLoop defines the callback to call when an animation loops
  23589. * @returns the animatable object created for this animation
  23590. */
  23591. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  23592. /**
  23593. * Will start the animation sequence of a given target and its hierarchy
  23594. * @param target defines the target
  23595. * @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.
  23596. * @param from defines from which frame should animation start
  23597. * @param to defines until which frame should animation run.
  23598. * @param loop defines if the animation loops
  23599. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  23600. * @param onAnimationEnd defines the function to be executed when the animation ends
  23601. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  23602. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  23603. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  23604. * @param onAnimationLoop defines the callback to call when an animation loops
  23605. * @returns the list of created animatables
  23606. */
  23607. 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[];
  23608. /**
  23609. * Begin a new animation on a given node
  23610. * @param target defines the target where the animation will take place
  23611. * @param animations defines the list of animations to start
  23612. * @param from defines the initial value
  23613. * @param to defines the final value
  23614. * @param loop defines if you want animation to loop (off by default)
  23615. * @param speedRatio defines the speed ratio to apply to all animations
  23616. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  23617. * @param onAnimationLoop defines the callback to call when an animation loops
  23618. * @returns the list of created animatables
  23619. */
  23620. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  23621. /**
  23622. * Begin a new animation on a given node and its hierarchy
  23623. * @param target defines the root node where the animation will take place
  23624. * @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.
  23625. * @param animations defines the list of animations to start
  23626. * @param from defines the initial value
  23627. * @param to defines the final value
  23628. * @param loop defines if you want animation to loop (off by default)
  23629. * @param speedRatio defines the speed ratio to apply to all animations
  23630. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  23631. * @param onAnimationLoop defines the callback to call when an animation loops
  23632. * @returns the list of animatables created for all nodes
  23633. */
  23634. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  23635. /**
  23636. * Gets the animatable associated with a specific target
  23637. * @param target defines the target of the animatable
  23638. * @returns the required animatable if found
  23639. */
  23640. getAnimatableByTarget(target: any): Nullable<Animatable>;
  23641. /**
  23642. * Gets all animatables associated with a given target
  23643. * @param target defines the target to look animatables for
  23644. * @returns an array of Animatables
  23645. */
  23646. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  23647. /**
  23648. * Will stop the animation of the given target
  23649. * @param target - the target
  23650. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  23651. * @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)
  23652. */
  23653. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  23654. /**
  23655. * Stops and removes all animations that have been applied to the scene
  23656. */
  23657. stopAllAnimations(): void;
  23658. }
  23659. interface Bone {
  23660. /**
  23661. * Copy an animation range from another bone
  23662. * @param source defines the source bone
  23663. * @param rangeName defines the range name to copy
  23664. * @param frameOffset defines the frame offset
  23665. * @param rescaleAsRequired defines if rescaling must be applied if required
  23666. * @param skelDimensionsRatio defines the scaling ratio
  23667. * @returns true if operation was successful
  23668. */
  23669. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  23670. }
  23671. }
  23672. declare module BABYLON {
  23673. /**
  23674. * Defines how a node can be built from a string name.
  23675. */
  23676. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  23677. /**
  23678. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  23679. */
  23680. export class Node implements IBehaviorAware<Node> {
  23681. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  23682. private static _NodeConstructors;
  23683. /**
  23684. * Add a new node constructor
  23685. * @param type defines the type name of the node to construct
  23686. * @param constructorFunc defines the constructor function
  23687. */
  23688. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  23689. /**
  23690. * Returns a node constructor based on type name
  23691. * @param type defines the type name
  23692. * @param name defines the new node name
  23693. * @param scene defines the hosting scene
  23694. * @param options defines optional options to transmit to constructors
  23695. * @returns the new constructor or null
  23696. */
  23697. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  23698. /**
  23699. * Gets or sets the name of the node
  23700. */
  23701. name: string;
  23702. /**
  23703. * Gets or sets the id of the node
  23704. */
  23705. id: string;
  23706. /**
  23707. * Gets or sets the unique id of the node
  23708. */
  23709. uniqueId: number;
  23710. /**
  23711. * Gets or sets a string used to store user defined state for the node
  23712. */
  23713. state: string;
  23714. /**
  23715. * Gets or sets an object used to store user defined information for the node
  23716. */
  23717. metadata: any;
  23718. /**
  23719. * For internal use only. Please do not use.
  23720. */
  23721. reservedDataStore: any;
  23722. /**
  23723. * Gets or sets a boolean used to define if the node must be serialized
  23724. */
  23725. doNotSerialize: boolean;
  23726. /** @hidden */ isDisposed: boolean;
  23727. /**
  23728. * Gets a list of Animations associated with the node
  23729. */
  23730. animations: Animation[];
  23731. protected _ranges: {
  23732. [name: string]: Nullable<AnimationRange>;
  23733. };
  23734. /**
  23735. * Callback raised when the node is ready to be used
  23736. */
  23737. onReady: (node: Node) => void;
  23738. private _isEnabled;
  23739. private _isParentEnabled;
  23740. private _isReady;
  23741. /** @hidden */ currentRenderId: number;
  23742. private _parentRenderId;
  23743. protected _childRenderId: number;
  23744. /** @hidden */ waitingParentId: Nullable<string>;
  23745. /** @hidden */ scene: Scene;
  23746. /** @hidden */ cache: any;
  23747. private _parentNode;
  23748. private _children;
  23749. /** @hidden */ worldMatrix: Matrix;
  23750. /** @hidden */ worldMatrixDeterminant: number;
  23751. /** @hidden */
  23752. private _sceneRootNodesIndex;
  23753. /**
  23754. * Gets a boolean indicating if the node has been disposed
  23755. * @returns true if the node was disposed
  23756. */
  23757. isDisposed(): boolean;
  23758. /**
  23759. * Gets or sets the parent of the node
  23760. */
  23761. parent: Nullable<Node>;
  23762. private addToSceneRootNodes;
  23763. private removeFromSceneRootNodes;
  23764. private _animationPropertiesOverride;
  23765. /**
  23766. * Gets or sets the animation properties override
  23767. */
  23768. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23769. /**
  23770. * Gets a string idenfifying the name of the class
  23771. * @returns "Node" string
  23772. */
  23773. getClassName(): string;
  23774. /** @hidden */ protected readonly _isNode: boolean;
  23775. /**
  23776. * An event triggered when the mesh is disposed
  23777. */
  23778. onDisposeObservable: Observable<Node>;
  23779. private _onDisposeObserver;
  23780. /**
  23781. * Sets a callback that will be raised when the node will be disposed
  23782. */
  23783. onDispose: () => void;
  23784. /**
  23785. * Creates a new Node
  23786. * @param name the name and id to be given to this node
  23787. * @param scene the scene this node will be added to
  23788. * @param addToRootNodes the node will be added to scene.rootNodes
  23789. */
  23790. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  23791. /**
  23792. * Gets the scene of the node
  23793. * @returns a scene
  23794. */
  23795. getScene(): Scene;
  23796. /**
  23797. * Gets the engine of the node
  23798. * @returns a Engine
  23799. */
  23800. getEngine(): Engine;
  23801. private _behaviors;
  23802. /**
  23803. * Attach a behavior to the node
  23804. * @see http://doc.babylonjs.com/features/behaviour
  23805. * @param behavior defines the behavior to attach
  23806. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  23807. * @returns the current Node
  23808. */
  23809. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  23810. /**
  23811. * Remove an attached behavior
  23812. * @see http://doc.babylonjs.com/features/behaviour
  23813. * @param behavior defines the behavior to attach
  23814. * @returns the current Node
  23815. */
  23816. removeBehavior(behavior: Behavior<Node>): Node;
  23817. /**
  23818. * Gets the list of attached behaviors
  23819. * @see http://doc.babylonjs.com/features/behaviour
  23820. */
  23821. readonly behaviors: Behavior<Node>[];
  23822. /**
  23823. * Gets an attached behavior by name
  23824. * @param name defines the name of the behavior to look for
  23825. * @see http://doc.babylonjs.com/features/behaviour
  23826. * @returns null if behavior was not found else the requested behavior
  23827. */
  23828. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  23829. /**
  23830. * Returns the latest update of the World matrix
  23831. * @returns a Matrix
  23832. */
  23833. getWorldMatrix(): Matrix;
  23834. /** @hidden */ getWorldMatrixDeterminant(): number;
  23835. /**
  23836. * Returns directly the latest state of the mesh World matrix.
  23837. * A Matrix is returned.
  23838. */
  23839. readonly worldMatrixFromCache: Matrix;
  23840. /** @hidden */ initCache(): void;
  23841. /** @hidden */
  23842. updateCache(force?: boolean): void;
  23843. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  23844. /** @hidden */ isSynchronized(): boolean;
  23845. /** @hidden */ markSyncedWithParent(): void;
  23846. /** @hidden */
  23847. isSynchronizedWithParent(): boolean;
  23848. /** @hidden */
  23849. isSynchronized(): boolean;
  23850. /**
  23851. * Is this node ready to be used/rendered
  23852. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23853. * @return true if the node is ready
  23854. */
  23855. isReady(completeCheck?: boolean): boolean;
  23856. /**
  23857. * Is this node enabled?
  23858. * 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
  23859. * @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
  23860. * @return whether this node (and its parent) is enabled
  23861. */
  23862. isEnabled(checkAncestors?: boolean): boolean;
  23863. /** @hidden */
  23864. protected _syncParentEnabledState(): void;
  23865. /**
  23866. * Set the enabled state of this node
  23867. * @param value defines the new enabled state
  23868. */
  23869. setEnabled(value: boolean): void;
  23870. /**
  23871. * Is this node a descendant of the given node?
  23872. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  23873. * @param ancestor defines the parent node to inspect
  23874. * @returns a boolean indicating if this node is a descendant of the given node
  23875. */
  23876. isDescendantOf(ancestor: Node): boolean;
  23877. /** @hidden */ getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  23878. /**
  23879. * Will return all nodes that have this node as ascendant
  23880. * @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
  23881. * @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
  23882. * @return all children nodes of all types
  23883. */
  23884. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  23885. /**
  23886. * Get all child-meshes of this node
  23887. * @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: false)
  23888. * @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
  23889. * @returns an array of AbstractMesh
  23890. */
  23891. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  23892. /**
  23893. * Get all direct children of this node
  23894. * @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
  23895. * @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)
  23896. * @returns an array of Node
  23897. */
  23898. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  23899. /** @hidden */ setReady(state: boolean): void;
  23900. /**
  23901. * Get an animation by name
  23902. * @param name defines the name of the animation to look for
  23903. * @returns null if not found else the requested animation
  23904. */
  23905. getAnimationByName(name: string): Nullable<Animation>;
  23906. /**
  23907. * Creates an animation range for this node
  23908. * @param name defines the name of the range
  23909. * @param from defines the starting key
  23910. * @param to defines the end key
  23911. */
  23912. createAnimationRange(name: string, from: number, to: number): void;
  23913. /**
  23914. * Delete a specific animation range
  23915. * @param name defines the name of the range to delete
  23916. * @param deleteFrames defines if animation frames from the range must be deleted as well
  23917. */
  23918. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  23919. /**
  23920. * Get an animation range by name
  23921. * @param name defines the name of the animation range to look for
  23922. * @returns null if not found else the requested animation range
  23923. */
  23924. getAnimationRange(name: string): Nullable<AnimationRange>;
  23925. /**
  23926. * Will start the animation sequence
  23927. * @param name defines the range frames for animation sequence
  23928. * @param loop defines if the animation should loop (false by default)
  23929. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  23930. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  23931. * @returns the object created for this animation. If range does not exist, it will return null
  23932. */
  23933. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  23934. /**
  23935. * Serialize animation ranges into a JSON compatible object
  23936. * @returns serialization object
  23937. */
  23938. serializeAnimationRanges(): any;
  23939. /**
  23940. * Computes the world matrix of the node
  23941. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  23942. * @returns the world matrix
  23943. */
  23944. computeWorldMatrix(force?: boolean): Matrix;
  23945. /**
  23946. * Releases resources associated with this node.
  23947. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23948. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23949. */
  23950. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23951. /**
  23952. * Parse animation range data from a serialization object and store them into a given node
  23953. * @param node defines where to store the animation ranges
  23954. * @param parsedNode defines the serialization object to read data from
  23955. * @param scene defines the hosting scene
  23956. */
  23957. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  23958. }
  23959. }
  23960. declare module BABYLON {
  23961. /**
  23962. * Class used to store any kind of animation
  23963. */
  23964. export class Animation {
  23965. /**Name of the animation */
  23966. name: string;
  23967. /**Property to animate */
  23968. targetProperty: string;
  23969. /**The frames per second of the animation */
  23970. framePerSecond: number;
  23971. /**The data type of the animation */
  23972. dataType: number;
  23973. /**The loop mode of the animation */
  23974. loopMode?: number | undefined;
  23975. /**Specifies if blending should be enabled */
  23976. enableBlending?: boolean | undefined;
  23977. /**
  23978. * Use matrix interpolation instead of using direct key value when animating matrices
  23979. */
  23980. static AllowMatricesInterpolation: boolean;
  23981. /**
  23982. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  23983. */
  23984. static AllowMatrixDecomposeForInterpolation: boolean;
  23985. /**
  23986. * Stores the key frames of the animation
  23987. */
  23988. private _keys;
  23989. /**
  23990. * Stores the easing function of the animation
  23991. */
  23992. private _easingFunction;
  23993. /**
  23994. * @hidden Internal use only
  23995. */ runtimeAnimations: RuntimeAnimation[];
  23996. /**
  23997. * The set of event that will be linked to this animation
  23998. */
  23999. private _events;
  24000. /**
  24001. * Stores an array of target property paths
  24002. */
  24003. targetPropertyPath: string[];
  24004. /**
  24005. * Stores the blending speed of the animation
  24006. */
  24007. blendingSpeed: number;
  24008. /**
  24009. * Stores the animation ranges for the animation
  24010. */
  24011. private _ranges;
  24012. /**
  24013. * @hidden Internal use
  24014. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  24015. /**
  24016. * Sets up an animation
  24017. * @param property The property to animate
  24018. * @param animationType The animation type to apply
  24019. * @param framePerSecond The frames per second of the animation
  24020. * @param easingFunction The easing function used in the animation
  24021. * @returns The created animation
  24022. */
  24023. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  24024. /**
  24025. * Create and start an animation on a node
  24026. * @param name defines the name of the global animation that will be run on all nodes
  24027. * @param node defines the root node where the animation will take place
  24028. * @param targetProperty defines property to animate
  24029. * @param framePerSecond defines the number of frame per second yo use
  24030. * @param totalFrame defines the number of frames in total
  24031. * @param from defines the initial value
  24032. * @param to defines the final value
  24033. * @param loopMode defines which loop mode you want to use (off by default)
  24034. * @param easingFunction defines the easing function to use (linear by default)
  24035. * @param onAnimationEnd defines the callback to call when animation end
  24036. * @returns the animatable created for this animation
  24037. */
  24038. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24039. /**
  24040. * Create and start an animation on a node and its descendants
  24041. * @param name defines the name of the global animation that will be run on all nodes
  24042. * @param node defines the root node where the animation will take place
  24043. * @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
  24044. * @param targetProperty defines property to animate
  24045. * @param framePerSecond defines the number of frame per second to use
  24046. * @param totalFrame defines the number of frames in total
  24047. * @param from defines the initial value
  24048. * @param to defines the final value
  24049. * @param loopMode defines which loop mode you want to use (off by default)
  24050. * @param easingFunction defines the easing function to use (linear by default)
  24051. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24052. * @returns the list of animatables created for all nodes
  24053. * @example https://www.babylonjs-playground.com/#MH0VLI
  24054. */
  24055. 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[]>;
  24056. /**
  24057. * Creates a new animation, merges it with the existing animations and starts it
  24058. * @param name Name of the animation
  24059. * @param node Node which contains the scene that begins the animations
  24060. * @param targetProperty Specifies which property to animate
  24061. * @param framePerSecond The frames per second of the animation
  24062. * @param totalFrame The total number of frames
  24063. * @param from The frame at the beginning of the animation
  24064. * @param to The frame at the end of the animation
  24065. * @param loopMode Specifies the loop mode of the animation
  24066. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  24067. * @param onAnimationEnd Callback to run once the animation is complete
  24068. * @returns Nullable animation
  24069. */
  24070. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24071. /**
  24072. * Transition property of an host to the target Value
  24073. * @param property The property to transition
  24074. * @param targetValue The target Value of the property
  24075. * @param host The object where the property to animate belongs
  24076. * @param scene Scene used to run the animation
  24077. * @param frameRate Framerate (in frame/s) to use
  24078. * @param transition The transition type we want to use
  24079. * @param duration The duration of the animation, in milliseconds
  24080. * @param onAnimationEnd Callback trigger at the end of the animation
  24081. * @returns Nullable animation
  24082. */
  24083. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  24084. /**
  24085. * Return the array of runtime animations currently using this animation
  24086. */
  24087. readonly runtimeAnimations: RuntimeAnimation[];
  24088. /**
  24089. * Specifies if any of the runtime animations are currently running
  24090. */
  24091. readonly hasRunningRuntimeAnimations: boolean;
  24092. /**
  24093. * Initializes the animation
  24094. * @param name Name of the animation
  24095. * @param targetProperty Property to animate
  24096. * @param framePerSecond The frames per second of the animation
  24097. * @param dataType The data type of the animation
  24098. * @param loopMode The loop mode of the animation
  24099. * @param enableBlending Specifies if blending should be enabled
  24100. */
  24101. constructor(
  24102. /**Name of the animation */
  24103. name: string,
  24104. /**Property to animate */
  24105. targetProperty: string,
  24106. /**The frames per second of the animation */
  24107. framePerSecond: number,
  24108. /**The data type of the animation */
  24109. dataType: number,
  24110. /**The loop mode of the animation */
  24111. loopMode?: number | undefined,
  24112. /**Specifies if blending should be enabled */
  24113. enableBlending?: boolean | undefined);
  24114. /**
  24115. * Converts the animation to a string
  24116. * @param fullDetails support for multiple levels of logging within scene loading
  24117. * @returns String form of the animation
  24118. */
  24119. toString(fullDetails?: boolean): string;
  24120. /**
  24121. * Add an event to this animation
  24122. * @param event Event to add
  24123. */
  24124. addEvent(event: AnimationEvent): void;
  24125. /**
  24126. * Remove all events found at the given frame
  24127. * @param frame The frame to remove events from
  24128. */
  24129. removeEvents(frame: number): void;
  24130. /**
  24131. * Retrieves all the events from the animation
  24132. * @returns Events from the animation
  24133. */
  24134. getEvents(): AnimationEvent[];
  24135. /**
  24136. * Creates an animation range
  24137. * @param name Name of the animation range
  24138. * @param from Starting frame of the animation range
  24139. * @param to Ending frame of the animation
  24140. */
  24141. createRange(name: string, from: number, to: number): void;
  24142. /**
  24143. * Deletes an animation range by name
  24144. * @param name Name of the animation range to delete
  24145. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  24146. */
  24147. deleteRange(name: string, deleteFrames?: boolean): void;
  24148. /**
  24149. * Gets the animation range by name, or null if not defined
  24150. * @param name Name of the animation range
  24151. * @returns Nullable animation range
  24152. */
  24153. getRange(name: string): Nullable<AnimationRange>;
  24154. /**
  24155. * Gets the key frames from the animation
  24156. * @returns The key frames of the animation
  24157. */
  24158. getKeys(): Array<IAnimationKey>;
  24159. /**
  24160. * Gets the highest frame rate of the animation
  24161. * @returns Highest frame rate of the animation
  24162. */
  24163. getHighestFrame(): number;
  24164. /**
  24165. * Gets the easing function of the animation
  24166. * @returns Easing function of the animation
  24167. */
  24168. getEasingFunction(): IEasingFunction;
  24169. /**
  24170. * Sets the easing function of the animation
  24171. * @param easingFunction A custom mathematical formula for animation
  24172. */
  24173. setEasingFunction(easingFunction: EasingFunction): void;
  24174. /**
  24175. * Interpolates a scalar linearly
  24176. * @param startValue Start value of the animation curve
  24177. * @param endValue End value of the animation curve
  24178. * @param gradient Scalar amount to interpolate
  24179. * @returns Interpolated scalar value
  24180. */
  24181. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  24182. /**
  24183. * Interpolates a scalar cubically
  24184. * @param startValue Start value of the animation curve
  24185. * @param outTangent End tangent of the animation
  24186. * @param endValue End value of the animation curve
  24187. * @param inTangent Start tangent of the animation curve
  24188. * @param gradient Scalar amount to interpolate
  24189. * @returns Interpolated scalar value
  24190. */
  24191. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  24192. /**
  24193. * Interpolates a quaternion using a spherical linear interpolation
  24194. * @param startValue Start value of the animation curve
  24195. * @param endValue End value of the animation curve
  24196. * @param gradient Scalar amount to interpolate
  24197. * @returns Interpolated quaternion value
  24198. */
  24199. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  24200. /**
  24201. * Interpolates a quaternion cubically
  24202. * @param startValue Start value of the animation curve
  24203. * @param outTangent End tangent of the animation curve
  24204. * @param endValue End value of the animation curve
  24205. * @param inTangent Start tangent of the animation curve
  24206. * @param gradient Scalar amount to interpolate
  24207. * @returns Interpolated quaternion value
  24208. */
  24209. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  24210. /**
  24211. * Interpolates a Vector3 linearl
  24212. * @param startValue Start value of the animation curve
  24213. * @param endValue End value of the animation curve
  24214. * @param gradient Scalar amount to interpolate
  24215. * @returns Interpolated scalar value
  24216. */
  24217. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  24218. /**
  24219. * Interpolates a Vector3 cubically
  24220. * @param startValue Start value of the animation curve
  24221. * @param outTangent End tangent of the animation
  24222. * @param endValue End value of the animation curve
  24223. * @param inTangent Start tangent of the animation curve
  24224. * @param gradient Scalar amount to interpolate
  24225. * @returns InterpolatedVector3 value
  24226. */
  24227. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  24228. /**
  24229. * Interpolates a Vector2 linearly
  24230. * @param startValue Start value of the animation curve
  24231. * @param endValue End value of the animation curve
  24232. * @param gradient Scalar amount to interpolate
  24233. * @returns Interpolated Vector2 value
  24234. */
  24235. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  24236. /**
  24237. * Interpolates a Vector2 cubically
  24238. * @param startValue Start value of the animation curve
  24239. * @param outTangent End tangent of the animation
  24240. * @param endValue End value of the animation curve
  24241. * @param inTangent Start tangent of the animation curve
  24242. * @param gradient Scalar amount to interpolate
  24243. * @returns Interpolated Vector2 value
  24244. */
  24245. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  24246. /**
  24247. * Interpolates a size linearly
  24248. * @param startValue Start value of the animation curve
  24249. * @param endValue End value of the animation curve
  24250. * @param gradient Scalar amount to interpolate
  24251. * @returns Interpolated Size value
  24252. */
  24253. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  24254. /**
  24255. * Interpolates a Color3 linearly
  24256. * @param startValue Start value of the animation curve
  24257. * @param endValue End value of the animation curve
  24258. * @param gradient Scalar amount to interpolate
  24259. * @returns Interpolated Color3 value
  24260. */
  24261. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  24262. /**
  24263. * @hidden Internal use only
  24264. */ getKeyValue(value: any): any;
  24265. /**
  24266. * @hidden Internal use only
  24267. */ interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  24268. /**
  24269. * Defines the function to use to interpolate matrices
  24270. * @param startValue defines the start matrix
  24271. * @param endValue defines the end matrix
  24272. * @param gradient defines the gradient between both matrices
  24273. * @param result defines an optional target matrix where to store the interpolation
  24274. * @returns the interpolated matrix
  24275. */
  24276. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  24277. /**
  24278. * Makes a copy of the animation
  24279. * @returns Cloned animation
  24280. */
  24281. clone(): Animation;
  24282. /**
  24283. * Sets the key frames of the animation
  24284. * @param values The animation key frames to set
  24285. */
  24286. setKeys(values: Array<IAnimationKey>): void;
  24287. /**
  24288. * Serializes the animation to an object
  24289. * @returns Serialized object
  24290. */
  24291. serialize(): any;
  24292. /**
  24293. * Float animation type
  24294. */
  24295. private static _ANIMATIONTYPE_FLOAT;
  24296. /**
  24297. * Vector3 animation type
  24298. */
  24299. private static _ANIMATIONTYPE_VECTOR3;
  24300. /**
  24301. * Quaternion animation type
  24302. */
  24303. private static _ANIMATIONTYPE_QUATERNION;
  24304. /**
  24305. * Matrix animation type
  24306. */
  24307. private static _ANIMATIONTYPE_MATRIX;
  24308. /**
  24309. * Color3 animation type
  24310. */
  24311. private static _ANIMATIONTYPE_COLOR3;
  24312. /**
  24313. * Vector2 animation type
  24314. */
  24315. private static _ANIMATIONTYPE_VECTOR2;
  24316. /**
  24317. * Size animation type
  24318. */
  24319. private static _ANIMATIONTYPE_SIZE;
  24320. /**
  24321. * Relative Loop Mode
  24322. */
  24323. private static _ANIMATIONLOOPMODE_RELATIVE;
  24324. /**
  24325. * Cycle Loop Mode
  24326. */
  24327. private static _ANIMATIONLOOPMODE_CYCLE;
  24328. /**
  24329. * Constant Loop Mode
  24330. */
  24331. private static _ANIMATIONLOOPMODE_CONSTANT;
  24332. /**
  24333. * Get the float animation type
  24334. */
  24335. static readonly ANIMATIONTYPE_FLOAT: number;
  24336. /**
  24337. * Get the Vector3 animation type
  24338. */
  24339. static readonly ANIMATIONTYPE_VECTOR3: number;
  24340. /**
  24341. * Get the Vector2 animation type
  24342. */
  24343. static readonly ANIMATIONTYPE_VECTOR2: number;
  24344. /**
  24345. * Get the Size animation type
  24346. */
  24347. static readonly ANIMATIONTYPE_SIZE: number;
  24348. /**
  24349. * Get the Quaternion animation type
  24350. */
  24351. static readonly ANIMATIONTYPE_QUATERNION: number;
  24352. /**
  24353. * Get the Matrix animation type
  24354. */
  24355. static readonly ANIMATIONTYPE_MATRIX: number;
  24356. /**
  24357. * Get the Color3 animation type
  24358. */
  24359. static readonly ANIMATIONTYPE_COLOR3: number;
  24360. /**
  24361. * Get the Relative Loop Mode
  24362. */
  24363. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  24364. /**
  24365. * Get the Cycle Loop Mode
  24366. */
  24367. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  24368. /**
  24369. * Get the Constant Loop Mode
  24370. */
  24371. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  24372. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  24373. /**
  24374. * Parses an animation object and creates an animation
  24375. * @param parsedAnimation Parsed animation object
  24376. * @returns Animation object
  24377. */
  24378. static Parse(parsedAnimation: any): Animation;
  24379. /**
  24380. * Appends the serialized animations from the source animations
  24381. * @param source Source containing the animations
  24382. * @param destination Target to store the animations
  24383. */
  24384. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  24385. }
  24386. }
  24387. declare module BABYLON {
  24388. /**
  24389. * Base class of all the textures in babylon.
  24390. * It groups all the common properties the materials, post process, lights... might need
  24391. * in order to make a correct use of the texture.
  24392. */
  24393. export class BaseTexture implements IAnimatable {
  24394. /**
  24395. * Default anisotropic filtering level for the application.
  24396. * It is set to 4 as a good tradeoff between perf and quality.
  24397. */
  24398. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  24399. /**
  24400. * Gets or sets the unique id of the texture
  24401. */
  24402. uniqueId: number;
  24403. /**
  24404. * Define the name of the texture.
  24405. */
  24406. name: string;
  24407. /**
  24408. * Gets or sets an object used to store user defined information.
  24409. */
  24410. metadata: any;
  24411. /**
  24412. * For internal use only. Please do not use.
  24413. */
  24414. reservedDataStore: any;
  24415. private _hasAlpha;
  24416. /**
  24417. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  24418. */
  24419. hasAlpha: boolean;
  24420. /**
  24421. * Defines if the alpha value should be determined via the rgb values.
  24422. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  24423. */
  24424. getAlphaFromRGB: boolean;
  24425. /**
  24426. * Intensity or strength of the texture.
  24427. * It is commonly used by materials to fine tune the intensity of the texture
  24428. */
  24429. level: number;
  24430. /**
  24431. * Define the UV chanel to use starting from 0 and defaulting to 0.
  24432. * This is part of the texture as textures usually maps to one uv set.
  24433. */
  24434. coordinatesIndex: number;
  24435. private _coordinatesMode;
  24436. /**
  24437. * How a texture is mapped.
  24438. *
  24439. * | Value | Type | Description |
  24440. * | ----- | ----------------------------------- | ----------- |
  24441. * | 0 | EXPLICIT_MODE | |
  24442. * | 1 | SPHERICAL_MODE | |
  24443. * | 2 | PLANAR_MODE | |
  24444. * | 3 | CUBIC_MODE | |
  24445. * | 4 | PROJECTION_MODE | |
  24446. * | 5 | SKYBOX_MODE | |
  24447. * | 6 | INVCUBIC_MODE | |
  24448. * | 7 | EQUIRECTANGULAR_MODE | |
  24449. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  24450. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  24451. */
  24452. coordinatesMode: number;
  24453. /**
  24454. * | Value | Type | Description |
  24455. * | ----- | ------------------ | ----------- |
  24456. * | 0 | CLAMP_ADDRESSMODE | |
  24457. * | 1 | WRAP_ADDRESSMODE | |
  24458. * | 2 | MIRROR_ADDRESSMODE | |
  24459. */
  24460. wrapU: number;
  24461. /**
  24462. * | Value | Type | Description |
  24463. * | ----- | ------------------ | ----------- |
  24464. * | 0 | CLAMP_ADDRESSMODE | |
  24465. * | 1 | WRAP_ADDRESSMODE | |
  24466. * | 2 | MIRROR_ADDRESSMODE | |
  24467. */
  24468. wrapV: number;
  24469. /**
  24470. * | Value | Type | Description |
  24471. * | ----- | ------------------ | ----------- |
  24472. * | 0 | CLAMP_ADDRESSMODE | |
  24473. * | 1 | WRAP_ADDRESSMODE | |
  24474. * | 2 | MIRROR_ADDRESSMODE | |
  24475. */
  24476. wrapR: number;
  24477. /**
  24478. * With compliant hardware and browser (supporting anisotropic filtering)
  24479. * this defines the level of anisotropic filtering in the texture.
  24480. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  24481. */
  24482. anisotropicFilteringLevel: number;
  24483. /**
  24484. * Define if the texture is a cube texture or if false a 2d texture.
  24485. */
  24486. isCube: boolean;
  24487. /**
  24488. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  24489. */
  24490. is3D: boolean;
  24491. /**
  24492. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  24493. * HDR texture are usually stored in linear space.
  24494. * This only impacts the PBR and Background materials
  24495. */
  24496. gammaSpace: boolean;
  24497. /**
  24498. * Gets whether or not the texture contains RGBD data.
  24499. */
  24500. readonly isRGBD: boolean;
  24501. /**
  24502. * Is Z inverted in the texture (useful in a cube texture).
  24503. */
  24504. invertZ: boolean;
  24505. /**
  24506. * Are mip maps generated for this texture or not.
  24507. */
  24508. readonly noMipmap: boolean;
  24509. /**
  24510. * @hidden
  24511. */
  24512. lodLevelInAlpha: boolean;
  24513. /**
  24514. * With prefiltered texture, defined the offset used during the prefiltering steps.
  24515. */
  24516. lodGenerationOffset: number;
  24517. /**
  24518. * With prefiltered texture, defined the scale used during the prefiltering steps.
  24519. */
  24520. lodGenerationScale: number;
  24521. /**
  24522. * Define if the texture is a render target.
  24523. */
  24524. isRenderTarget: boolean;
  24525. /**
  24526. * Define the unique id of the texture in the scene.
  24527. */
  24528. readonly uid: string;
  24529. /**
  24530. * Return a string representation of the texture.
  24531. * @returns the texture as a string
  24532. */
  24533. toString(): string;
  24534. /**
  24535. * Get the class name of the texture.
  24536. * @returns "BaseTexture"
  24537. */
  24538. getClassName(): string;
  24539. /**
  24540. * Define the list of animation attached to the texture.
  24541. */
  24542. animations: Animation[];
  24543. /**
  24544. * An event triggered when the texture is disposed.
  24545. */
  24546. onDisposeObservable: Observable<BaseTexture>;
  24547. private _onDisposeObserver;
  24548. /**
  24549. * Callback triggered when the texture has been disposed.
  24550. * Kept for back compatibility, you can use the onDisposeObservable instead.
  24551. */
  24552. onDispose: () => void;
  24553. /**
  24554. * Define the current state of the loading sequence when in delayed load mode.
  24555. */
  24556. delayLoadState: number;
  24557. private _scene;
  24558. /** @hidden */ texture: Nullable<InternalTexture>;
  24559. private _uid;
  24560. /**
  24561. * Define if the texture is preventinga material to render or not.
  24562. * If not and the texture is not ready, the engine will use a default black texture instead.
  24563. */
  24564. readonly isBlocking: boolean;
  24565. /**
  24566. * Instantiates a new BaseTexture.
  24567. * Base class of all the textures in babylon.
  24568. * It groups all the common properties the materials, post process, lights... might need
  24569. * in order to make a correct use of the texture.
  24570. * @param scene Define the scene the texture blongs to
  24571. */
  24572. constructor(scene: Nullable<Scene>);
  24573. /**
  24574. * Get the scene the texture belongs to.
  24575. * @returns the scene or null if undefined
  24576. */
  24577. getScene(): Nullable<Scene>;
  24578. /**
  24579. * Get the texture transform matrix used to offset tile the texture for istance.
  24580. * @returns the transformation matrix
  24581. */
  24582. getTextureMatrix(): Matrix;
  24583. /**
  24584. * Get the texture reflection matrix used to rotate/transform the reflection.
  24585. * @returns the reflection matrix
  24586. */
  24587. getReflectionTextureMatrix(): Matrix;
  24588. /**
  24589. * Get the underlying lower level texture from Babylon.
  24590. * @returns the insternal texture
  24591. */
  24592. getInternalTexture(): Nullable<InternalTexture>;
  24593. /**
  24594. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  24595. * @returns true if ready or not blocking
  24596. */
  24597. isReadyOrNotBlocking(): boolean;
  24598. /**
  24599. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  24600. * @returns true if fully ready
  24601. */
  24602. isReady(): boolean;
  24603. private _cachedSize;
  24604. /**
  24605. * Get the size of the texture.
  24606. * @returns the texture size.
  24607. */
  24608. getSize(): ISize;
  24609. /**
  24610. * Get the base size of the texture.
  24611. * It can be different from the size if the texture has been resized for POT for instance
  24612. * @returns the base size
  24613. */
  24614. getBaseSize(): ISize;
  24615. /**
  24616. * Update the sampling mode of the texture.
  24617. * Default is Trilinear mode.
  24618. *
  24619. * | Value | Type | Description |
  24620. * | ----- | ------------------ | ----------- |
  24621. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  24622. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  24623. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  24624. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  24625. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  24626. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  24627. * | 7 | NEAREST_LINEAR | |
  24628. * | 8 | NEAREST_NEAREST | |
  24629. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  24630. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  24631. * | 11 | LINEAR_LINEAR | |
  24632. * | 12 | LINEAR_NEAREST | |
  24633. *
  24634. * > _mag_: magnification filter (close to the viewer)
  24635. * > _min_: minification filter (far from the viewer)
  24636. * > _mip_: filter used between mip map levels
  24637. *@param samplingMode Define the new sampling mode of the texture
  24638. */
  24639. updateSamplingMode(samplingMode: number): void;
  24640. /**
  24641. * Scales the texture if is `canRescale()`
  24642. * @param ratio the resize factor we want to use to rescale
  24643. */
  24644. scale(ratio: number): void;
  24645. /**
  24646. * Get if the texture can rescale.
  24647. */
  24648. readonly canRescale: boolean;
  24649. /** @hidden */ getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  24650. /** @hidden */ rebuild(): void;
  24651. /**
  24652. * Triggers the load sequence in delayed load mode.
  24653. */
  24654. delayLoad(): void;
  24655. /**
  24656. * Clones the texture.
  24657. * @returns the cloned texture
  24658. */
  24659. clone(): Nullable<BaseTexture>;
  24660. /**
  24661. * Get the texture underlying type (INT, FLOAT...)
  24662. */
  24663. readonly textureType: number;
  24664. /**
  24665. * Get the texture underlying format (RGB, RGBA...)
  24666. */
  24667. readonly textureFormat: number;
  24668. /**
  24669. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  24670. * This will returns an RGBA array buffer containing either in values (0-255) or
  24671. * float values (0-1) depending of the underlying buffer type.
  24672. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  24673. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  24674. * @param buffer defines a user defined buffer to fill with data (can be null)
  24675. * @returns The Array buffer containing the pixels data.
  24676. */
  24677. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  24678. /**
  24679. * Release and destroy the underlying lower level texture aka internalTexture.
  24680. */
  24681. releaseInternalTexture(): void;
  24682. /**
  24683. * Get the polynomial representation of the texture data.
  24684. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  24685. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  24686. */
  24687. sphericalPolynomial: Nullable<SphericalPolynomial>;
  24688. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  24689. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  24690. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  24691. /**
  24692. * Dispose the texture and release its associated resources.
  24693. */
  24694. dispose(): void;
  24695. /**
  24696. * Serialize the texture into a JSON representation that can be parsed later on.
  24697. * @returns the JSON representation of the texture
  24698. */
  24699. serialize(): any;
  24700. /**
  24701. * Helper function to be called back once a list of texture contains only ready textures.
  24702. * @param textures Define the list of textures to wait for
  24703. * @param callback Define the callback triggered once the entire list will be ready
  24704. */
  24705. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  24706. }
  24707. }
  24708. declare module BABYLON {
  24709. /**
  24710. * Uniform buffer objects.
  24711. *
  24712. * Handles blocks of uniform on the GPU.
  24713. *
  24714. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  24715. *
  24716. * For more information, please refer to :
  24717. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  24718. */
  24719. export class UniformBuffer {
  24720. private _engine;
  24721. private _buffer;
  24722. private _data;
  24723. private _bufferData;
  24724. private _dynamic?;
  24725. private _uniformLocations;
  24726. private _uniformSizes;
  24727. private _uniformLocationPointer;
  24728. private _needSync;
  24729. private _noUBO;
  24730. private _currentEffect;
  24731. private static _MAX_UNIFORM_SIZE;
  24732. private static _tempBuffer;
  24733. /**
  24734. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  24735. * This is dynamic to allow compat with webgl 1 and 2.
  24736. * You will need to pass the name of the uniform as well as the value.
  24737. */
  24738. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  24739. /**
  24740. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  24741. * This is dynamic to allow compat with webgl 1 and 2.
  24742. * You will need to pass the name of the uniform as well as the value.
  24743. */
  24744. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  24745. /**
  24746. * Lambda to Update a single float in a uniform buffer.
  24747. * This is dynamic to allow compat with webgl 1 and 2.
  24748. * You will need to pass the name of the uniform as well as the value.
  24749. */
  24750. updateFloat: (name: string, x: number) => void;
  24751. /**
  24752. * Lambda to Update a vec2 of float in a uniform buffer.
  24753. * This is dynamic to allow compat with webgl 1 and 2.
  24754. * You will need to pass the name of the uniform as well as the value.
  24755. */
  24756. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  24757. /**
  24758. * Lambda to Update a vec3 of float in a uniform buffer.
  24759. * This is dynamic to allow compat with webgl 1 and 2.
  24760. * You will need to pass the name of the uniform as well as the value.
  24761. */
  24762. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  24763. /**
  24764. * Lambda to Update a vec4 of float in a uniform buffer.
  24765. * This is dynamic to allow compat with webgl 1 and 2.
  24766. * You will need to pass the name of the uniform as well as the value.
  24767. */
  24768. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  24769. /**
  24770. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  24771. * This is dynamic to allow compat with webgl 1 and 2.
  24772. * You will need to pass the name of the uniform as well as the value.
  24773. */
  24774. updateMatrix: (name: string, mat: Matrix) => void;
  24775. /**
  24776. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  24777. * This is dynamic to allow compat with webgl 1 and 2.
  24778. * You will need to pass the name of the uniform as well as the value.
  24779. */
  24780. updateVector3: (name: string, vector: Vector3) => void;
  24781. /**
  24782. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  24783. * This is dynamic to allow compat with webgl 1 and 2.
  24784. * You will need to pass the name of the uniform as well as the value.
  24785. */
  24786. updateVector4: (name: string, vector: Vector4) => void;
  24787. /**
  24788. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  24789. * This is dynamic to allow compat with webgl 1 and 2.
  24790. * You will need to pass the name of the uniform as well as the value.
  24791. */
  24792. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  24793. /**
  24794. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  24795. * This is dynamic to allow compat with webgl 1 and 2.
  24796. * You will need to pass the name of the uniform as well as the value.
  24797. */
  24798. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  24799. /**
  24800. * Instantiates a new Uniform buffer objects.
  24801. *
  24802. * Handles blocks of uniform on the GPU.
  24803. *
  24804. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  24805. *
  24806. * For more information, please refer to :
  24807. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  24808. * @param engine Define the engine the buffer is associated with
  24809. * @param data Define the data contained in the buffer
  24810. * @param dynamic Define if the buffer is updatable
  24811. */
  24812. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  24813. /**
  24814. * Indicates if the buffer is using the WebGL2 UBO implementation,
  24815. * or just falling back on setUniformXXX calls.
  24816. */
  24817. readonly useUbo: boolean;
  24818. /**
  24819. * Indicates if the WebGL underlying uniform buffer is in sync
  24820. * with the javascript cache data.
  24821. */
  24822. readonly isSync: boolean;
  24823. /**
  24824. * Indicates if the WebGL underlying uniform buffer is dynamic.
  24825. * Also, a dynamic UniformBuffer will disable cache verification and always
  24826. * update the underlying WebGL uniform buffer to the GPU.
  24827. * @returns if Dynamic, otherwise false
  24828. */
  24829. isDynamic(): boolean;
  24830. /**
  24831. * The data cache on JS side.
  24832. * @returns the underlying data as a float array
  24833. */
  24834. getData(): Float32Array;
  24835. /**
  24836. * The underlying WebGL Uniform buffer.
  24837. * @returns the webgl buffer
  24838. */
  24839. getBuffer(): Nullable<WebGLBuffer>;
  24840. /**
  24841. * std140 layout specifies how to align data within an UBO structure.
  24842. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  24843. * for specs.
  24844. */
  24845. private _fillAlignment;
  24846. /**
  24847. * Adds an uniform in the buffer.
  24848. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  24849. * for the layout to be correct !
  24850. * @param name Name of the uniform, as used in the uniform block in the shader.
  24851. * @param size Data size, or data directly.
  24852. */
  24853. addUniform(name: string, size: number | number[]): void;
  24854. /**
  24855. * Adds a Matrix 4x4 to the uniform buffer.
  24856. * @param name Name of the uniform, as used in the uniform block in the shader.
  24857. * @param mat A 4x4 matrix.
  24858. */
  24859. addMatrix(name: string, mat: Matrix): void;
  24860. /**
  24861. * Adds a vec2 to the uniform buffer.
  24862. * @param name Name of the uniform, as used in the uniform block in the shader.
  24863. * @param x Define the x component value of the vec2
  24864. * @param y Define the y component value of the vec2
  24865. */
  24866. addFloat2(name: string, x: number, y: number): void;
  24867. /**
  24868. * Adds a vec3 to the uniform buffer.
  24869. * @param name Name of the uniform, as used in the uniform block in the shader.
  24870. * @param x Define the x component value of the vec3
  24871. * @param y Define the y component value of the vec3
  24872. * @param z Define the z component value of the vec3
  24873. */
  24874. addFloat3(name: string, x: number, y: number, z: number): void;
  24875. /**
  24876. * Adds a vec3 to the uniform buffer.
  24877. * @param name Name of the uniform, as used in the uniform block in the shader.
  24878. * @param color Define the vec3 from a Color
  24879. */
  24880. addColor3(name: string, color: Color3): void;
  24881. /**
  24882. * Adds a vec4 to the uniform buffer.
  24883. * @param name Name of the uniform, as used in the uniform block in the shader.
  24884. * @param color Define the rgb components from a Color
  24885. * @param alpha Define the a component of the vec4
  24886. */
  24887. addColor4(name: string, color: Color3, alpha: number): void;
  24888. /**
  24889. * Adds a vec3 to the uniform buffer.
  24890. * @param name Name of the uniform, as used in the uniform block in the shader.
  24891. * @param vector Define the vec3 components from a Vector
  24892. */
  24893. addVector3(name: string, vector: Vector3): void;
  24894. /**
  24895. * Adds a Matrix 3x3 to the uniform buffer.
  24896. * @param name Name of the uniform, as used in the uniform block in the shader.
  24897. */
  24898. addMatrix3x3(name: string): void;
  24899. /**
  24900. * Adds a Matrix 2x2 to the uniform buffer.
  24901. * @param name Name of the uniform, as used in the uniform block in the shader.
  24902. */
  24903. addMatrix2x2(name: string): void;
  24904. /**
  24905. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  24906. */
  24907. create(): void;
  24908. /** @hidden */ rebuild(): void;
  24909. /**
  24910. * Updates the WebGL Uniform Buffer on the GPU.
  24911. * If the `dynamic` flag is set to true, no cache comparison is done.
  24912. * Otherwise, the buffer will be updated only if the cache differs.
  24913. */
  24914. update(): void;
  24915. /**
  24916. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  24917. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  24918. * @param data Define the flattened data
  24919. * @param size Define the size of the data.
  24920. */
  24921. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  24922. private _updateMatrix3x3ForUniform;
  24923. private _updateMatrix3x3ForEffect;
  24924. private _updateMatrix2x2ForEffect;
  24925. private _updateMatrix2x2ForUniform;
  24926. private _updateFloatForEffect;
  24927. private _updateFloatForUniform;
  24928. private _updateFloat2ForEffect;
  24929. private _updateFloat2ForUniform;
  24930. private _updateFloat3ForEffect;
  24931. private _updateFloat3ForUniform;
  24932. private _updateFloat4ForEffect;
  24933. private _updateFloat4ForUniform;
  24934. private _updateMatrixForEffect;
  24935. private _updateMatrixForUniform;
  24936. private _updateVector3ForEffect;
  24937. private _updateVector3ForUniform;
  24938. private _updateVector4ForEffect;
  24939. private _updateVector4ForUniform;
  24940. private _updateColor3ForEffect;
  24941. private _updateColor3ForUniform;
  24942. private _updateColor4ForEffect;
  24943. private _updateColor4ForUniform;
  24944. /**
  24945. * Sets a sampler uniform on the effect.
  24946. * @param name Define the name of the sampler.
  24947. * @param texture Define the texture to set in the sampler
  24948. */
  24949. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  24950. /**
  24951. * Directly updates the value of the uniform in the cache AND on the GPU.
  24952. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  24953. * @param data Define the flattened data
  24954. */
  24955. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  24956. /**
  24957. * Binds this uniform buffer to an effect.
  24958. * @param effect Define the effect to bind the buffer to
  24959. * @param name Name of the uniform block in the shader.
  24960. */
  24961. bindToEffect(effect: Effect, name: string): void;
  24962. /**
  24963. * Disposes the uniform buffer.
  24964. */
  24965. dispose(): void;
  24966. }
  24967. }
  24968. declare module BABYLON {
  24969. /**
  24970. * This represents the required contract to create a new type of texture loader.
  24971. */
  24972. export interface IInternalTextureLoader {
  24973. /**
  24974. * Defines wether the loader supports cascade loading the different faces.
  24975. */
  24976. supportCascades: boolean;
  24977. /**
  24978. * This returns if the loader support the current file information.
  24979. * @param extension defines the file extension of the file being loaded
  24980. * @param textureFormatInUse defines the current compressed format in use iun the engine
  24981. * @param fallback defines the fallback internal texture if any
  24982. * @param isBase64 defines whether the texture is encoded as a base64
  24983. * @param isBuffer defines whether the texture data are stored as a buffer
  24984. * @returns true if the loader can load the specified file
  24985. */
  24986. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  24987. /**
  24988. * Transform the url before loading if required.
  24989. * @param rootUrl the url of the texture
  24990. * @param textureFormatInUse defines the current compressed format in use iun the engine
  24991. * @returns the transformed texture
  24992. */
  24993. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  24994. /**
  24995. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  24996. * @param rootUrl the url of the texture
  24997. * @param textureFormatInUse defines the current compressed format in use iun the engine
  24998. * @returns the fallback texture
  24999. */
  25000. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  25001. /**
  25002. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  25003. * @param data contains the texture data
  25004. * @param texture defines the BabylonJS internal texture
  25005. * @param createPolynomials will be true if polynomials have been requested
  25006. * @param onLoad defines the callback to trigger once the texture is ready
  25007. * @param onError defines the callback to trigger in case of error
  25008. */
  25009. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  25010. /**
  25011. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  25012. * @param data contains the texture data
  25013. * @param texture defines the BabylonJS internal texture
  25014. * @param callback defines the method to call once ready to upload
  25015. */
  25016. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  25017. }
  25018. }
  25019. declare module BABYLON {
  25020. /**
  25021. * Creation options of the multi render target texture.
  25022. */
  25023. export interface IMultiRenderTargetOptions {
  25024. /**
  25025. * Define if the texture needs to create mip maps after render.
  25026. */
  25027. generateMipMaps?: boolean;
  25028. /**
  25029. * Define the types of all the draw buffers we want to create
  25030. */
  25031. types?: number[];
  25032. /**
  25033. * Define the sampling modes of all the draw buffers we want to create
  25034. */
  25035. samplingModes?: number[];
  25036. /**
  25037. * Define if a depth buffer is required
  25038. */
  25039. generateDepthBuffer?: boolean;
  25040. /**
  25041. * Define if a stencil buffer is required
  25042. */
  25043. generateStencilBuffer?: boolean;
  25044. /**
  25045. * Define if a depth texture is required instead of a depth buffer
  25046. */
  25047. generateDepthTexture?: boolean;
  25048. /**
  25049. * Define the number of desired draw buffers
  25050. */
  25051. textureCount?: number;
  25052. /**
  25053. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25054. */
  25055. doNotChangeAspectRatio?: boolean;
  25056. /**
  25057. * Define the default type of the buffers we are creating
  25058. */
  25059. defaultType?: number;
  25060. }
  25061. /**
  25062. * A multi render target, like a render target provides the ability to render to a texture.
  25063. * Unlike the render target, it can render to several draw buffers in one draw.
  25064. * This is specially interesting in deferred rendering or for any effects requiring more than
  25065. * just one color from a single pass.
  25066. */
  25067. export class MultiRenderTarget extends RenderTargetTexture {
  25068. private _internalTextures;
  25069. private _textures;
  25070. private _multiRenderTargetOptions;
  25071. /**
  25072. * Get if draw buffers are currently supported by the used hardware and browser.
  25073. */
  25074. readonly isSupported: boolean;
  25075. /**
  25076. * Get the list of textures generated by the multi render target.
  25077. */
  25078. readonly textures: Texture[];
  25079. /**
  25080. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25081. */
  25082. readonly depthTexture: Texture;
  25083. /**
  25084. * Set the wrapping mode on U of all the textures we are rendering to.
  25085. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25086. */
  25087. wrapU: number;
  25088. /**
  25089. * Set the wrapping mode on V of all the textures we are rendering to.
  25090. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25091. */
  25092. wrapV: number;
  25093. /**
  25094. * Instantiate a new multi render target texture.
  25095. * A multi render target, like a render target provides the ability to render to a texture.
  25096. * Unlike the render target, it can render to several draw buffers in one draw.
  25097. * This is specially interesting in deferred rendering or for any effects requiring more than
  25098. * just one color from a single pass.
  25099. * @param name Define the name of the texture
  25100. * @param size Define the size of the buffers to render to
  25101. * @param count Define the number of target we are rendering into
  25102. * @param scene Define the scene the texture belongs to
  25103. * @param options Define the options used to create the multi render target
  25104. */
  25105. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25106. /** @hidden */ rebuild(): void;
  25107. private _createInternalTextures;
  25108. private _createTextures;
  25109. /**
  25110. * Define the number of samples used if MSAA is enabled.
  25111. */
  25112. samples: number;
  25113. /**
  25114. * Resize all the textures in the multi render target.
  25115. * Be carrefull as it will recreate all the data in the new texture.
  25116. * @param size Define the new size
  25117. */
  25118. resize(size: any): void;
  25119. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25120. /**
  25121. * Dispose the render targets and their associated resources
  25122. */
  25123. dispose(): void;
  25124. /**
  25125. * Release all the underlying texture used as draw buffers.
  25126. */
  25127. releaseInternalTextures(): void;
  25128. }
  25129. }
  25130. declare module BABYLON {
  25131. /**
  25132. * Class used to work with sound analyzer using fast fourier transform (FFT)
  25133. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25134. */
  25135. export class Analyser {
  25136. /**
  25137. * Gets or sets the smoothing
  25138. * @ignorenaming
  25139. */
  25140. SMOOTHING: number;
  25141. /**
  25142. * Gets or sets the FFT table size
  25143. * @ignorenaming
  25144. */
  25145. FFT_SIZE: number;
  25146. /**
  25147. * Gets or sets the bar graph amplitude
  25148. * @ignorenaming
  25149. */
  25150. BARGRAPHAMPLITUDE: number;
  25151. /**
  25152. * Gets or sets the position of the debug canvas
  25153. * @ignorenaming
  25154. */
  25155. DEBUGCANVASPOS: {
  25156. x: number;
  25157. y: number;
  25158. };
  25159. /**
  25160. * Gets or sets the debug canvas size
  25161. * @ignorenaming
  25162. */
  25163. DEBUGCANVASSIZE: {
  25164. width: number;
  25165. height: number;
  25166. };
  25167. private _byteFreqs;
  25168. private _byteTime;
  25169. private _floatFreqs;
  25170. private _webAudioAnalyser;
  25171. private _debugCanvas;
  25172. private _debugCanvasContext;
  25173. private _scene;
  25174. private _registerFunc;
  25175. private _audioEngine;
  25176. /**
  25177. * Creates a new analyser
  25178. * @param scene defines hosting scene
  25179. */
  25180. constructor(scene: Scene);
  25181. /**
  25182. * Get the number of data values you will have to play with for the visualization
  25183. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  25184. * @returns a number
  25185. */
  25186. getFrequencyBinCount(): number;
  25187. /**
  25188. * Gets the current frequency data as a byte array
  25189. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25190. * @returns a Uint8Array
  25191. */
  25192. getByteFrequencyData(): Uint8Array;
  25193. /**
  25194. * Gets the current waveform as a byte array
  25195. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  25196. * @returns a Uint8Array
  25197. */
  25198. getByteTimeDomainData(): Uint8Array;
  25199. /**
  25200. * Gets the current frequency data as a float array
  25201. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25202. * @returns a Float32Array
  25203. */
  25204. getFloatFrequencyData(): Float32Array;
  25205. /**
  25206. * Renders the debug canvas
  25207. */
  25208. drawDebugCanvas(): void;
  25209. /**
  25210. * Stops rendering the debug canvas and removes it
  25211. */
  25212. stopDebugCanvas(): void;
  25213. /**
  25214. * Connects two audio nodes
  25215. * @param inputAudioNode defines first node to connect
  25216. * @param outputAudioNode defines second node to connect
  25217. */
  25218. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  25219. /**
  25220. * Releases all associated resources
  25221. */
  25222. dispose(): void;
  25223. }
  25224. }
  25225. declare module BABYLON {
  25226. /**
  25227. * This represents an audio engine and it is responsible
  25228. * to play, synchronize and analyse sounds throughout the application.
  25229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25230. */
  25231. export interface IAudioEngine extends IDisposable {
  25232. /**
  25233. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25234. */
  25235. readonly canUseWebAudio: boolean;
  25236. /**
  25237. * Gets the current AudioContext if available.
  25238. */
  25239. readonly audioContext: Nullable<AudioContext>;
  25240. /**
  25241. * The master gain node defines the global audio volume of your audio engine.
  25242. */
  25243. readonly masterGain: GainNode;
  25244. /**
  25245. * Gets whether or not mp3 are supported by your browser.
  25246. */
  25247. readonly isMP3supported: boolean;
  25248. /**
  25249. * Gets whether or not ogg are supported by your browser.
  25250. */
  25251. readonly isOGGsupported: boolean;
  25252. /**
  25253. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25254. * @ignoreNaming
  25255. */
  25256. WarnedWebAudioUnsupported: boolean;
  25257. /**
  25258. * Defines if the audio engine relies on a custom unlocked button.
  25259. * In this case, the embedded button will not be displayed.
  25260. */
  25261. useCustomUnlockedButton: boolean;
  25262. /**
  25263. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  25264. */
  25265. readonly unlocked: boolean;
  25266. /**
  25267. * Event raised when audio has been unlocked on the browser.
  25268. */
  25269. onAudioUnlockedObservable: Observable<AudioEngine>;
  25270. /**
  25271. * Event raised when audio has been locked on the browser.
  25272. */
  25273. onAudioLockedObservable: Observable<AudioEngine>;
  25274. /**
  25275. * Flags the audio engine in Locked state.
  25276. * This happens due to new browser policies preventing audio to autoplay.
  25277. */
  25278. lock(): void;
  25279. /**
  25280. * Unlocks the audio engine once a user action has been done on the dom.
  25281. * This is helpful to resume play once browser policies have been satisfied.
  25282. */
  25283. unlock(): void;
  25284. }
  25285. /**
  25286. * This represents the default audio engine used in babylon.
  25287. * It is responsible to play, synchronize and analyse sounds throughout the application.
  25288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25289. */
  25290. export class AudioEngine implements IAudioEngine {
  25291. private _audioContext;
  25292. private _audioContextInitialized;
  25293. private _muteButton;
  25294. private _hostElement;
  25295. /**
  25296. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25297. */
  25298. canUseWebAudio: boolean;
  25299. /**
  25300. * The master gain node defines the global audio volume of your audio engine.
  25301. */
  25302. masterGain: GainNode;
  25303. /**
  25304. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25305. * @ignoreNaming
  25306. */
  25307. WarnedWebAudioUnsupported: boolean;
  25308. /**
  25309. * Gets whether or not mp3 are supported by your browser.
  25310. */
  25311. isMP3supported: boolean;
  25312. /**
  25313. * Gets whether or not ogg are supported by your browser.
  25314. */
  25315. isOGGsupported: boolean;
  25316. /**
  25317. * Gets whether audio has been unlocked on the device.
  25318. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  25319. * a user interaction has happened.
  25320. */
  25321. unlocked: boolean;
  25322. /**
  25323. * Defines if the audio engine relies on a custom unlocked button.
  25324. * In this case, the embedded button will not be displayed.
  25325. */
  25326. useCustomUnlockedButton: boolean;
  25327. /**
  25328. * Event raised when audio has been unlocked on the browser.
  25329. */
  25330. onAudioUnlockedObservable: Observable<AudioEngine>;
  25331. /**
  25332. * Event raised when audio has been locked on the browser.
  25333. */
  25334. onAudioLockedObservable: Observable<AudioEngine>;
  25335. /**
  25336. * Gets the current AudioContext if available.
  25337. */
  25338. readonly audioContext: Nullable<AudioContext>;
  25339. private _connectedAnalyser;
  25340. /**
  25341. * Instantiates a new audio engine.
  25342. *
  25343. * There should be only one per page as some browsers restrict the number
  25344. * of audio contexts you can create.
  25345. * @param hostElement defines the host element where to display the mute icon if necessary
  25346. */
  25347. constructor(hostElement?: Nullable<HTMLElement>);
  25348. /**
  25349. * Flags the audio engine in Locked state.
  25350. * This happens due to new browser policies preventing audio to autoplay.
  25351. */
  25352. lock(): void;
  25353. /**
  25354. * Unlocks the audio engine once a user action has been done on the dom.
  25355. * This is helpful to resume play once browser policies have been satisfied.
  25356. */
  25357. unlock(): void;
  25358. private _resumeAudioContext;
  25359. private _initializeAudioContext;
  25360. private _tryToRun;
  25361. private _triggerRunningState;
  25362. private _triggerSuspendedState;
  25363. private _displayMuteButton;
  25364. private _moveButtonToTopLeft;
  25365. private _onResize;
  25366. private _hideMuteButton;
  25367. /**
  25368. * Destroy and release the resources associated with the audio ccontext.
  25369. */
  25370. dispose(): void;
  25371. /**
  25372. * Gets the global volume sets on the master gain.
  25373. * @returns the global volume if set or -1 otherwise
  25374. */
  25375. getGlobalVolume(): number;
  25376. /**
  25377. * Sets the global volume of your experience (sets on the master gain).
  25378. * @param newVolume Defines the new global volume of the application
  25379. */
  25380. setGlobalVolume(newVolume: number): void;
  25381. /**
  25382. * Connect the audio engine to an audio analyser allowing some amazing
  25383. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  25384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  25385. * @param analyser The analyser to connect to the engine
  25386. */
  25387. connectToAnalyser(analyser: Analyser): void;
  25388. }
  25389. }
  25390. declare module BABYLON {
  25391. /**
  25392. * Interface used to present a loading screen while loading a scene
  25393. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25394. */
  25395. export interface ILoadingScreen {
  25396. /**
  25397. * Function called to display the loading screen
  25398. */
  25399. displayLoadingUI: () => void;
  25400. /**
  25401. * Function called to hide the loading screen
  25402. */
  25403. hideLoadingUI: () => void;
  25404. /**
  25405. * Gets or sets the color to use for the background
  25406. */
  25407. loadingUIBackgroundColor: string;
  25408. /**
  25409. * Gets or sets the text to display while loading
  25410. */
  25411. loadingUIText: string;
  25412. }
  25413. /**
  25414. * Class used for the default loading screen
  25415. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25416. */
  25417. export class DefaultLoadingScreen implements ILoadingScreen {
  25418. private _renderingCanvas;
  25419. private _loadingText;
  25420. private _loadingDivBackgroundColor;
  25421. private _loadingDiv;
  25422. private _loadingTextDiv;
  25423. /**
  25424. * Creates a new default loading screen
  25425. * @param _renderingCanvas defines the canvas used to render the scene
  25426. * @param _loadingText defines the default text to display
  25427. * @param _loadingDivBackgroundColor defines the default background color
  25428. */
  25429. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  25430. /**
  25431. * Function called to display the loading screen
  25432. */
  25433. displayLoadingUI(): void;
  25434. /**
  25435. * Function called to hide the loading screen
  25436. */
  25437. hideLoadingUI(): void;
  25438. /**
  25439. * Gets or sets the text to display while loading
  25440. */
  25441. loadingUIText: string;
  25442. /**
  25443. * Gets or sets the color to use for the background
  25444. */
  25445. loadingUIBackgroundColor: string;
  25446. private _resizeLoadingUI;
  25447. }
  25448. }
  25449. declare module BABYLON {
  25450. /**
  25451. * Settings for finer control over video usage
  25452. */
  25453. export interface VideoTextureSettings {
  25454. /**
  25455. * Applies `autoplay` to video, if specified
  25456. */
  25457. autoPlay?: boolean;
  25458. /**
  25459. * Applies `loop` to video, if specified
  25460. */
  25461. loop?: boolean;
  25462. /**
  25463. * Automatically updates internal texture from video at every frame in the render loop
  25464. */
  25465. autoUpdateTexture: boolean;
  25466. /**
  25467. * Image src displayed during the video loading or until the user interacts with the video.
  25468. */
  25469. poster?: string;
  25470. }
  25471. /**
  25472. * If you want to display a video in your scene, this is the special texture for that.
  25473. * This special texture works similar to other textures, with the exception of a few parameters.
  25474. * @see https://doc.babylonjs.com/how_to/video_texture
  25475. */
  25476. export class VideoTexture extends Texture {
  25477. /**
  25478. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  25479. */
  25480. readonly autoUpdateTexture: boolean;
  25481. /**
  25482. * The video instance used by the texture internally
  25483. */
  25484. readonly video: HTMLVideoElement;
  25485. private _onUserActionRequestedObservable;
  25486. /**
  25487. * Event triggerd when a dom action is required by the user to play the video.
  25488. * This happens due to recent changes in browser policies preventing video to auto start.
  25489. */
  25490. readonly onUserActionRequestedObservable: Observable<Texture>;
  25491. private _generateMipMaps;
  25492. private _engine;
  25493. private _stillImageCaptured;
  25494. private _displayingPosterTexture;
  25495. private _settings;
  25496. private _createInternalTextureOnEvent;
  25497. /**
  25498. * Creates a video texture.
  25499. * If you want to display a video in your scene, this is the special texture for that.
  25500. * This special texture works similar to other textures, with the exception of a few parameters.
  25501. * @see https://doc.babylonjs.com/how_to/video_texture
  25502. * @param name optional name, will detect from video source, if not defined
  25503. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  25504. * @param scene is obviously the current scene.
  25505. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  25506. * @param invertY is false by default but can be used to invert video on Y axis
  25507. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  25508. * @param settings allows finer control over video usage
  25509. */
  25510. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  25511. private _getName;
  25512. private _getVideo;
  25513. private _createInternalTexture;
  25514. private reset;
  25515. /**
  25516. * @hidden Internal method to initiate `update`.
  25517. */ rebuild(): void;
  25518. /**
  25519. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  25520. */
  25521. update(): void;
  25522. /**
  25523. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  25524. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  25525. */
  25526. updateTexture(isVisible: boolean): void;
  25527. protected _updateInternalTexture: () => void;
  25528. /**
  25529. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  25530. * @param url New url.
  25531. */
  25532. updateURL(url: string): void;
  25533. /**
  25534. * Dispose the texture and release its associated resources.
  25535. */
  25536. dispose(): void;
  25537. /**
  25538. * Creates a video texture straight from your WebCam video feed.
  25539. * @param scene Define the scene the texture should be created in
  25540. * @param onReady Define a callback to triggered once the texture will be ready
  25541. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  25542. */
  25543. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  25544. minWidth: number;
  25545. maxWidth: number;
  25546. minHeight: number;
  25547. maxHeight: number;
  25548. deviceId: string;
  25549. }): void;
  25550. }
  25551. }
  25552. declare module BABYLON {
  25553. /**
  25554. * Interface for attribute information associated with buffer instanciation
  25555. */
  25556. export class InstancingAttributeInfo {
  25557. /**
  25558. * Index/offset of the attribute in the vertex shader
  25559. */
  25560. index: number;
  25561. /**
  25562. * size of the attribute, 1, 2, 3 or 4
  25563. */
  25564. attributeSize: number;
  25565. /**
  25566. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  25567. * default is FLOAT
  25568. */
  25569. attribyteType: number;
  25570. /**
  25571. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  25572. */
  25573. normalized: boolean;
  25574. /**
  25575. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  25576. */
  25577. offset: number;
  25578. /**
  25579. * Name of the GLSL attribute, for debugging purpose only
  25580. */
  25581. attributeName: string;
  25582. }
  25583. /**
  25584. * Define options used to create a depth texture
  25585. */
  25586. export class DepthTextureCreationOptions {
  25587. /** Specifies whether or not a stencil should be allocated in the texture */
  25588. generateStencil?: boolean;
  25589. /** Specifies whether or not bilinear filtering is enable on the texture */
  25590. bilinearFiltering?: boolean;
  25591. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  25592. comparisonFunction?: number;
  25593. /** Specifies if the created texture is a cube texture */
  25594. isCube?: boolean;
  25595. }
  25596. /**
  25597. * Class used to describe the capabilities of the engine relatively to the current browser
  25598. */
  25599. export class EngineCapabilities {
  25600. /** Maximum textures units per fragment shader */
  25601. maxTexturesImageUnits: number;
  25602. /** Maximum texture units per vertex shader */
  25603. maxVertexTextureImageUnits: number;
  25604. /** Maximum textures units in the entire pipeline */
  25605. maxCombinedTexturesImageUnits: number;
  25606. /** Maximum texture size */
  25607. maxTextureSize: number;
  25608. /** Maximum cube texture size */
  25609. maxCubemapTextureSize: number;
  25610. /** Maximum render texture size */
  25611. maxRenderTextureSize: number;
  25612. /** Maximum number of vertex attributes */
  25613. maxVertexAttribs: number;
  25614. /** Maximum number of varyings */
  25615. maxVaryingVectors: number;
  25616. /** Maximum number of uniforms per vertex shader */
  25617. maxVertexUniformVectors: number;
  25618. /** Maximum number of uniforms per fragment shader */
  25619. maxFragmentUniformVectors: number;
  25620. /** Defines if standard derivates (dx/dy) are supported */
  25621. standardDerivatives: boolean;
  25622. /** Defines if s3tc texture compression is supported */
  25623. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  25624. /** Defines if pvrtc texture compression is supported */
  25625. pvrtc: any;
  25626. /** Defines if etc1 texture compression is supported */
  25627. etc1: any;
  25628. /** Defines if etc2 texture compression is supported */
  25629. etc2: any;
  25630. /** Defines if astc texture compression is supported */
  25631. astc: any;
  25632. /** Defines if float textures are supported */
  25633. textureFloat: boolean;
  25634. /** Defines if vertex array objects are supported */
  25635. vertexArrayObject: boolean;
  25636. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  25637. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  25638. /** Gets the maximum level of anisotropy supported */
  25639. maxAnisotropy: number;
  25640. /** Defines if instancing is supported */
  25641. instancedArrays: boolean;
  25642. /** Defines if 32 bits indices are supported */
  25643. uintIndices: boolean;
  25644. /** Defines if high precision shaders are supported */
  25645. highPrecisionShaderSupported: boolean;
  25646. /** Defines if depth reading in the fragment shader is supported */
  25647. fragmentDepthSupported: boolean;
  25648. /** Defines if float texture linear filtering is supported*/
  25649. textureFloatLinearFiltering: boolean;
  25650. /** Defines if rendering to float textures is supported */
  25651. textureFloatRender: boolean;
  25652. /** Defines if half float textures are supported*/
  25653. textureHalfFloat: boolean;
  25654. /** Defines if half float texture linear filtering is supported*/
  25655. textureHalfFloatLinearFiltering: boolean;
  25656. /** Defines if rendering to half float textures is supported */
  25657. textureHalfFloatRender: boolean;
  25658. /** Defines if textureLOD shader command is supported */
  25659. textureLOD: boolean;
  25660. /** Defines if draw buffers extension is supported */
  25661. drawBuffersExtension: boolean;
  25662. /** Defines if depth textures are supported */
  25663. depthTextureExtension: boolean;
  25664. /** Defines if float color buffer are supported */
  25665. colorBufferFloat: boolean;
  25666. /** Gets disjoint timer query extension (null if not supported) */
  25667. timerQuery: EXT_disjoint_timer_query;
  25668. /** Defines if timestamp can be used with timer query */
  25669. canUseTimestampForTimerQuery: boolean;
  25670. /** Function used to let the system compiles shaders in background */
  25671. parallelShaderCompile: {
  25672. MAX_SHADER_COMPILER_THREADS_KHR: number;
  25673. maxShaderCompilerThreadsKHR: (thread: number) => void;
  25674. COMPLETION_STATUS_KHR: number;
  25675. };
  25676. }
  25677. /** Interface defining initialization parameters for Engine class */
  25678. export interface EngineOptions extends WebGLContextAttributes {
  25679. /**
  25680. * Defines if the engine should no exceed a specified device ratio
  25681. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  25682. */
  25683. limitDeviceRatio?: number;
  25684. /**
  25685. * Defines if webvr should be enabled automatically
  25686. * @see http://doc.babylonjs.com/how_to/webvr_camera
  25687. */
  25688. autoEnableWebVR?: boolean;
  25689. /**
  25690. * Defines if webgl2 should be turned off even if supported
  25691. * @see http://doc.babylonjs.com/features/webgl2
  25692. */
  25693. disableWebGL2Support?: boolean;
  25694. /**
  25695. * Defines if webaudio should be initialized as well
  25696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25697. */
  25698. audioEngine?: boolean;
  25699. /**
  25700. * Defines if animations should run using a deterministic lock step
  25701. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  25702. */
  25703. deterministicLockstep?: boolean;
  25704. /** Defines the maximum steps to use with deterministic lock step mode */
  25705. lockstepMaxSteps?: number;
  25706. /**
  25707. * Defines that engine should ignore context lost events
  25708. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  25709. */
  25710. doNotHandleContextLost?: boolean;
  25711. /**
  25712. * Defines that engine should ignore modifying touch action attribute and style
  25713. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  25714. */
  25715. doNotHandleTouchAction?: boolean;
  25716. }
  25717. /**
  25718. * Defines the interface used by display changed events
  25719. */
  25720. export interface IDisplayChangedEventArgs {
  25721. /** Gets the vrDisplay object (if any) */
  25722. vrDisplay: Nullable<any>;
  25723. /** Gets a boolean indicating if webVR is supported */
  25724. vrSupported: boolean;
  25725. }
  25726. /**
  25727. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  25728. */
  25729. export class Engine {
  25730. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  25731. static ExceptionList: ({
  25732. key: string;
  25733. capture: string;
  25734. captureConstraint: number;
  25735. targets: string[];
  25736. } | {
  25737. key: string;
  25738. capture: null;
  25739. captureConstraint: null;
  25740. targets: string[];
  25741. })[];
  25742. /** Gets the list of created engines */
  25743. static readonly Instances: Engine[];
  25744. /**
  25745. * Gets the latest created engine
  25746. */
  25747. static readonly LastCreatedEngine: Nullable<Engine>;
  25748. /**
  25749. * Gets the latest created scene
  25750. */
  25751. static readonly LastCreatedScene: Nullable<Scene>;
  25752. /**
  25753. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  25754. * @param flag defines which part of the materials must be marked as dirty
  25755. * @param predicate defines a predicate used to filter which materials should be affected
  25756. */
  25757. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  25758. /**
  25759. * Hidden
  25760. */ private static _TextureLoaders: IInternalTextureLoader[];
  25761. /** Defines that alpha blending is disabled */
  25762. static readonly ALPHA_DISABLE: number;
  25763. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  25764. static readonly ALPHA_ADD: number;
  25765. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  25766. static readonly ALPHA_COMBINE: number;
  25767. /** Defines that alpha blending to DEST - SRC * DEST */
  25768. static readonly ALPHA_SUBTRACT: number;
  25769. /** Defines that alpha blending to SRC * DEST */
  25770. static readonly ALPHA_MULTIPLY: number;
  25771. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  25772. static readonly ALPHA_MAXIMIZED: number;
  25773. /** Defines that alpha blending to SRC + DEST */
  25774. static readonly ALPHA_ONEONE: number;
  25775. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  25776. static readonly ALPHA_PREMULTIPLIED: number;
  25777. /**
  25778. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  25779. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  25780. */
  25781. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  25782. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  25783. static readonly ALPHA_INTERPOLATE: number;
  25784. /**
  25785. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  25786. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  25787. */
  25788. static readonly ALPHA_SCREENMODE: number;
  25789. /** Defines that the ressource is not delayed*/
  25790. static readonly DELAYLOADSTATE_NONE: number;
  25791. /** Defines that the ressource was successfully delay loaded */
  25792. static readonly DELAYLOADSTATE_LOADED: number;
  25793. /** Defines that the ressource is currently delay loading */
  25794. static readonly DELAYLOADSTATE_LOADING: number;
  25795. /** Defines that the ressource is delayed and has not started loading */
  25796. static readonly DELAYLOADSTATE_NOTLOADED: number;
  25797. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  25798. static readonly NEVER: number;
  25799. /** 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 */
  25800. static readonly ALWAYS: number;
  25801. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  25802. static readonly LESS: number;
  25803. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  25804. static readonly EQUAL: number;
  25805. /** 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 */
  25806. static readonly LEQUAL: number;
  25807. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  25808. static readonly GREATER: number;
  25809. /** 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 */
  25810. static readonly GEQUAL: number;
  25811. /** 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 */
  25812. static readonly NOTEQUAL: number;
  25813. /** Passed to stencilOperation to specify that stencil value must be kept */
  25814. static readonly KEEP: number;
  25815. /** Passed to stencilOperation to specify that stencil value must be replaced */
  25816. static readonly REPLACE: number;
  25817. /** Passed to stencilOperation to specify that stencil value must be incremented */
  25818. static readonly INCR: number;
  25819. /** Passed to stencilOperation to specify that stencil value must be decremented */
  25820. static readonly DECR: number;
  25821. /** Passed to stencilOperation to specify that stencil value must be inverted */
  25822. static readonly INVERT: number;
  25823. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  25824. static readonly INCR_WRAP: number;
  25825. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  25826. static readonly DECR_WRAP: number;
  25827. /** Texture is not repeating outside of 0..1 UVs */
  25828. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  25829. /** Texture is repeating outside of 0..1 UVs */
  25830. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  25831. /** Texture is repeating and mirrored */
  25832. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  25833. /** ALPHA */
  25834. static readonly TEXTUREFORMAT_ALPHA: number;
  25835. /** LUMINANCE */
  25836. static readonly TEXTUREFORMAT_LUMINANCE: number;
  25837. /** LUMINANCE_ALPHA */
  25838. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  25839. /** RGB */
  25840. static readonly TEXTUREFORMAT_RGB: number;
  25841. /** RGBA */
  25842. static readonly TEXTUREFORMAT_RGBA: number;
  25843. /** RED */
  25844. static readonly TEXTUREFORMAT_RED: number;
  25845. /** RED (2nd reference) */
  25846. static readonly TEXTUREFORMAT_R: number;
  25847. /** RG */
  25848. static readonly TEXTUREFORMAT_RG: number;
  25849. /** RED_INTEGER */
  25850. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  25851. /** RED_INTEGER (2nd reference) */
  25852. static readonly TEXTUREFORMAT_R_INTEGER: number;
  25853. /** RG_INTEGER */
  25854. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  25855. /** RGB_INTEGER */
  25856. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  25857. /** RGBA_INTEGER */
  25858. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  25859. /** UNSIGNED_BYTE */
  25860. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  25861. /** UNSIGNED_BYTE (2nd reference) */
  25862. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  25863. /** FLOAT */
  25864. static readonly TEXTURETYPE_FLOAT: number;
  25865. /** HALF_FLOAT */
  25866. static readonly TEXTURETYPE_HALF_FLOAT: number;
  25867. /** BYTE */
  25868. static readonly TEXTURETYPE_BYTE: number;
  25869. /** SHORT */
  25870. static readonly TEXTURETYPE_SHORT: number;
  25871. /** UNSIGNED_SHORT */
  25872. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  25873. /** INT */
  25874. static readonly TEXTURETYPE_INT: number;
  25875. /** UNSIGNED_INT */
  25876. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  25877. /** UNSIGNED_SHORT_4_4_4_4 */
  25878. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  25879. /** UNSIGNED_SHORT_5_5_5_1 */
  25880. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  25881. /** UNSIGNED_SHORT_5_6_5 */
  25882. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  25883. /** UNSIGNED_INT_2_10_10_10_REV */
  25884. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  25885. /** UNSIGNED_INT_24_8 */
  25886. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  25887. /** UNSIGNED_INT_10F_11F_11F_REV */
  25888. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  25889. /** UNSIGNED_INT_5_9_9_9_REV */
  25890. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  25891. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  25892. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  25893. /** nearest is mag = nearest and min = nearest and mip = linear */
  25894. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  25895. /** Bilinear is mag = linear and min = linear and mip = nearest */
  25896. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  25897. /** Trilinear is mag = linear and min = linear and mip = linear */
  25898. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  25899. /** nearest is mag = nearest and min = nearest and mip = linear */
  25900. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  25901. /** Bilinear is mag = linear and min = linear and mip = nearest */
  25902. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  25903. /** Trilinear is mag = linear and min = linear and mip = linear */
  25904. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  25905. /** mag = nearest and min = nearest and mip = nearest */
  25906. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  25907. /** mag = nearest and min = linear and mip = nearest */
  25908. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  25909. /** mag = nearest and min = linear and mip = linear */
  25910. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  25911. /** mag = nearest and min = linear and mip = none */
  25912. static readonly TEXTURE_NEAREST_LINEAR: number;
  25913. /** mag = nearest and min = nearest and mip = none */
  25914. static readonly TEXTURE_NEAREST_NEAREST: number;
  25915. /** mag = linear and min = nearest and mip = nearest */
  25916. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  25917. /** mag = linear and min = nearest and mip = linear */
  25918. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  25919. /** mag = linear and min = linear and mip = none */
  25920. static readonly TEXTURE_LINEAR_LINEAR: number;
  25921. /** mag = linear and min = nearest and mip = none */
  25922. static readonly TEXTURE_LINEAR_NEAREST: number;
  25923. /** Explicit coordinates mode */
  25924. static readonly TEXTURE_EXPLICIT_MODE: number;
  25925. /** Spherical coordinates mode */
  25926. static readonly TEXTURE_SPHERICAL_MODE: number;
  25927. /** Planar coordinates mode */
  25928. static readonly TEXTURE_PLANAR_MODE: number;
  25929. /** Cubic coordinates mode */
  25930. static readonly TEXTURE_CUBIC_MODE: number;
  25931. /** Projection coordinates mode */
  25932. static readonly TEXTURE_PROJECTION_MODE: number;
  25933. /** Skybox coordinates mode */
  25934. static readonly TEXTURE_SKYBOX_MODE: number;
  25935. /** Inverse Cubic coordinates mode */
  25936. static readonly TEXTURE_INVCUBIC_MODE: number;
  25937. /** Equirectangular coordinates mode */
  25938. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  25939. /** Equirectangular Fixed coordinates mode */
  25940. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  25941. /** Equirectangular Fixed Mirrored coordinates mode */
  25942. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  25943. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  25944. static readonly SCALEMODE_FLOOR: number;
  25945. /** Defines that texture rescaling will look for the nearest power of 2 size */
  25946. static readonly SCALEMODE_NEAREST: number;
  25947. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  25948. static readonly SCALEMODE_CEILING: number;
  25949. /**
  25950. * Returns the current version of the framework
  25951. */
  25952. static readonly Version: string;
  25953. /**
  25954. * Returns a string describing the current engine
  25955. */
  25956. readonly description: string;
  25957. /**
  25958. * Gets or sets the epsilon value used by collision engine
  25959. */
  25960. static CollisionsEpsilon: number;
  25961. /**
  25962. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  25963. */
  25964. static ShadersRepository: string;
  25965. /**
  25966. * Method called to create the default loading screen.
  25967. * This can be overriden in your own app.
  25968. * @param canvas The rendering canvas element
  25969. * @returns The loading screen
  25970. */
  25971. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  25972. /**
  25973. * Method called to create the default rescale post process on each engine.
  25974. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  25975. /**
  25976. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  25977. */
  25978. forcePOTTextures: boolean;
  25979. /**
  25980. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  25981. */
  25982. isFullscreen: boolean;
  25983. /**
  25984. * Gets a boolean indicating if the pointer is currently locked
  25985. */
  25986. isPointerLock: boolean;
  25987. /**
  25988. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  25989. */
  25990. cullBackFaces: boolean;
  25991. /**
  25992. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  25993. */
  25994. renderEvenInBackground: boolean;
  25995. /**
  25996. * Gets or sets a boolean indicating that cache can be kept between frames
  25997. */
  25998. preventCacheWipeBetweenFrames: boolean;
  25999. /**
  26000. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26001. **/
  26002. enableOfflineSupport: boolean;
  26003. /**
  26004. * 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)
  26005. **/
  26006. disableManifestCheck: boolean;
  26007. /**
  26008. * Gets the list of created scenes
  26009. */
  26010. scenes: Scene[];
  26011. /**
  26012. * Event raised when a new scene is created
  26013. */
  26014. onNewSceneAddedObservable: Observable<Scene>;
  26015. /**
  26016. * Gets the list of created postprocesses
  26017. */
  26018. postProcesses: PostProcess[];
  26019. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26020. validateShaderPrograms: boolean;
  26021. /**
  26022. * Observable event triggered each time the rendering canvas is resized
  26023. */
  26024. onResizeObservable: Observable<Engine>;
  26025. /**
  26026. * Observable event triggered each time the canvas loses focus
  26027. */
  26028. onCanvasBlurObservable: Observable<Engine>;
  26029. /**
  26030. * Observable event triggered each time the canvas gains focus
  26031. */
  26032. onCanvasFocusObservable: Observable<Engine>;
  26033. /**
  26034. * Observable event triggered each time the canvas receives pointerout event
  26035. */
  26036. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26037. /**
  26038. * Observable event triggered before each texture is initialized
  26039. */
  26040. onBeforeTextureInitObservable: Observable<Texture>;
  26041. private _vrDisplay;
  26042. private _vrSupported;
  26043. private _oldSize;
  26044. private _oldHardwareScaleFactor;
  26045. private _vrExclusivePointerMode;
  26046. private _webVRInitPromise;
  26047. /**
  26048. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26049. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26050. */
  26051. readonly isInVRExclusivePointerMode: boolean;
  26052. /**
  26053. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26054. */
  26055. disableUniformBuffers: boolean;
  26056. /** @hidden */ uniformBuffers: UniformBuffer[];
  26057. /**
  26058. * Gets a boolean indicating that the engine supports uniform buffers
  26059. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26060. */
  26061. readonly supportsUniformBuffers: boolean;
  26062. /**
  26063. * Observable raised when the engine begins a new frame
  26064. */
  26065. onBeginFrameObservable: Observable<Engine>;
  26066. /**
  26067. * If set, will be used to request the next animation frame for the render loop
  26068. */
  26069. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  26070. /**
  26071. * Observable raised when the engine ends the current frame
  26072. */
  26073. onEndFrameObservable: Observable<Engine>;
  26074. /**
  26075. * Observable raised when the engine is about to compile a shader
  26076. */
  26077. onBeforeShaderCompilationObservable: Observable<Engine>;
  26078. /**
  26079. * Observable raised when the engine has jsut compiled a shader
  26080. */
  26081. onAfterShaderCompilationObservable: Observable<Engine>;
  26082. /** @hidden */ gl: WebGLRenderingContext;
  26083. private _renderingCanvas;
  26084. private _windowIsBackground;
  26085. private _webGLVersion;
  26086. /**
  26087. * Gets a boolean indicating that only power of 2 textures are supported
  26088. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  26089. */
  26090. readonly needPOTTextures: boolean;
  26091. /** @hidden */ badOS: boolean;
  26092. /** @hidden */ badDesktopOS: boolean;
  26093. /**
  26094. * Gets or sets a value indicating if we want to disable texture binding optimization.
  26095. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  26096. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  26097. */
  26098. disableTextureBindingOptimization: boolean;
  26099. /**
  26100. * Gets the audio engine
  26101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26102. * @ignorenaming
  26103. */
  26104. static audioEngine: IAudioEngine;
  26105. /**
  26106. * Default AudioEngine factory responsible of creating the Audio Engine.
  26107. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  26108. */
  26109. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  26110. /**
  26111. * Default offline support factory responsible of creating a tool used to store data locally.
  26112. * By default, this will create a Database object if the workload has been embedded.
  26113. */
  26114. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  26115. private _onFocus;
  26116. private _onBlur;
  26117. private _onCanvasPointerOut;
  26118. private _onCanvasBlur;
  26119. private _onCanvasFocus;
  26120. private _onFullscreenChange;
  26121. private _onPointerLockChange;
  26122. private _onVRDisplayPointerRestricted;
  26123. private _onVRDisplayPointerUnrestricted;
  26124. private _onVrDisplayConnect;
  26125. private _onVrDisplayDisconnect;
  26126. private _onVrDisplayPresentChange;
  26127. /**
  26128. * Observable signaled when VR display mode changes
  26129. */
  26130. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26131. /**
  26132. * Observable signaled when VR request present is complete
  26133. */
  26134. onVRRequestPresentComplete: Observable<boolean>;
  26135. /**
  26136. * Observable signaled when VR request present starts
  26137. */
  26138. onVRRequestPresentStart: Observable<Engine>;
  26139. private _hardwareScalingLevel;
  26140. /** @hidden */
  26141. protected _caps: EngineCapabilities;
  26142. private _pointerLockRequested;
  26143. private _isStencilEnable;
  26144. private _colorWrite;
  26145. private _loadingScreen;
  26146. /** @hidden */ drawCalls: PerfCounter;
  26147. /** @hidden */ textureCollisions: PerfCounter;
  26148. private _glVersion;
  26149. private _glRenderer;
  26150. private _glVendor;
  26151. private _videoTextureSupported;
  26152. private _renderingQueueLaunched;
  26153. private _activeRenderLoops;
  26154. private _deterministicLockstep;
  26155. private _lockstepMaxSteps;
  26156. /**
  26157. * Observable signaled when a context lost event is raised
  26158. */
  26159. onContextLostObservable: Observable<Engine>;
  26160. /**
  26161. * Observable signaled when a context restored event is raised
  26162. */
  26163. onContextRestoredObservable: Observable<Engine>;
  26164. private _onContextLost;
  26165. private _onContextRestored;
  26166. private _contextWasLost;
  26167. private _doNotHandleContextLost;
  26168. /**
  26169. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  26170. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  26171. */
  26172. doNotHandleContextLost: boolean;
  26173. private _performanceMonitor;
  26174. private _fps;
  26175. private _deltaTime;
  26176. /**
  26177. * Turn this value on if you want to pause FPS computation when in background
  26178. */
  26179. disablePerformanceMonitorInBackground: boolean;
  26180. /**
  26181. * Gets the performance monitor attached to this engine
  26182. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  26183. */
  26184. readonly performanceMonitor: PerformanceMonitor;
  26185. /** @hidden */
  26186. protected _depthCullingState: _DepthCullingState;
  26187. /** @hidden */
  26188. protected _stencilState: _StencilState;
  26189. /** @hidden */
  26190. protected _alphaState: _AlphaState;
  26191. /** @hidden */
  26192. protected _alphaMode: number;
  26193. protected _internalTexturesCache: InternalTexture[];
  26194. /** @hidden */
  26195. protected _activeChannel: number;
  26196. private _currentTextureChannel;
  26197. /** @hidden */
  26198. protected _boundTexturesCache: {
  26199. [key: string]: Nullable<InternalTexture>;
  26200. };
  26201. /** @hidden */
  26202. protected _currentEffect: Nullable<Effect>;
  26203. /** @hidden */
  26204. protected _currentProgram: Nullable<WebGLProgram>;
  26205. private _compiledEffects;
  26206. private _vertexAttribArraysEnabled;
  26207. /** @hidden */
  26208. protected _cachedViewport: Nullable<Viewport>;
  26209. private _cachedVertexArrayObject;
  26210. /** @hidden */
  26211. protected _cachedVertexBuffers: any;
  26212. /** @hidden */
  26213. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  26214. /** @hidden */
  26215. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  26216. /** @hidden */
  26217. protected _currentRenderTarget: Nullable<InternalTexture>;
  26218. private _uintIndicesCurrentlySet;
  26219. private _currentBoundBuffer;
  26220. /** @hidden */
  26221. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  26222. private _currentBufferPointers;
  26223. private _currentInstanceLocations;
  26224. private _currentInstanceBuffers;
  26225. private _textureUnits;
  26226. private _firstBoundInternalTextureTracker;
  26227. private _lastBoundInternalTextureTracker;
  26228. private _workingCanvas;
  26229. private _workingContext;
  26230. private _rescalePostProcess;
  26231. private _dummyFramebuffer;
  26232. private _externalData;
  26233. private _bindedRenderFunction;
  26234. private _vaoRecordInProgress;
  26235. private _mustWipeVertexAttributes;
  26236. private _emptyTexture;
  26237. private _emptyCubeTexture;
  26238. private _emptyTexture3D;
  26239. /** @hidden */ frameHandler: number;
  26240. private _nextFreeTextureSlots;
  26241. private _maxSimultaneousTextures;
  26242. private _activeRequests;
  26243. private _texturesSupported;
  26244. private _textureFormatInUse;
  26245. /**
  26246. * Gets the list of texture formats supported
  26247. */
  26248. readonly texturesSupported: Array<string>;
  26249. /**
  26250. * Gets the list of texture formats in use
  26251. */
  26252. readonly textureFormatInUse: Nullable<string>;
  26253. /**
  26254. * Gets the current viewport
  26255. */
  26256. readonly currentViewport: Nullable<Viewport>;
  26257. /**
  26258. * Gets the default empty texture
  26259. */
  26260. readonly emptyTexture: InternalTexture;
  26261. /**
  26262. * Gets the default empty 3D texture
  26263. */
  26264. readonly emptyTexture3D: InternalTexture;
  26265. /**
  26266. * Gets the default empty cube texture
  26267. */
  26268. readonly emptyCubeTexture: InternalTexture;
  26269. /**
  26270. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  26271. */
  26272. readonly premultipliedAlpha: boolean;
  26273. /**
  26274. * Creates a new engine
  26275. * @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
  26276. * @param antialias defines enable antialiasing (default: false)
  26277. * @param options defines further options to be sent to the getContext() function
  26278. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  26279. */
  26280. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  26281. private _disableTouchAction;
  26282. private _rebuildInternalTextures;
  26283. private _rebuildEffects;
  26284. /**
  26285. * Gets a boolean indicating if all created effects are ready
  26286. * @returns true if all effects are ready
  26287. */
  26288. areAllEffectsReady(): boolean;
  26289. private _rebuildBuffers;
  26290. private _initGLContext;
  26291. /**
  26292. * Gets version of the current webGL context
  26293. */
  26294. readonly webGLVersion: number;
  26295. /**
  26296. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  26297. */
  26298. readonly isStencilEnable: boolean;
  26299. private _prepareWorkingCanvas;
  26300. /**
  26301. * Reset the texture cache to empty state
  26302. */
  26303. resetTextureCache(): void;
  26304. /**
  26305. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  26306. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26307. * @returns true if engine is in deterministic lock step mode
  26308. */
  26309. isDeterministicLockStep(): boolean;
  26310. /**
  26311. * Gets the max steps when engine is running in deterministic lock step
  26312. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26313. * @returns the max steps
  26314. */
  26315. getLockstepMaxSteps(): number;
  26316. /**
  26317. * Gets an object containing information about the current webGL context
  26318. * @returns an object containing the vender, the renderer and the version of the current webGL context
  26319. */
  26320. getGlInfo(): {
  26321. vendor: string;
  26322. renderer: string;
  26323. version: string;
  26324. };
  26325. /**
  26326. * Gets current aspect ratio
  26327. * @param camera defines the camera to use to get the aspect ratio
  26328. * @param useScreen defines if screen size must be used (or the current render target if any)
  26329. * @returns a number defining the aspect ratio
  26330. */
  26331. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  26332. /**
  26333. * Gets current screen aspect ratio
  26334. * @returns a number defining the aspect ratio
  26335. */
  26336. getScreenAspectRatio(): number;
  26337. /**
  26338. * Gets the current render width
  26339. * @param useScreen defines if screen size must be used (or the current render target if any)
  26340. * @returns a number defining the current render width
  26341. */
  26342. getRenderWidth(useScreen?: boolean): number;
  26343. /**
  26344. * Gets the current render height
  26345. * @param useScreen defines if screen size must be used (or the current render target if any)
  26346. * @returns a number defining the current render height
  26347. */
  26348. getRenderHeight(useScreen?: boolean): number;
  26349. /**
  26350. * Gets the HTML canvas attached with the current webGL context
  26351. * @returns a HTML canvas
  26352. */
  26353. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  26354. /**
  26355. * Gets the client rect of the HTML canvas attached with the current webGL context
  26356. * @returns a client rectanglee
  26357. */
  26358. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  26359. /**
  26360. * Defines the hardware scaling level.
  26361. * By default the hardware scaling level is computed from the window device ratio.
  26362. * 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.
  26363. * @param level defines the level to use
  26364. */
  26365. setHardwareScalingLevel(level: number): void;
  26366. /**
  26367. * Gets the current hardware scaling level.
  26368. * By default the hardware scaling level is computed from the window device ratio.
  26369. * 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.
  26370. * @returns a number indicating the current hardware scaling level
  26371. */
  26372. getHardwareScalingLevel(): number;
  26373. /**
  26374. * Gets the list of loaded textures
  26375. * @returns an array containing all loaded textures
  26376. */
  26377. getLoadedTexturesCache(): InternalTexture[];
  26378. /**
  26379. * Gets the object containing all engine capabilities
  26380. * @returns the EngineCapabilities object
  26381. */
  26382. getCaps(): EngineCapabilities;
  26383. /**
  26384. * Gets the current depth function
  26385. * @returns a number defining the depth function
  26386. */
  26387. getDepthFunction(): Nullable<number>;
  26388. /**
  26389. * Sets the current depth function
  26390. * @param depthFunc defines the function to use
  26391. */
  26392. setDepthFunction(depthFunc: number): void;
  26393. /**
  26394. * Sets the current depth function to GREATER
  26395. */
  26396. setDepthFunctionToGreater(): void;
  26397. /**
  26398. * Sets the current depth function to GEQUAL
  26399. */
  26400. setDepthFunctionToGreaterOrEqual(): void;
  26401. /**
  26402. * Sets the current depth function to LESS
  26403. */
  26404. setDepthFunctionToLess(): void;
  26405. /**
  26406. * Sets the current depth function to LEQUAL
  26407. */
  26408. setDepthFunctionToLessOrEqual(): void;
  26409. /**
  26410. * Gets a boolean indicating if stencil buffer is enabled
  26411. * @returns the current stencil buffer state
  26412. */
  26413. getStencilBuffer(): boolean;
  26414. /**
  26415. * Enable or disable the stencil buffer
  26416. * @param enable defines if the stencil buffer must be enabled or disabled
  26417. */
  26418. setStencilBuffer(enable: boolean): void;
  26419. /**
  26420. * Gets the current stencil mask
  26421. * @returns a number defining the new stencil mask to use
  26422. */
  26423. getStencilMask(): number;
  26424. /**
  26425. * Sets the current stencil mask
  26426. * @param mask defines the new stencil mask to use
  26427. */
  26428. setStencilMask(mask: number): void;
  26429. /**
  26430. * Gets the current stencil function
  26431. * @returns a number defining the stencil function to use
  26432. */
  26433. getStencilFunction(): number;
  26434. /**
  26435. * Gets the current stencil reference value
  26436. * @returns a number defining the stencil reference value to use
  26437. */
  26438. getStencilFunctionReference(): number;
  26439. /**
  26440. * Gets the current stencil mask
  26441. * @returns a number defining the stencil mask to use
  26442. */
  26443. getStencilFunctionMask(): number;
  26444. /**
  26445. * Sets the current stencil function
  26446. * @param stencilFunc defines the new stencil function to use
  26447. */
  26448. setStencilFunction(stencilFunc: number): void;
  26449. /**
  26450. * Sets the current stencil reference
  26451. * @param reference defines the new stencil reference to use
  26452. */
  26453. setStencilFunctionReference(reference: number): void;
  26454. /**
  26455. * Sets the current stencil mask
  26456. * @param mask defines the new stencil mask to use
  26457. */
  26458. setStencilFunctionMask(mask: number): void;
  26459. /**
  26460. * Gets the current stencil operation when stencil fails
  26461. * @returns a number defining stencil operation to use when stencil fails
  26462. */
  26463. getStencilOperationFail(): number;
  26464. /**
  26465. * Gets the current stencil operation when depth fails
  26466. * @returns a number defining stencil operation to use when depth fails
  26467. */
  26468. getStencilOperationDepthFail(): number;
  26469. /**
  26470. * Gets the current stencil operation when stencil passes
  26471. * @returns a number defining stencil operation to use when stencil passes
  26472. */
  26473. getStencilOperationPass(): number;
  26474. /**
  26475. * Sets the stencil operation to use when stencil fails
  26476. * @param operation defines the stencil operation to use when stencil fails
  26477. */
  26478. setStencilOperationFail(operation: number): void;
  26479. /**
  26480. * Sets the stencil operation to use when depth fails
  26481. * @param operation defines the stencil operation to use when depth fails
  26482. */
  26483. setStencilOperationDepthFail(operation: number): void;
  26484. /**
  26485. * Sets the stencil operation to use when stencil passes
  26486. * @param operation defines the stencil operation to use when stencil passes
  26487. */
  26488. setStencilOperationPass(operation: number): void;
  26489. /**
  26490. * Sets a boolean indicating if the dithering state is enabled or disabled
  26491. * @param value defines the dithering state
  26492. */
  26493. setDitheringState(value: boolean): void;
  26494. /**
  26495. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  26496. * @param value defines the rasterizer state
  26497. */
  26498. setRasterizerState(value: boolean): void;
  26499. /**
  26500. * stop executing a render loop function and remove it from the execution array
  26501. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  26502. */
  26503. stopRenderLoop(renderFunction?: () => void): void;
  26504. /** @hidden */ renderLoop(): void;
  26505. /**
  26506. * Register and execute a render loop. The engine can have more than one render function
  26507. * @param renderFunction defines the function to continuously execute
  26508. */
  26509. runRenderLoop(renderFunction: () => void): void;
  26510. /**
  26511. * Toggle full screen mode
  26512. * @param requestPointerLock defines if a pointer lock should be requested from the user
  26513. */
  26514. switchFullscreen(requestPointerLock: boolean): void;
  26515. /**
  26516. * Enters full screen mode
  26517. * @param requestPointerLock defines if a pointer lock should be requested from the user
  26518. */
  26519. enterFullscreen(requestPointerLock: boolean): void;
  26520. /**
  26521. * Exits full screen mode
  26522. */
  26523. exitFullscreen(): void;
  26524. /**
  26525. * Clear the current render buffer or the current render target (if any is set up)
  26526. * @param color defines the color to use
  26527. * @param backBuffer defines if the back buffer must be cleared
  26528. * @param depth defines if the depth buffer must be cleared
  26529. * @param stencil defines if the stencil buffer must be cleared
  26530. */
  26531. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  26532. /**
  26533. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  26534. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  26535. * @param y defines the y-coordinate of the corner of the clear rectangle
  26536. * @param width defines the width of the clear rectangle
  26537. * @param height defines the height of the clear rectangle
  26538. * @param clearColor defines the clear color
  26539. */
  26540. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  26541. /**
  26542. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  26543. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  26544. * @param y defines the y-coordinate of the corner of the clear rectangle
  26545. * @param width defines the width of the clear rectangle
  26546. * @param height defines the height of the clear rectangle
  26547. */
  26548. enableScissor(x: number, y: number, width: number, height: number): void;
  26549. /**
  26550. * Disable previously set scissor test rectangle
  26551. */
  26552. disableScissor(): void;
  26553. private _viewportCached;
  26554. /** @hidden */ viewport(x: number, y: number, width: number, height: number): void;
  26555. /**
  26556. * Set the WebGL's viewport
  26557. * @param viewport defines the viewport element to be used
  26558. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  26559. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  26560. */
  26561. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  26562. /**
  26563. * Directly set the WebGL Viewport
  26564. * @param x defines the x coordinate of the viewport (in screen space)
  26565. * @param y defines the y coordinate of the viewport (in screen space)
  26566. * @param width defines the width of the viewport (in screen space)
  26567. * @param height defines the height of the viewport (in screen space)
  26568. * @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
  26569. */
  26570. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  26571. /**
  26572. * Begin a new frame
  26573. */
  26574. beginFrame(): void;
  26575. /**
  26576. * Enf the current frame
  26577. */
  26578. endFrame(): void;
  26579. /**
  26580. * Resize the view according to the canvas' size
  26581. */
  26582. resize(): void;
  26583. /**
  26584. * Force a specific size of the canvas
  26585. * @param width defines the new canvas' width
  26586. * @param height defines the new canvas' height
  26587. */
  26588. setSize(width: number, height: number): void;
  26589. /**
  26590. * Gets a boolean indicating if a webVR device was detected
  26591. * @returns true if a webVR device was detected
  26592. */
  26593. isVRDevicePresent(): boolean;
  26594. /**
  26595. * Gets the current webVR device
  26596. * @returns the current webVR device (or null)
  26597. */
  26598. getVRDevice(): any;
  26599. /**
  26600. * Initializes a webVR display and starts listening to display change events
  26601. * The onVRDisplayChangedObservable will be notified upon these changes
  26602. * @returns The onVRDisplayChangedObservable
  26603. */
  26604. initWebVR(): Observable<IDisplayChangedEventArgs>;
  26605. /**
  26606. * Initializes a webVR display and starts listening to display change events
  26607. * The onVRDisplayChangedObservable will be notified upon these changes
  26608. * @returns A promise containing a VRDisplay and if vr is supported
  26609. */
  26610. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  26611. /**
  26612. * Call this function to switch to webVR mode
  26613. * Will do nothing if webVR is not supported or if there is no webVR device
  26614. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26615. */
  26616. enableVR(): void;
  26617. /**
  26618. * Call this function to leave webVR mode
  26619. * Will do nothing if webVR is not supported or if there is no webVR device
  26620. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26621. */
  26622. disableVR(): void;
  26623. private _onVRFullScreenTriggered;
  26624. private _getVRDisplaysAsync;
  26625. /**
  26626. * Binds the frame buffer to the specified texture.
  26627. * @param texture The texture to render to or null for the default canvas
  26628. * @param faceIndex The face of the texture to render to in case of cube texture
  26629. * @param requiredWidth The width of the target to render to
  26630. * @param requiredHeight The height of the target to render to
  26631. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  26632. * @param depthStencilTexture The depth stencil texture to use to render
  26633. * @param lodLevel defines le lod level to bind to the frame buffer
  26634. */
  26635. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  26636. private bindUnboundFramebuffer;
  26637. /**
  26638. * Unbind the current render target texture from the webGL context
  26639. * @param texture defines the render target texture to unbind
  26640. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  26641. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  26642. */
  26643. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  26644. /**
  26645. * Unbind a list of render target textures from the webGL context
  26646. * This is used only when drawBuffer extension or webGL2 are active
  26647. * @param textures defines the render target textures to unbind
  26648. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  26649. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  26650. */
  26651. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  26652. /**
  26653. * Force the mipmap generation for the given render target texture
  26654. * @param texture defines the render target texture to use
  26655. */
  26656. generateMipMapsForCubemap(texture: InternalTexture): void;
  26657. /**
  26658. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  26659. */
  26660. flushFramebuffer(): void;
  26661. /**
  26662. * Unbind the current render target and bind the default framebuffer
  26663. */
  26664. restoreDefaultFramebuffer(): void;
  26665. /**
  26666. * Create an uniform buffer
  26667. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26668. * @param elements defines the content of the uniform buffer
  26669. * @returns the webGL uniform buffer
  26670. */
  26671. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  26672. /**
  26673. * Create a dynamic uniform buffer
  26674. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26675. * @param elements defines the content of the uniform buffer
  26676. * @returns the webGL uniform buffer
  26677. */
  26678. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  26679. /**
  26680. * Update an existing uniform buffer
  26681. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26682. * @param uniformBuffer defines the target uniform buffer
  26683. * @param elements defines the content to update
  26684. * @param offset defines the offset in the uniform buffer where update should start
  26685. * @param count defines the size of the data to update
  26686. */
  26687. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  26688. private _resetVertexBufferBinding;
  26689. /**
  26690. * Creates a vertex buffer
  26691. * @param data the data for the vertex buffer
  26692. * @returns the new WebGL static buffer
  26693. */
  26694. createVertexBuffer(data: DataArray): WebGLBuffer;
  26695. /**
  26696. * Creates a dynamic vertex buffer
  26697. * @param data the data for the dynamic vertex buffer
  26698. * @returns the new WebGL dynamic buffer
  26699. */
  26700. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  26701. /**
  26702. * Update a dynamic index buffer
  26703. * @param indexBuffer defines the target index buffer
  26704. * @param indices defines the data to update
  26705. * @param offset defines the offset in the target index buffer where update should start
  26706. */
  26707. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  26708. /**
  26709. * Updates a dynamic vertex buffer.
  26710. * @param vertexBuffer the vertex buffer to update
  26711. * @param data the data used to update the vertex buffer
  26712. * @param byteOffset the byte offset of the data
  26713. * @param byteLength the byte length of the data
  26714. */
  26715. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  26716. private _resetIndexBufferBinding;
  26717. /**
  26718. * Creates a new index buffer
  26719. * @param indices defines the content of the index buffer
  26720. * @param updatable defines if the index buffer must be updatable
  26721. * @returns a new webGL buffer
  26722. */
  26723. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  26724. /**
  26725. * Bind a webGL buffer to the webGL context
  26726. * @param buffer defines the buffer to bind
  26727. */
  26728. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  26729. /**
  26730. * Bind an uniform buffer to the current webGL context
  26731. * @param buffer defines the buffer to bind
  26732. */
  26733. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  26734. /**
  26735. * Bind a buffer to the current webGL context at a given location
  26736. * @param buffer defines the buffer to bind
  26737. * @param location defines the index where to bind the buffer
  26738. */
  26739. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  26740. /**
  26741. * Bind a specific block at a given index in a specific shader program
  26742. * @param shaderProgram defines the shader program
  26743. * @param blockName defines the block name
  26744. * @param index defines the index where to bind the block
  26745. */
  26746. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  26747. private bindIndexBuffer;
  26748. private bindBuffer;
  26749. /**
  26750. * update the bound buffer with the given data
  26751. * @param data defines the data to update
  26752. */
  26753. updateArrayBuffer(data: Float32Array): void;
  26754. private _vertexAttribPointer;
  26755. private _bindIndexBufferWithCache;
  26756. private _bindVertexBuffersAttributes;
  26757. /**
  26758. * Records a vertex array object
  26759. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  26760. * @param vertexBuffers defines the list of vertex buffers to store
  26761. * @param indexBuffer defines the index buffer to store
  26762. * @param effect defines the effect to store
  26763. * @returns the new vertex array object
  26764. */
  26765. recordVertexArrayObject(vertexBuffers: {
  26766. [key: string]: VertexBuffer;
  26767. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  26768. /**
  26769. * Bind a specific vertex array object
  26770. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  26771. * @param vertexArrayObject defines the vertex array object to bind
  26772. * @param indexBuffer defines the index buffer to bind
  26773. */
  26774. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  26775. /**
  26776. * Bind webGl buffers directly to the webGL context
  26777. * @param vertexBuffer defines the vertex buffer to bind
  26778. * @param indexBuffer defines the index buffer to bind
  26779. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  26780. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  26781. * @param effect defines the effect associated with the vertex buffer
  26782. */
  26783. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  26784. private _unbindVertexArrayObject;
  26785. /**
  26786. * Bind a list of vertex buffers to the webGL context
  26787. * @param vertexBuffers defines the list of vertex buffers to bind
  26788. * @param indexBuffer defines the index buffer to bind
  26789. * @param effect defines the effect associated with the vertex buffers
  26790. */
  26791. bindBuffers(vertexBuffers: {
  26792. [key: string]: Nullable<VertexBuffer>;
  26793. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  26794. /**
  26795. * Unbind all instance attributes
  26796. */
  26797. unbindInstanceAttributes(): void;
  26798. /**
  26799. * Release and free the memory of a vertex array object
  26800. * @param vao defines the vertex array object to delete
  26801. */
  26802. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  26803. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  26804. /**
  26805. * Creates a webGL buffer to use with instanciation
  26806. * @param capacity defines the size of the buffer
  26807. * @returns the webGL buffer
  26808. */
  26809. createInstancesBuffer(capacity: number): WebGLBuffer;
  26810. /**
  26811. * Delete a webGL buffer used with instanciation
  26812. * @param buffer defines the webGL buffer to delete
  26813. */
  26814. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  26815. /**
  26816. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  26817. * @param instancesBuffer defines the webGL buffer to update and bind
  26818. * @param data defines the data to store in the buffer
  26819. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  26820. */
  26821. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  26822. /**
  26823. * Apply all cached states (depth, culling, stencil and alpha)
  26824. */
  26825. applyStates(): void;
  26826. /**
  26827. * Send a draw order
  26828. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  26829. * @param indexStart defines the starting index
  26830. * @param indexCount defines the number of index to draw
  26831. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26832. */
  26833. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  26834. /**
  26835. * Draw a list of points
  26836. * @param verticesStart defines the index of first vertex to draw
  26837. * @param verticesCount defines the count of vertices to draw
  26838. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26839. */
  26840. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  26841. /**
  26842. * Draw a list of unindexed primitives
  26843. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  26844. * @param verticesStart defines the index of first vertex to draw
  26845. * @param verticesCount defines the count of vertices to draw
  26846. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26847. */
  26848. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  26849. /**
  26850. * Draw a list of indexed primitives
  26851. * @param fillMode defines the primitive to use
  26852. * @param indexStart defines the starting index
  26853. * @param indexCount defines the number of index to draw
  26854. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26855. */
  26856. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  26857. /**
  26858. * Draw a list of unindexed primitives
  26859. * @param fillMode defines the primitive to use
  26860. * @param verticesStart defines the index of first vertex to draw
  26861. * @param verticesCount defines the count of vertices to draw
  26862. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26863. */
  26864. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  26865. private _drawMode;
  26866. /** @hidden */ releaseEffect(effect: Effect): void;
  26867. /** @hidden */ deleteProgram(program: WebGLProgram): void;
  26868. /**
  26869. * Create a new effect (used to store vertex/fragment shaders)
  26870. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  26871. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  26872. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  26873. * @param samplers defines an array of string used to represent textures
  26874. * @param defines defines the string containing the defines to use to compile the shaders
  26875. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  26876. * @param onCompiled defines a function to call when the effect creation is successful
  26877. * @param onError defines a function to call when the effect creation has failed
  26878. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  26879. * @returns the new Effect
  26880. */
  26881. 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;
  26882. private _compileShader;
  26883. private _compileRawShader;
  26884. /**
  26885. * Directly creates a webGL program
  26886. * @param vertexCode defines the vertex shader code to use
  26887. * @param fragmentCode defines the fragment shader code to use
  26888. * @param context defines the webGL context to use (if not set, the current one will be used)
  26889. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  26890. * @returns the new webGL program
  26891. */
  26892. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  26893. /**
  26894. * Creates a webGL program
  26895. * @param vertexCode defines the vertex shader code to use
  26896. * @param fragmentCode defines the fragment shader code to use
  26897. * @param defines defines the string containing the defines to use to compile the shaders
  26898. * @param context defines the webGL context to use (if not set, the current one will be used)
  26899. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  26900. * @returns the new webGL program
  26901. */
  26902. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  26903. private _createShaderProgram;
  26904. private _finalizeProgram;
  26905. /** @hidden */ isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  26906. /** @hidden */ executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  26907. /**
  26908. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  26909. * @param shaderProgram defines the webGL program to use
  26910. * @param uniformsNames defines the list of uniform names
  26911. * @returns an array of webGL uniform locations
  26912. */
  26913. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  26914. /**
  26915. * Gets the lsit of active attributes for a given webGL program
  26916. * @param shaderProgram defines the webGL program to use
  26917. * @param attributesNames defines the list of attribute names to get
  26918. * @returns an array of indices indicating the offset of each attribute
  26919. */
  26920. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  26921. /**
  26922. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  26923. * @param effect defines the effect to activate
  26924. */
  26925. enableEffect(effect: Nullable<Effect>): void;
  26926. /**
  26927. * Set the value of an uniform to an array of int32
  26928. * @param uniform defines the webGL uniform location where to store the value
  26929. * @param array defines the array of int32 to store
  26930. */
  26931. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  26932. /**
  26933. * Set the value of an uniform to an array of int32 (stored as vec2)
  26934. * @param uniform defines the webGL uniform location where to store the value
  26935. * @param array defines the array of int32 to store
  26936. */
  26937. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  26938. /**
  26939. * Set the value of an uniform to an array of int32 (stored as vec3)
  26940. * @param uniform defines the webGL uniform location where to store the value
  26941. * @param array defines the array of int32 to store
  26942. */
  26943. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  26944. /**
  26945. * Set the value of an uniform to an array of int32 (stored as vec4)
  26946. * @param uniform defines the webGL uniform location where to store the value
  26947. * @param array defines the array of int32 to store
  26948. */
  26949. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  26950. /**
  26951. * Set the value of an uniform to an array of float32
  26952. * @param uniform defines the webGL uniform location where to store the value
  26953. * @param array defines the array of float32 to store
  26954. */
  26955. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  26956. /**
  26957. * Set the value of an uniform to an array of float32 (stored as vec2)
  26958. * @param uniform defines the webGL uniform location where to store the value
  26959. * @param array defines the array of float32 to store
  26960. */
  26961. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  26962. /**
  26963. * Set the value of an uniform to an array of float32 (stored as vec3)
  26964. * @param uniform defines the webGL uniform location where to store the value
  26965. * @param array defines the array of float32 to store
  26966. */
  26967. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  26968. /**
  26969. * Set the value of an uniform to an array of float32 (stored as vec4)
  26970. * @param uniform defines the webGL uniform location where to store the value
  26971. * @param array defines the array of float32 to store
  26972. */
  26973. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  26974. /**
  26975. * Set the value of an uniform to an array of number
  26976. * @param uniform defines the webGL uniform location where to store the value
  26977. * @param array defines the array of number to store
  26978. */
  26979. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  26980. /**
  26981. * Set the value of an uniform to an array of number (stored as vec2)
  26982. * @param uniform defines the webGL uniform location where to store the value
  26983. * @param array defines the array of number to store
  26984. */
  26985. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  26986. /**
  26987. * Set the value of an uniform to an array of number (stored as vec3)
  26988. * @param uniform defines the webGL uniform location where to store the value
  26989. * @param array defines the array of number to store
  26990. */
  26991. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  26992. /**
  26993. * Set the value of an uniform to an array of number (stored as vec4)
  26994. * @param uniform defines the webGL uniform location where to store the value
  26995. * @param array defines the array of number to store
  26996. */
  26997. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  26998. /**
  26999. * Set the value of an uniform to an array of float32 (stored as matrices)
  27000. * @param uniform defines the webGL uniform location where to store the value
  27001. * @param matrices defines the array of float32 to store
  27002. */
  27003. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27004. /**
  27005. * Set the value of an uniform to a matrix
  27006. * @param uniform defines the webGL uniform location where to store the value
  27007. * @param matrix defines the matrix to store
  27008. */
  27009. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27010. /**
  27011. * Set the value of an uniform to a matrix (3x3)
  27012. * @param uniform defines the webGL uniform location where to store the value
  27013. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27014. */
  27015. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27016. /**
  27017. * Set the value of an uniform to a matrix (2x2)
  27018. * @param uniform defines the webGL uniform location where to store the value
  27019. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27020. */
  27021. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27022. /**
  27023. * Set the value of an uniform to a number (int)
  27024. * @param uniform defines the webGL uniform location where to store the value
  27025. * @param value defines the int number to store
  27026. */
  27027. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27028. /**
  27029. * Set the value of an uniform to a number (float)
  27030. * @param uniform defines the webGL uniform location where to store the value
  27031. * @param value defines the float number to store
  27032. */
  27033. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27034. /**
  27035. * Set the value of an uniform to a vec2
  27036. * @param uniform defines the webGL uniform location where to store the value
  27037. * @param x defines the 1st component of the value
  27038. * @param y defines the 2nd component of the value
  27039. */
  27040. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27041. /**
  27042. * Set the value of an uniform to a vec3
  27043. * @param uniform defines the webGL uniform location where to store the value
  27044. * @param x defines the 1st component of the value
  27045. * @param y defines the 2nd component of the value
  27046. * @param z defines the 3rd component of the value
  27047. */
  27048. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27049. /**
  27050. * Set the value of an uniform to a boolean
  27051. * @param uniform defines the webGL uniform location where to store the value
  27052. * @param bool defines the boolean to store
  27053. */
  27054. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27055. /**
  27056. * Set the value of an uniform to a vec4
  27057. * @param uniform defines the webGL uniform location where to store the value
  27058. * @param x defines the 1st component of the value
  27059. * @param y defines the 2nd component of the value
  27060. * @param z defines the 3rd component of the value
  27061. * @param w defines the 4th component of the value
  27062. */
  27063. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27064. /**
  27065. * Set the value of an uniform to a Color3
  27066. * @param uniform defines the webGL uniform location where to store the value
  27067. * @param color3 defines the color to store
  27068. */
  27069. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27070. /**
  27071. * Set the value of an uniform to a Color3 and an alpha value
  27072. * @param uniform defines the webGL uniform location where to store the value
  27073. * @param color3 defines the color to store
  27074. * @param alpha defines the alpha component to store
  27075. */
  27076. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  27077. /**
  27078. * Sets a Color4 on a uniform variable
  27079. * @param uniform defines the uniform location
  27080. * @param color4 defines the value to be set
  27081. */
  27082. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  27083. /**
  27084. * Set various states to the webGL context
  27085. * @param culling defines backface culling state
  27086. * @param zOffset defines the value to apply to zOffset (0 by default)
  27087. * @param force defines if states must be applied even if cache is up to date
  27088. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  27089. */
  27090. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  27091. /**
  27092. * Set the z offset to apply to current rendering
  27093. * @param value defines the offset to apply
  27094. */
  27095. setZOffset(value: number): void;
  27096. /**
  27097. * Gets the current value of the zOffset
  27098. * @returns the current zOffset state
  27099. */
  27100. getZOffset(): number;
  27101. /**
  27102. * Enable or disable depth buffering
  27103. * @param enable defines the state to set
  27104. */
  27105. setDepthBuffer(enable: boolean): void;
  27106. /**
  27107. * Gets a boolean indicating if depth writing is enabled
  27108. * @returns the current depth writing state
  27109. */
  27110. getDepthWrite(): boolean;
  27111. /**
  27112. * Enable or disable depth writing
  27113. * @param enable defines the state to set
  27114. */
  27115. setDepthWrite(enable: boolean): void;
  27116. /**
  27117. * Enable or disable color writing
  27118. * @param enable defines the state to set
  27119. */
  27120. setColorWrite(enable: boolean): void;
  27121. /**
  27122. * Gets a boolean indicating if color writing is enabled
  27123. * @returns the current color writing state
  27124. */
  27125. getColorWrite(): boolean;
  27126. /**
  27127. * Sets alpha constants used by some alpha blending modes
  27128. * @param r defines the red component
  27129. * @param g defines the green component
  27130. * @param b defines the blue component
  27131. * @param a defines the alpha component
  27132. */
  27133. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  27134. /**
  27135. * Sets the current alpha mode
  27136. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  27137. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  27138. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27139. */
  27140. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  27141. /**
  27142. * Gets the current alpha mode
  27143. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27144. * @returns the current alpha mode
  27145. */
  27146. getAlphaMode(): number;
  27147. /**
  27148. * Clears the list of texture accessible through engine.
  27149. * This can help preventing texture load conflict due to name collision.
  27150. */
  27151. clearInternalTexturesCache(): void;
  27152. /**
  27153. * Force the entire cache to be cleared
  27154. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  27155. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  27156. */
  27157. wipeCaches(bruteForce?: boolean): void;
  27158. /**
  27159. * Set the compressed texture format to use, based on the formats you have, and the formats
  27160. * supported by the hardware / browser.
  27161. *
  27162. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  27163. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  27164. * to API arguments needed to compressed textures. This puts the burden on the container
  27165. * generator to house the arcane code for determining these for current & future formats.
  27166. *
  27167. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27168. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27169. *
  27170. * Note: The result of this call is not taken into account when a texture is base64.
  27171. *
  27172. * @param formatsAvailable defines the list of those format families you have created
  27173. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  27174. *
  27175. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  27176. * @returns The extension selected.
  27177. */
  27178. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  27179. private _getSamplingParameters;
  27180. private _partialLoadImg;
  27181. private _cascadeLoadImgs;
  27182. /** @hidden */ createTexture(): WebGLTexture;
  27183. /**
  27184. * Usually called from Texture.ts.
  27185. * Passed information to create a WebGLTexture
  27186. * @param urlArg defines a value which contains one of the following:
  27187. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  27188. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  27189. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  27190. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  27191. * @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)
  27192. * @param scene needed for loading to the correct scene
  27193. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  27194. * @param onLoad optional callback to be called upon successful completion
  27195. * @param onError optional callback to be called upon failure
  27196. * @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
  27197. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  27198. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  27199. * @param forcedExtension defines the extension to use to pick the right loader
  27200. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  27201. * @returns a InternalTexture for assignment back into BABYLON.Texture
  27202. */
  27203. 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;
  27204. private _rescaleTexture;
  27205. /**
  27206. * Update a raw texture
  27207. * @param texture defines the texture to update
  27208. * @param data defines the data to store in the texture
  27209. * @param format defines the format of the data
  27210. * @param invertY defines if data must be stored with Y axis inverted
  27211. * @param compression defines the compression used (null by default)
  27212. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27213. */
  27214. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  27215. /**
  27216. * Creates a raw texture
  27217. * @param data defines the data to store in the texture
  27218. * @param width defines the width of the texture
  27219. * @param height defines the height of the texture
  27220. * @param format defines the format of the data
  27221. * @param generateMipMaps defines if the engine should generate the mip levels
  27222. * @param invertY defines if data must be stored with Y axis inverted
  27223. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27224. * @param compression defines the compression used (null by default)
  27225. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27226. * @returns the raw texture inside an InternalTexture
  27227. */
  27228. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  27229. private _unpackFlipYCached;
  27230. /**
  27231. * In case you are sharing the context with other applications, it might
  27232. * be interested to not cache the unpack flip y state to ensure a consistent
  27233. * value would be set.
  27234. */
  27235. enableUnpackFlipYCached: boolean;
  27236. /** @hidden */ unpackFlipY(value: boolean): void;
  27237. /** @hidden */ getUnpackAlignement(): number;
  27238. /**
  27239. * Creates a dynamic texture
  27240. * @param width defines the width of the texture
  27241. * @param height defines the height of the texture
  27242. * @param generateMipMaps defines if the engine should generate the mip levels
  27243. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27244. * @returns the dynamic texture inside an InternalTexture
  27245. */
  27246. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  27247. /**
  27248. * Update the sampling mode of a given texture
  27249. * @param samplingMode defines the required sampling mode
  27250. * @param texture defines the texture to update
  27251. */
  27252. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  27253. /**
  27254. * Update the content of a dynamic texture
  27255. * @param texture defines the texture to update
  27256. * @param canvas defines the canvas containing the source
  27257. * @param invertY defines if data must be stored with Y axis inverted
  27258. * @param premulAlpha defines if alpha is stored as premultiplied
  27259. * @param format defines the format of the data
  27260. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  27261. */
  27262. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  27263. /**
  27264. * Update a video texture
  27265. * @param texture defines the texture to update
  27266. * @param video defines the video element to use
  27267. * @param invertY defines if data must be stored with Y axis inverted
  27268. */
  27269. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  27270. /**
  27271. * Updates a depth texture Comparison Mode and Function.
  27272. * If the comparison Function is equal to 0, the mode will be set to none.
  27273. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  27274. * @param texture The texture to set the comparison function for
  27275. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  27276. */
  27277. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  27278. private _setupDepthStencilTexture;
  27279. /**
  27280. * Creates a depth stencil texture.
  27281. * This is only available in WebGL 2 or with the depth texture extension available.
  27282. * @param size The size of face edge in the texture.
  27283. * @param options The options defining the texture.
  27284. * @returns The texture
  27285. */
  27286. createDepthStencilTexture(size: number | {
  27287. width: number;
  27288. height: number;
  27289. }, options: DepthTextureCreationOptions): InternalTexture;
  27290. /**
  27291. * Creates a depth stencil texture.
  27292. * This is only available in WebGL 2 or with the depth texture extension available.
  27293. * @param size The size of face edge in the texture.
  27294. * @param options The options defining the texture.
  27295. * @returns The texture
  27296. */
  27297. private _createDepthStencilTexture;
  27298. /**
  27299. * Creates a depth stencil cube texture.
  27300. * This is only available in WebGL 2.
  27301. * @param size The size of face edge in the cube texture.
  27302. * @param options The options defining the cube texture.
  27303. * @returns The cube texture
  27304. */
  27305. private _createDepthStencilCubeTexture;
  27306. /**
  27307. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  27308. * @param renderTarget The render target to set the frame buffer for
  27309. */
  27310. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  27311. /**
  27312. * Creates a new render target texture
  27313. * @param size defines the size of the texture
  27314. * @param options defines the options used to create the texture
  27315. * @returns a new render target texture stored in an InternalTexture
  27316. */
  27317. createRenderTargetTexture(size: number | {
  27318. width: number;
  27319. height: number;
  27320. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  27321. /**
  27322. * Create a multi render target texture
  27323. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  27324. * @param size defines the size of the texture
  27325. * @param options defines the creation options
  27326. * @returns the cube texture as an InternalTexture
  27327. */
  27328. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  27329. private _setupFramebufferDepthAttachments;
  27330. /**
  27331. * Updates the sample count of a render target texture
  27332. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27333. * @param texture defines the texture to update
  27334. * @param samples defines the sample count to set
  27335. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27336. */
  27337. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  27338. /**
  27339. * Update the sample count for a given multiple render target texture
  27340. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27341. * @param textures defines the textures to update
  27342. * @param samples defines the sample count to set
  27343. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27344. */
  27345. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  27346. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27347. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27348. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27349. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  27350. /**
  27351. * Creates a new render target cube texture
  27352. * @param size defines the size of the texture
  27353. * @param options defines the options used to create the texture
  27354. * @returns a new render target cube texture stored in an InternalTexture
  27355. */
  27356. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  27357. /**
  27358. * Creates a cube texture
  27359. * @param rootUrl defines the url where the files to load is located
  27360. * @param scene defines the current scene
  27361. * @param files defines the list of files to load (1 per face)
  27362. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  27363. * @param onLoad defines an optional callback raised when the texture is loaded
  27364. * @param onError defines an optional callback raised if there is an issue to load the texture
  27365. * @param format defines the format of the data
  27366. * @param forcedExtension defines the extension to use to pick the right loader
  27367. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  27368. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  27369. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  27370. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  27371. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  27372. * @returns the cube texture as an InternalTexture
  27373. */
  27374. 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;
  27375. /**
  27376. * @hidden
  27377. */ setCubeMapTextureParams(loadMipmap: boolean): void;
  27378. /**
  27379. * Update a raw cube texture
  27380. * @param texture defines the texture to udpdate
  27381. * @param data defines the data to store
  27382. * @param format defines the data format
  27383. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27384. * @param invertY defines if data must be stored with Y axis inverted
  27385. * @param compression defines the compression used (null by default)
  27386. * @param level defines which level of the texture to update
  27387. */
  27388. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  27389. /**
  27390. * Creates a new raw cube texture
  27391. * @param data defines the array of data to use to create each face
  27392. * @param size defines the size of the textures
  27393. * @param format defines the format of the data
  27394. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27395. * @param generateMipMaps defines if the engine should generate the mip levels
  27396. * @param invertY defines if data must be stored with Y axis inverted
  27397. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27398. * @param compression defines the compression used (null by default)
  27399. * @returns the cube texture as an InternalTexture
  27400. */
  27401. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  27402. /**
  27403. * Creates a new raw cube texture from a specified url
  27404. * @param url defines the url where the data is located
  27405. * @param scene defines the current scene
  27406. * @param size defines the size of the textures
  27407. * @param format defines the format of the data
  27408. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27409. * @param noMipmap defines if the engine should avoid generating the mip levels
  27410. * @param callback defines a callback used to extract texture data from loaded data
  27411. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  27412. * @param onLoad defines a callback called when texture is loaded
  27413. * @param onError defines a callback called if there is an error
  27414. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27415. * @param invertY defines if data must be stored with Y axis inverted
  27416. * @returns the cube texture as an InternalTexture
  27417. */
  27418. 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;
  27419. /**
  27420. * Update a raw 3D texture
  27421. * @param texture defines the texture to update
  27422. * @param data defines the data to store
  27423. * @param format defines the data format
  27424. * @param invertY defines if data must be stored with Y axis inverted
  27425. * @param compression defines the used compression (can be null)
  27426. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  27427. */
  27428. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  27429. /**
  27430. * Creates a new raw 3D texture
  27431. * @param data defines the data used to create the texture
  27432. * @param width defines the width of the texture
  27433. * @param height defines the height of the texture
  27434. * @param depth defines the depth of the texture
  27435. * @param format defines the format of the texture
  27436. * @param generateMipMaps defines if the engine must generate mip levels
  27437. * @param invertY defines if data must be stored with Y axis inverted
  27438. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27439. * @param compression defines the compressed used (can be null)
  27440. * @param textureType defines the compressed used (can be null)
  27441. * @returns a new raw 3D texture (stored in an InternalTexture)
  27442. */
  27443. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  27444. private _prepareWebGLTextureContinuation;
  27445. private _prepareWebGLTexture;
  27446. private _convertRGBtoRGBATextureData;
  27447. /** @hidden */ releaseFramebufferObjects(texture: InternalTexture): void;
  27448. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  27449. private setProgram;
  27450. private _boundUniforms;
  27451. /**
  27452. * Binds an effect to the webGL context
  27453. * @param effect defines the effect to bind
  27454. */
  27455. bindSamplers(effect: Effect): void;
  27456. private _moveBoundTextureOnTop;
  27457. private _getCorrectTextureChannel;
  27458. private _linkTrackers;
  27459. private _removeDesignatedSlot;
  27460. private _activateCurrentTexture;
  27461. /** @hidden */ bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  27462. /** @hidden */ bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  27463. /**
  27464. * Sets a texture to the webGL context from a postprocess
  27465. * @param channel defines the channel to use
  27466. * @param postProcess defines the source postprocess
  27467. */
  27468. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  27469. /**
  27470. * Binds the output of the passed in post process to the texture channel specified
  27471. * @param channel The channel the texture should be bound to
  27472. * @param postProcess The post process which's output should be bound
  27473. */
  27474. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  27475. /**
  27476. * Unbind all textures from the webGL context
  27477. */
  27478. unbindAllTextures(): void;
  27479. /**
  27480. * Sets a texture to the according uniform.
  27481. * @param channel The texture channel
  27482. * @param uniform The uniform to set
  27483. * @param texture The texture to apply
  27484. */
  27485. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  27486. /**
  27487. * Sets a depth stencil texture from a render target to the according uniform.
  27488. * @param channel The texture channel
  27489. * @param uniform The uniform to set
  27490. * @param texture The render target texture containing the depth stencil texture to apply
  27491. */
  27492. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  27493. private _bindSamplerUniformToChannel;
  27494. private _getTextureWrapMode;
  27495. private _setTexture;
  27496. /**
  27497. * Sets an array of texture to the webGL context
  27498. * @param channel defines the channel where the texture array must be set
  27499. * @param uniform defines the associated uniform location
  27500. * @param textures defines the array of textures to bind
  27501. */
  27502. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  27503. /** @hidden */ setAnisotropicLevel(target: number, texture: BaseTexture): void;
  27504. private _setTextureParameterFloat;
  27505. private _setTextureParameterInteger;
  27506. /**
  27507. * Reads pixels from the current frame buffer. Please note that this function can be slow
  27508. * @param x defines the x coordinate of the rectangle where pixels must be read
  27509. * @param y defines the y coordinate of the rectangle where pixels must be read
  27510. * @param width defines the width of the rectangle where pixels must be read
  27511. * @param height defines the height of the rectangle where pixels must be read
  27512. * @returns a Uint8Array containing RGBA colors
  27513. */
  27514. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  27515. /**
  27516. * Add an externaly attached data from its key.
  27517. * This method call will fail and return false, if such key already exists.
  27518. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  27519. * @param key the unique key that identifies the data
  27520. * @param data the data object to associate to the key for this Engine instance
  27521. * @return true if no such key were already present and the data was added successfully, false otherwise
  27522. */
  27523. addExternalData<T>(key: string, data: T): boolean;
  27524. /**
  27525. * Get an externaly attached data from its key
  27526. * @param key the unique key that identifies the data
  27527. * @return the associated data, if present (can be null), or undefined if not present
  27528. */
  27529. getExternalData<T>(key: string): T;
  27530. /**
  27531. * Get an externaly attached data from its key, create it using a factory if it's not already present
  27532. * @param key the unique key that identifies the data
  27533. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  27534. * @return the associated data, can be null if the factory returned null.
  27535. */
  27536. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  27537. /**
  27538. * Remove an externaly attached data from the Engine instance
  27539. * @param key the unique key that identifies the data
  27540. * @return true if the data was successfully removed, false if it doesn't exist
  27541. */
  27542. removeExternalData(key: string): boolean;
  27543. /**
  27544. * Unbind all vertex attributes from the webGL context
  27545. */
  27546. unbindAllAttributes(): void;
  27547. /**
  27548. * 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
  27549. */
  27550. releaseEffects(): void;
  27551. /**
  27552. * Dispose and release all associated resources
  27553. */
  27554. dispose(): void;
  27555. /**
  27556. * Display the loading screen
  27557. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27558. */
  27559. displayLoadingUI(): void;
  27560. /**
  27561. * Hide the loading screen
  27562. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27563. */
  27564. hideLoadingUI(): void;
  27565. /**
  27566. * Gets the current loading screen object
  27567. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27568. */
  27569. /**
  27570. * Sets the current loading screen object
  27571. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27572. */
  27573. loadingScreen: ILoadingScreen;
  27574. /**
  27575. * Sets the current loading screen text
  27576. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27577. */
  27578. loadingUIText: string;
  27579. /**
  27580. * Sets the current loading screen background color
  27581. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27582. */
  27583. loadingUIBackgroundColor: string;
  27584. /**
  27585. * Attach a new callback raised when context lost event is fired
  27586. * @param callback defines the callback to call
  27587. */
  27588. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  27589. /**
  27590. * Attach a new callback raised when context restored event is fired
  27591. * @param callback defines the callback to call
  27592. */
  27593. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  27594. /**
  27595. * Gets the source code of the vertex shader associated with a specific webGL program
  27596. * @param program defines the program to use
  27597. * @returns a string containing the source code of the vertex shader associated with the program
  27598. */
  27599. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  27600. /**
  27601. * Gets the source code of the fragment shader associated with a specific webGL program
  27602. * @param program defines the program to use
  27603. * @returns a string containing the source code of the fragment shader associated with the program
  27604. */
  27605. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  27606. /**
  27607. * Get the current error code of the webGL context
  27608. * @returns the error code
  27609. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  27610. */
  27611. getError(): number;
  27612. /**
  27613. * Gets the current framerate
  27614. * @returns a number representing the framerate
  27615. */
  27616. getFps(): number;
  27617. /**
  27618. * Gets the time spent between current and previous frame
  27619. * @returns a number representing the delta time in ms
  27620. */
  27621. getDeltaTime(): number;
  27622. private _measureFps;
  27623. /** @hidden */ readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  27624. private _canRenderToFloatFramebuffer;
  27625. private _canRenderToHalfFloatFramebuffer;
  27626. private _canRenderToFramebuffer;
  27627. /** @hidden */ getWebGLTextureType(type: number): number;
  27628. private _getInternalFormat;
  27629. /** @hidden */ getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  27630. /** @hidden */ getRGBAMultiSampleBufferFormat(type: number): number;
  27631. /** @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;
  27632. /** @hidden */ loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  27633. private _partialLoadFile;
  27634. private _cascadeLoadFiles;
  27635. /**
  27636. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  27637. * @returns true if the engine can be created
  27638. * @ignorenaming
  27639. */
  27640. static isSupported(): boolean;
  27641. }
  27642. }
  27643. declare module BABYLON {
  27644. /**
  27645. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  27646. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  27647. */
  27648. export class EffectFallbacks {
  27649. private _defines;
  27650. private _currentRank;
  27651. private _maxRank;
  27652. private _mesh;
  27653. /**
  27654. * Removes the fallback from the bound mesh.
  27655. */
  27656. unBindMesh(): void;
  27657. /**
  27658. * Adds a fallback on the specified property.
  27659. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27660. * @param define The name of the define in the shader
  27661. */
  27662. addFallback(rank: number, define: string): void;
  27663. /**
  27664. * Sets the mesh to use CPU skinning when needing to fallback.
  27665. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27666. * @param mesh The mesh to use the fallbacks.
  27667. */
  27668. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  27669. /**
  27670. * Checks to see if more fallbacks are still availible.
  27671. */
  27672. readonly isMoreFallbacks: boolean;
  27673. /**
  27674. * Removes the defines that shoould be removed when falling back.
  27675. * @param currentDefines defines the current define statements for the shader.
  27676. * @param effect defines the current effect we try to compile
  27677. * @returns The resulting defines with defines of the current rank removed.
  27678. */
  27679. reduce(currentDefines: string, effect: Effect): string;
  27680. }
  27681. /**
  27682. * Options to be used when creating an effect.
  27683. */
  27684. export class EffectCreationOptions {
  27685. /**
  27686. * Atrributes that will be used in the shader.
  27687. */
  27688. attributes: string[];
  27689. /**
  27690. * Uniform varible names that will be set in the shader.
  27691. */
  27692. uniformsNames: string[];
  27693. /**
  27694. * Uniform buffer varible names that will be set in the shader.
  27695. */
  27696. uniformBuffersNames: string[];
  27697. /**
  27698. * Sampler texture variable names that will be set in the shader.
  27699. */
  27700. samplers: string[];
  27701. /**
  27702. * Define statements that will be set in the shader.
  27703. */
  27704. defines: any;
  27705. /**
  27706. * Possible fallbacks for this effect to improve performance when needed.
  27707. */
  27708. fallbacks: Nullable<EffectFallbacks>;
  27709. /**
  27710. * Callback that will be called when the shader is compiled.
  27711. */
  27712. onCompiled: Nullable<(effect: Effect) => void>;
  27713. /**
  27714. * Callback that will be called if an error occurs during shader compilation.
  27715. */
  27716. onError: Nullable<(effect: Effect, errors: string) => void>;
  27717. /**
  27718. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27719. */
  27720. indexParameters: any;
  27721. /**
  27722. * Max number of lights that can be used in the shader.
  27723. */
  27724. maxSimultaneousLights: number;
  27725. /**
  27726. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27727. */
  27728. transformFeedbackVaryings: Nullable<string[]>;
  27729. }
  27730. /**
  27731. * Effect containing vertex and fragment shader that can be executed on an object.
  27732. */
  27733. export class Effect {
  27734. /**
  27735. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27736. */
  27737. static ShadersRepository: string;
  27738. /**
  27739. * Name of the effect.
  27740. */
  27741. name: any;
  27742. /**
  27743. * String container all the define statements that should be set on the shader.
  27744. */
  27745. defines: string;
  27746. /**
  27747. * Callback that will be called when the shader is compiled.
  27748. */
  27749. onCompiled: Nullable<(effect: Effect) => void>;
  27750. /**
  27751. * Callback that will be called if an error occurs during shader compilation.
  27752. */
  27753. onError: Nullable<(effect: Effect, errors: string) => void>;
  27754. /**
  27755. * Callback that will be called when effect is bound.
  27756. */
  27757. onBind: Nullable<(effect: Effect) => void>;
  27758. /**
  27759. * Unique ID of the effect.
  27760. */
  27761. uniqueId: number;
  27762. /**
  27763. * Observable that will be called when the shader is compiled.
  27764. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27765. */
  27766. onCompileObservable: Observable<Effect>;
  27767. /**
  27768. * Observable that will be called if an error occurs during shader compilation.
  27769. */
  27770. onErrorObservable: Observable<Effect>;
  27771. /** @hidden */ onBindObservable: Nullable<Observable<Effect>>;
  27772. /**
  27773. * Observable that will be called when effect is bound.
  27774. */
  27775. readonly onBindObservable: Observable<Effect>;
  27776. /** @hidden */ bonesComputationForcedToCPU: boolean;
  27777. private static _uniqueIdSeed;
  27778. private _engine;
  27779. private _uniformBuffersNames;
  27780. private _uniformsNames;
  27781. private _samplers;
  27782. private _isReady;
  27783. private _compilationError;
  27784. private _attributesNames;
  27785. private _attributes;
  27786. private _uniforms;
  27787. /**
  27788. * Key for the effect.
  27789. * @hidden
  27790. */ key: string;
  27791. private _indexParameters;
  27792. private _fallbacks;
  27793. private _vertexSourceCode;
  27794. private _fragmentSourceCode;
  27795. private _vertexSourceCodeOverride;
  27796. private _fragmentSourceCodeOverride;
  27797. private _transformFeedbackVaryings;
  27798. /**
  27799. * Compiled shader to webGL program.
  27800. * @hidden
  27801. */ program: WebGLProgram;
  27802. private _valueCache;
  27803. private static _baseCache;
  27804. /**
  27805. * Instantiates an effect.
  27806. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27807. * @param baseName Name of the effect.
  27808. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27809. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27810. * @param samplers List of sampler variables that will be passed to the shader.
  27811. * @param engine Engine to be used to render the effect
  27812. * @param defines Define statements to be added to the shader.
  27813. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27814. * @param onCompiled Callback that will be called when the shader is compiled.
  27815. * @param onError Callback that will be called if an error occurs during shader compilation.
  27816. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27817. */
  27818. 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);
  27819. /**
  27820. * Unique key for this effect
  27821. */
  27822. readonly key: string;
  27823. /**
  27824. * If the effect has been compiled and prepared.
  27825. * @returns if the effect is compiled and prepared.
  27826. */
  27827. isReady(): boolean;
  27828. /**
  27829. * The engine the effect was initialized with.
  27830. * @returns the engine.
  27831. */
  27832. getEngine(): Engine;
  27833. /**
  27834. * The compiled webGL program for the effect
  27835. * @returns the webGL program.
  27836. */
  27837. getProgram(): WebGLProgram;
  27838. /**
  27839. * The set of names of attribute variables for the shader.
  27840. * @returns An array of attribute names.
  27841. */
  27842. getAttributesNames(): string[];
  27843. /**
  27844. * Returns the attribute at the given index.
  27845. * @param index The index of the attribute.
  27846. * @returns The location of the attribute.
  27847. */
  27848. getAttributeLocation(index: number): number;
  27849. /**
  27850. * Returns the attribute based on the name of the variable.
  27851. * @param name of the attribute to look up.
  27852. * @returns the attribute location.
  27853. */
  27854. getAttributeLocationByName(name: string): number;
  27855. /**
  27856. * The number of attributes.
  27857. * @returns the numnber of attributes.
  27858. */
  27859. getAttributesCount(): number;
  27860. /**
  27861. * Gets the index of a uniform variable.
  27862. * @param uniformName of the uniform to look up.
  27863. * @returns the index.
  27864. */
  27865. getUniformIndex(uniformName: string): number;
  27866. /**
  27867. * Returns the attribute based on the name of the variable.
  27868. * @param uniformName of the uniform to look up.
  27869. * @returns the location of the uniform.
  27870. */
  27871. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27872. /**
  27873. * Returns an array of sampler variable names
  27874. * @returns The array of sampler variable neames.
  27875. */
  27876. getSamplers(): string[];
  27877. /**
  27878. * The error from the last compilation.
  27879. * @returns the error string.
  27880. */
  27881. getCompilationError(): string;
  27882. /**
  27883. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27884. * @param func The callback to be used.
  27885. */
  27886. executeWhenCompiled(func: (effect: Effect) => void): void;
  27887. private _checkIsReady;
  27888. /** @hidden */ loadVertexShader(vertex: any, callback: (data: any) => void): void;
  27889. /** @hidden */ loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  27890. /** @hidden */ dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  27891. private _processShaderConversion;
  27892. private _processIncludes;
  27893. private _processPrecision;
  27894. /**
  27895. * Recompiles the webGL program
  27896. * @param vertexSourceCode The source code for the vertex shader.
  27897. * @param fragmentSourceCode The source code for the fragment shader.
  27898. * @param onCompiled Callback called when completed.
  27899. * @param onError Callback called on error.
  27900. * @hidden
  27901. */ rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  27902. /**
  27903. * Gets the uniform locations of the the specified variable names
  27904. * @param names THe names of the variables to lookup.
  27905. * @returns Array of locations in the same order as variable names.
  27906. */
  27907. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  27908. /**
  27909. * Prepares the effect
  27910. * @hidden
  27911. */ prepareEffect(): void;
  27912. /**
  27913. * Checks if the effect is supported. (Must be called after compilation)
  27914. */
  27915. readonly isSupported: boolean;
  27916. /**
  27917. * Binds a texture to the engine to be used as output of the shader.
  27918. * @param channel Name of the output variable.
  27919. * @param texture Texture to bind.
  27920. * @hidden
  27921. */ bindTexture(channel: string, texture: InternalTexture): void;
  27922. /**
  27923. * Sets a texture on the engine to be used in the shader.
  27924. * @param channel Name of the sampler variable.
  27925. * @param texture Texture to set.
  27926. */
  27927. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  27928. /**
  27929. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  27930. * @param channel Name of the sampler variable.
  27931. * @param texture Texture to set.
  27932. */
  27933. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  27934. /**
  27935. * Sets an array of textures on the engine to be used in the shader.
  27936. * @param channel Name of the variable.
  27937. * @param textures Textures to set.
  27938. */
  27939. setTextureArray(channel: string, textures: BaseTexture[]): void;
  27940. /**
  27941. * 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)
  27942. * @param channel Name of the sampler variable.
  27943. * @param postProcess Post process to get the input texture from.
  27944. */
  27945. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  27946. /**
  27947. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  27948. * 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)
  27949. * @param channel Name of the sampler variable.
  27950. * @param postProcess Post process to get the output texture from.
  27951. */
  27952. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  27953. /** @hidden */ cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  27954. /** @hidden */ cacheFloat2(uniformName: string, x: number, y: number): boolean;
  27955. /** @hidden */ cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  27956. /** @hidden */ cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  27957. /**
  27958. * Binds a buffer to a uniform.
  27959. * @param buffer Buffer to bind.
  27960. * @param name Name of the uniform variable to bind to.
  27961. */
  27962. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  27963. /**
  27964. * Binds block to a uniform.
  27965. * @param blockName Name of the block to bind.
  27966. * @param index Index to bind.
  27967. */
  27968. bindUniformBlock(blockName: string, index: number): void;
  27969. /**
  27970. * Sets an interger value on a uniform variable.
  27971. * @param uniformName Name of the variable.
  27972. * @param value Value to be set.
  27973. * @returns this effect.
  27974. */
  27975. setInt(uniformName: string, value: number): Effect;
  27976. /**
  27977. * Sets an int array on a uniform variable.
  27978. * @param uniformName Name of the variable.
  27979. * @param array array to be set.
  27980. * @returns this effect.
  27981. */
  27982. setIntArray(uniformName: string, array: Int32Array): Effect;
  27983. /**
  27984. * 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)
  27985. * @param uniformName Name of the variable.
  27986. * @param array array to be set.
  27987. * @returns this effect.
  27988. */
  27989. setIntArray2(uniformName: string, array: Int32Array): Effect;
  27990. /**
  27991. * 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)
  27992. * @param uniformName Name of the variable.
  27993. * @param array array to be set.
  27994. * @returns this effect.
  27995. */
  27996. setIntArray3(uniformName: string, array: Int32Array): Effect;
  27997. /**
  27998. * 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)
  27999. * @param uniformName Name of the variable.
  28000. * @param array array to be set.
  28001. * @returns this effect.
  28002. */
  28003. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28004. /**
  28005. * Sets an float array on a uniform variable.
  28006. * @param uniformName Name of the variable.
  28007. * @param array array to be set.
  28008. * @returns this effect.
  28009. */
  28010. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28011. /**
  28012. * 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)
  28013. * @param uniformName Name of the variable.
  28014. * @param array array to be set.
  28015. * @returns this effect.
  28016. */
  28017. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28018. /**
  28019. * 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)
  28020. * @param uniformName Name of the variable.
  28021. * @param array array to be set.
  28022. * @returns this effect.
  28023. */
  28024. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28025. /**
  28026. * 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)
  28027. * @param uniformName Name of the variable.
  28028. * @param array array to be set.
  28029. * @returns this effect.
  28030. */
  28031. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28032. /**
  28033. * Sets an array on a uniform variable.
  28034. * @param uniformName Name of the variable.
  28035. * @param array array to be set.
  28036. * @returns this effect.
  28037. */
  28038. setArray(uniformName: string, array: number[]): Effect;
  28039. /**
  28040. * 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)
  28041. * @param uniformName Name of the variable.
  28042. * @param array array to be set.
  28043. * @returns this effect.
  28044. */
  28045. setArray2(uniformName: string, array: number[]): Effect;
  28046. /**
  28047. * 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)
  28048. * @param uniformName Name of the variable.
  28049. * @param array array to be set.
  28050. * @returns this effect.
  28051. */
  28052. setArray3(uniformName: string, array: number[]): Effect;
  28053. /**
  28054. * 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)
  28055. * @param uniformName Name of the variable.
  28056. * @param array array to be set.
  28057. * @returns this effect.
  28058. */
  28059. setArray4(uniformName: string, array: number[]): Effect;
  28060. /**
  28061. * Sets matrices on a uniform variable.
  28062. * @param uniformName Name of the variable.
  28063. * @param matrices matrices to be set.
  28064. * @returns this effect.
  28065. */
  28066. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28067. /**
  28068. * Sets matrix on a uniform variable.
  28069. * @param uniformName Name of the variable.
  28070. * @param matrix matrix to be set.
  28071. * @returns this effect.
  28072. */
  28073. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28074. /**
  28075. * 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)
  28076. * @param uniformName Name of the variable.
  28077. * @param matrix matrix to be set.
  28078. * @returns this effect.
  28079. */
  28080. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28081. /**
  28082. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28083. * @param uniformName Name of the variable.
  28084. * @param matrix matrix to be set.
  28085. * @returns this effect.
  28086. */
  28087. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28088. /**
  28089. * Sets a float on a uniform variable.
  28090. * @param uniformName Name of the variable.
  28091. * @param value value to be set.
  28092. * @returns this effect.
  28093. */
  28094. setFloat(uniformName: string, value: number): Effect;
  28095. /**
  28096. * Sets a boolean on a uniform variable.
  28097. * @param uniformName Name of the variable.
  28098. * @param bool value to be set.
  28099. * @returns this effect.
  28100. */
  28101. setBool(uniformName: string, bool: boolean): Effect;
  28102. /**
  28103. * Sets a Vector2 on a uniform variable.
  28104. * @param uniformName Name of the variable.
  28105. * @param vector2 vector2 to be set.
  28106. * @returns this effect.
  28107. */
  28108. setVector2(uniformName: string, vector2: Vector2): Effect;
  28109. /**
  28110. * Sets a float2 on a uniform variable.
  28111. * @param uniformName Name of the variable.
  28112. * @param x First float in float2.
  28113. * @param y Second float in float2.
  28114. * @returns this effect.
  28115. */
  28116. setFloat2(uniformName: string, x: number, y: number): Effect;
  28117. /**
  28118. * Sets a Vector3 on a uniform variable.
  28119. * @param uniformName Name of the variable.
  28120. * @param vector3 Value to be set.
  28121. * @returns this effect.
  28122. */
  28123. setVector3(uniformName: string, vector3: Vector3): Effect;
  28124. /**
  28125. * Sets a float3 on a uniform variable.
  28126. * @param uniformName Name of the variable.
  28127. * @param x First float in float3.
  28128. * @param y Second float in float3.
  28129. * @param z Third float in float3.
  28130. * @returns this effect.
  28131. */
  28132. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28133. /**
  28134. * Sets a Vector4 on a uniform variable.
  28135. * @param uniformName Name of the variable.
  28136. * @param vector4 Value to be set.
  28137. * @returns this effect.
  28138. */
  28139. setVector4(uniformName: string, vector4: Vector4): Effect;
  28140. /**
  28141. * Sets a float4 on a uniform variable.
  28142. * @param uniformName Name of the variable.
  28143. * @param x First float in float4.
  28144. * @param y Second float in float4.
  28145. * @param z Third float in float4.
  28146. * @param w Fourth float in float4.
  28147. * @returns this effect.
  28148. */
  28149. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28150. /**
  28151. * Sets a Color3 on a uniform variable.
  28152. * @param uniformName Name of the variable.
  28153. * @param color3 Value to be set.
  28154. * @returns this effect.
  28155. */
  28156. setColor3(uniformName: string, color3: Color3): Effect;
  28157. /**
  28158. * Sets a Color4 on a uniform variable.
  28159. * @param uniformName Name of the variable.
  28160. * @param color3 Value to be set.
  28161. * @param alpha Alpha value to be set.
  28162. * @returns this effect.
  28163. */
  28164. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28165. /**
  28166. * Sets a Color4 on a uniform variable
  28167. * @param uniformName defines the name of the variable
  28168. * @param color4 defines the value to be set
  28169. * @returns this effect.
  28170. */
  28171. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28172. /**
  28173. * This function will add a new shader to the shader store
  28174. * @param name the name of the shader
  28175. * @param pixelShader optional pixel shader content
  28176. * @param vertexShader optional vertex shader content
  28177. */
  28178. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28179. /**
  28180. * Store of each shader (The can be looked up using effect.key)
  28181. */
  28182. static ShadersStore: {
  28183. [key: string]: string;
  28184. };
  28185. /**
  28186. * Store of each included file for a shader (The can be looked up using effect.key)
  28187. */
  28188. static IncludesShadersStore: {
  28189. [key: string]: string;
  28190. };
  28191. /**
  28192. * Resets the cache of effects.
  28193. */
  28194. static ResetCache(): void;
  28195. }
  28196. }
  28197. declare module BABYLON {
  28198. /**
  28199. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28200. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28201. * 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;
  28202. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28203. */
  28204. export class ColorCurves {
  28205. private _dirty;
  28206. private _tempColor;
  28207. private _globalCurve;
  28208. private _highlightsCurve;
  28209. private _midtonesCurve;
  28210. private _shadowsCurve;
  28211. private _positiveCurve;
  28212. private _negativeCurve;
  28213. private _globalHue;
  28214. private _globalDensity;
  28215. private _globalSaturation;
  28216. private _globalExposure;
  28217. /**
  28218. * Gets the global Hue value.
  28219. * 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).
  28220. */
  28221. /**
  28222. * Sets the global Hue value.
  28223. * 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).
  28224. */
  28225. globalHue: number;
  28226. /**
  28227. * Gets the global Density value.
  28228. * 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.
  28229. * Values less than zero provide a filter of opposite hue.
  28230. */
  28231. /**
  28232. * Sets the global 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. globalDensity: number;
  28237. /**
  28238. * Gets the global Saturation value.
  28239. * 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.
  28240. */
  28241. /**
  28242. * Sets the global Saturation value.
  28243. * 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.
  28244. */
  28245. globalSaturation: number;
  28246. /**
  28247. * Gets the global Exposure 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 exposure and negative values decrease exposure.
  28249. */
  28250. /**
  28251. * Sets the global Exposure value.
  28252. * 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.
  28253. */
  28254. globalExposure: number;
  28255. private _highlightsHue;
  28256. private _highlightsDensity;
  28257. private _highlightsSaturation;
  28258. private _highlightsExposure;
  28259. /**
  28260. * Gets the highlights Hue value.
  28261. * 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).
  28262. */
  28263. /**
  28264. * Sets the highlights Hue value.
  28265. * 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).
  28266. */
  28267. highlightsHue: number;
  28268. /**
  28269. * Gets the highlights Density value.
  28270. * 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.
  28271. * Values less than zero provide a filter of opposite hue.
  28272. */
  28273. /**
  28274. * Sets the highlights 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. highlightsDensity: number;
  28279. /**
  28280. * Gets the highlights Saturation value.
  28281. * 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.
  28282. */
  28283. /**
  28284. * Sets the highlights Saturation value.
  28285. * 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.
  28286. */
  28287. highlightsSaturation: number;
  28288. /**
  28289. * Gets the highlights Exposure 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 exposure and negative values decrease exposure.
  28291. */
  28292. /**
  28293. * Sets the highlights Exposure value.
  28294. * 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.
  28295. */
  28296. highlightsExposure: number;
  28297. private _midtonesHue;
  28298. private _midtonesDensity;
  28299. private _midtonesSaturation;
  28300. private _midtonesExposure;
  28301. /**
  28302. * Gets the midtones Hue value.
  28303. * 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).
  28304. */
  28305. /**
  28306. * Sets the midtones Hue value.
  28307. * 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).
  28308. */
  28309. midtonesHue: number;
  28310. /**
  28311. * Gets the midtones Density value.
  28312. * 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.
  28313. * Values less than zero provide a filter of opposite hue.
  28314. */
  28315. /**
  28316. * Sets the midtones Density value.
  28317. * 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.
  28318. * Values less than zero provide a filter of opposite hue.
  28319. */
  28320. midtonesDensity: number;
  28321. /**
  28322. * Gets the midtones Saturation value.
  28323. * 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.
  28324. */
  28325. /**
  28326. * Sets the midtones Saturation value.
  28327. * 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.
  28328. */
  28329. midtonesSaturation: number;
  28330. /**
  28331. * Gets the midtones Exposure value.
  28332. * 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.
  28333. */
  28334. /**
  28335. * Sets the midtones Exposure value.
  28336. * 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.
  28337. */
  28338. midtonesExposure: number;
  28339. private _shadowsHue;
  28340. private _shadowsDensity;
  28341. private _shadowsSaturation;
  28342. private _shadowsExposure;
  28343. /**
  28344. * Gets the shadows Hue value.
  28345. * 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).
  28346. */
  28347. /**
  28348. * Sets the shadows Hue value.
  28349. * 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).
  28350. */
  28351. shadowsHue: number;
  28352. /**
  28353. * Gets the shadows Density value.
  28354. * 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.
  28355. * Values less than zero provide a filter of opposite hue.
  28356. */
  28357. /**
  28358. * Sets the shadows Density value.
  28359. * 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.
  28360. * Values less than zero provide a filter of opposite hue.
  28361. */
  28362. shadowsDensity: number;
  28363. /**
  28364. * Gets the shadows Saturation value.
  28365. * 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.
  28366. */
  28367. /**
  28368. * Sets the shadows Saturation value.
  28369. * 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.
  28370. */
  28371. shadowsSaturation: number;
  28372. /**
  28373. * Gets the shadows Exposure value.
  28374. * 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.
  28375. */
  28376. /**
  28377. * Sets the shadows Exposure value.
  28378. * 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.
  28379. */
  28380. shadowsExposure: number;
  28381. /**
  28382. * Returns the class name
  28383. * @returns The class name
  28384. */
  28385. getClassName(): string;
  28386. /**
  28387. * Binds the color curves to the shader.
  28388. * @param colorCurves The color curve to bind
  28389. * @param effect The effect to bind to
  28390. * @param positiveUniform The positive uniform shader parameter
  28391. * @param neutralUniform The neutral uniform shader parameter
  28392. * @param negativeUniform The negative uniform shader parameter
  28393. */
  28394. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  28395. /**
  28396. * Prepare the list of uniforms associated with the ColorCurves effects.
  28397. * @param uniformsList The list of uniforms used in the effect
  28398. */
  28399. static PrepareUniforms(uniformsList: string[]): void;
  28400. /**
  28401. * Returns color grading data based on a hue, density, saturation and exposure value.
  28402. * @param filterHue The hue of the color filter.
  28403. * @param filterDensity The density of the color filter.
  28404. * @param saturation The saturation.
  28405. * @param exposure The exposure.
  28406. * @param result The result data container.
  28407. */
  28408. private getColorGradingDataToRef;
  28409. /**
  28410. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  28411. * @param value The input slider value in range [-100,100].
  28412. * @returns Adjusted value.
  28413. */
  28414. private static applyColorGradingSliderNonlinear;
  28415. /**
  28416. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  28417. * @param hue The hue (H) input.
  28418. * @param saturation The saturation (S) input.
  28419. * @param brightness The brightness (B) input.
  28420. * @result An RGBA color represented as Vector4.
  28421. */
  28422. private static fromHSBToRef;
  28423. /**
  28424. * Returns a value clamped between min and max
  28425. * @param value The value to clamp
  28426. * @param min The minimum of value
  28427. * @param max The maximum of value
  28428. * @returns The clamped value.
  28429. */
  28430. private static clamp;
  28431. /**
  28432. * Clones the current color curve instance.
  28433. * @return The cloned curves
  28434. */
  28435. clone(): ColorCurves;
  28436. /**
  28437. * Serializes the current color curve instance to a json representation.
  28438. * @return a JSON representation
  28439. */
  28440. serialize(): any;
  28441. /**
  28442. * Parses the color curve from a json representation.
  28443. * @param source the JSON source to parse
  28444. * @return The parsed curves
  28445. */
  28446. static Parse(source: any): ColorCurves;
  28447. }
  28448. }
  28449. declare module BABYLON {
  28450. /**
  28451. * Interface to follow in your material defines to integrate easily the
  28452. * Image proccessing functions.
  28453. * @hidden
  28454. */
  28455. export interface IImageProcessingConfigurationDefines {
  28456. IMAGEPROCESSING: boolean;
  28457. VIGNETTE: boolean;
  28458. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28459. VIGNETTEBLENDMODEOPAQUE: boolean;
  28460. TONEMAPPING: boolean;
  28461. TONEMAPPING_ACES: boolean;
  28462. CONTRAST: boolean;
  28463. EXPOSURE: boolean;
  28464. COLORCURVES: boolean;
  28465. COLORGRADING: boolean;
  28466. COLORGRADING3D: boolean;
  28467. SAMPLER3DGREENDEPTH: boolean;
  28468. SAMPLER3DBGRMAP: boolean;
  28469. IMAGEPROCESSINGPOSTPROCESS: boolean;
  28470. }
  28471. /**
  28472. * @hidden
  28473. */
  28474. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  28475. IMAGEPROCESSING: boolean;
  28476. VIGNETTE: boolean;
  28477. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28478. VIGNETTEBLENDMODEOPAQUE: boolean;
  28479. TONEMAPPING: boolean;
  28480. TONEMAPPING_ACES: boolean;
  28481. CONTRAST: boolean;
  28482. COLORCURVES: boolean;
  28483. COLORGRADING: boolean;
  28484. COLORGRADING3D: boolean;
  28485. SAMPLER3DGREENDEPTH: boolean;
  28486. SAMPLER3DBGRMAP: boolean;
  28487. IMAGEPROCESSINGPOSTPROCESS: boolean;
  28488. EXPOSURE: boolean;
  28489. constructor();
  28490. }
  28491. /**
  28492. * This groups together the common properties used for image processing either in direct forward pass
  28493. * or through post processing effect depending on the use of the image processing pipeline in your scene
  28494. * or not.
  28495. */
  28496. export class ImageProcessingConfiguration {
  28497. /**
  28498. * Default tone mapping applied in BabylonJS.
  28499. */
  28500. static readonly TONEMAPPING_STANDARD: number;
  28501. /**
  28502. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  28503. * to other engines rendering to increase portability.
  28504. */
  28505. static readonly TONEMAPPING_ACES: number;
  28506. /**
  28507. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  28508. */
  28509. colorCurves: Nullable<ColorCurves>;
  28510. private _colorCurvesEnabled;
  28511. /**
  28512. * Gets wether the color curves effect is enabled.
  28513. */
  28514. /**
  28515. * Sets wether the color curves effect is enabled.
  28516. */
  28517. colorCurvesEnabled: boolean;
  28518. private _colorGradingTexture;
  28519. /**
  28520. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  28521. */
  28522. /**
  28523. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  28524. */
  28525. colorGradingTexture: Nullable<BaseTexture>;
  28526. private _colorGradingEnabled;
  28527. /**
  28528. * Gets wether the color grading effect is enabled.
  28529. */
  28530. /**
  28531. * Sets wether the color grading effect is enabled.
  28532. */
  28533. colorGradingEnabled: boolean;
  28534. private _colorGradingWithGreenDepth;
  28535. /**
  28536. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  28537. */
  28538. /**
  28539. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  28540. */
  28541. colorGradingWithGreenDepth: boolean;
  28542. private _colorGradingBGR;
  28543. /**
  28544. * Gets wether the color grading texture contains BGR values.
  28545. */
  28546. /**
  28547. * Sets wether the color grading texture contains BGR values.
  28548. */
  28549. colorGradingBGR: boolean;
  28550. /** @hidden */ exposure: number;
  28551. /**
  28552. * Gets the Exposure used in the effect.
  28553. */
  28554. /**
  28555. * Sets the Exposure used in the effect.
  28556. */
  28557. exposure: number;
  28558. private _toneMappingEnabled;
  28559. /**
  28560. * Gets wether the tone mapping effect is enabled.
  28561. */
  28562. /**
  28563. * Sets wether the tone mapping effect is enabled.
  28564. */
  28565. toneMappingEnabled: boolean;
  28566. private _toneMappingType;
  28567. /**
  28568. * Gets the type of tone mapping effect.
  28569. */
  28570. /**
  28571. * Sets the type of tone mapping effect used in BabylonJS.
  28572. */
  28573. toneMappingType: number;
  28574. protected _contrast: number;
  28575. /**
  28576. * Gets the contrast used in the effect.
  28577. */
  28578. /**
  28579. * Sets the contrast used in the effect.
  28580. */
  28581. contrast: number;
  28582. /**
  28583. * Vignette stretch size.
  28584. */
  28585. vignetteStretch: number;
  28586. /**
  28587. * Vignette centre X Offset.
  28588. */
  28589. vignetteCentreX: number;
  28590. /**
  28591. * Vignette centre Y Offset.
  28592. */
  28593. vignetteCentreY: number;
  28594. /**
  28595. * Vignette weight or intensity of the vignette effect.
  28596. */
  28597. vignetteWeight: number;
  28598. /**
  28599. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28600. * if vignetteEnabled is set to true.
  28601. */
  28602. vignetteColor: Color4;
  28603. /**
  28604. * Camera field of view used by the Vignette effect.
  28605. */
  28606. vignetteCameraFov: number;
  28607. private _vignetteBlendMode;
  28608. /**
  28609. * Gets the vignette blend mode allowing different kind of effect.
  28610. */
  28611. /**
  28612. * Sets the vignette blend mode allowing different kind of effect.
  28613. */
  28614. vignetteBlendMode: number;
  28615. private _vignetteEnabled;
  28616. /**
  28617. * Gets wether the vignette effect is enabled.
  28618. */
  28619. /**
  28620. * Sets wether the vignette effect is enabled.
  28621. */
  28622. vignetteEnabled: boolean;
  28623. private _applyByPostProcess;
  28624. /**
  28625. * Gets wether the image processing is applied through a post process or not.
  28626. */
  28627. /**
  28628. * Sets wether the image processing is applied through a post process or not.
  28629. */
  28630. applyByPostProcess: boolean;
  28631. private _isEnabled;
  28632. /**
  28633. * Gets wether the image processing is enabled or not.
  28634. */
  28635. /**
  28636. * Sets wether the image processing is enabled or not.
  28637. */
  28638. isEnabled: boolean;
  28639. /**
  28640. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  28641. */
  28642. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  28643. /**
  28644. * Method called each time the image processing information changes requires to recompile the effect.
  28645. */
  28646. protected _updateParameters(): void;
  28647. /**
  28648. * Gets the current class name.
  28649. * @return "ImageProcessingConfiguration"
  28650. */
  28651. getClassName(): string;
  28652. /**
  28653. * Prepare the list of uniforms associated with the Image Processing effects.
  28654. * @param uniforms The list of uniforms used in the effect
  28655. * @param defines the list of defines currently in use
  28656. */
  28657. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  28658. /**
  28659. * Prepare the list of samplers associated with the Image Processing effects.
  28660. * @param samplersList The list of uniforms used in the effect
  28661. * @param defines the list of defines currently in use
  28662. */
  28663. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  28664. /**
  28665. * Prepare the list of defines associated to the shader.
  28666. * @param defines the list of defines to complete
  28667. * @param forPostProcess Define if we are currently in post process mode or not
  28668. */
  28669. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  28670. /**
  28671. * Returns true if all the image processing information are ready.
  28672. * @returns True if ready, otherwise, false
  28673. */
  28674. isReady(): boolean;
  28675. /**
  28676. * Binds the image processing to the shader.
  28677. * @param effect The effect to bind to
  28678. * @param aspectRatio Define the current aspect ratio of the effect
  28679. */
  28680. bind(effect: Effect, aspectRatio?: number): void;
  28681. /**
  28682. * Clones the current image processing instance.
  28683. * @return The cloned image processing
  28684. */
  28685. clone(): ImageProcessingConfiguration;
  28686. /**
  28687. * Serializes the current image processing instance to a json representation.
  28688. * @return a JSON representation
  28689. */
  28690. serialize(): any;
  28691. /**
  28692. * Parses the image processing from a json representation.
  28693. * @param source the JSON source to parse
  28694. * @return The parsed image processing
  28695. */
  28696. static Parse(source: any): ImageProcessingConfiguration;
  28697. private static _VIGNETTEMODE_MULTIPLY;
  28698. private static _VIGNETTEMODE_OPAQUE;
  28699. /**
  28700. * Used to apply the vignette as a mix with the pixel color.
  28701. */
  28702. static readonly VIGNETTEMODE_MULTIPLY: number;
  28703. /**
  28704. * Used to apply the vignette as a replacement of the pixel color.
  28705. */
  28706. static readonly VIGNETTEMODE_OPAQUE: number;
  28707. }
  28708. }
  28709. declare module BABYLON {
  28710. /**
  28711. * This represents all the required information to add a fresnel effect on a material:
  28712. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28713. */
  28714. export class FresnelParameters {
  28715. private _isEnabled;
  28716. /**
  28717. * Define if the fresnel effect is enable or not.
  28718. */
  28719. isEnabled: boolean;
  28720. /**
  28721. * Define the color used on edges (grazing angle)
  28722. */
  28723. leftColor: Color3;
  28724. /**
  28725. * Define the color used on center
  28726. */
  28727. rightColor: Color3;
  28728. /**
  28729. * Define bias applied to computed fresnel term
  28730. */
  28731. bias: number;
  28732. /**
  28733. * Defined the power exponent applied to fresnel term
  28734. */
  28735. power: number;
  28736. /**
  28737. * Clones the current fresnel and its valuues
  28738. * @returns a clone fresnel configuration
  28739. */
  28740. clone(): FresnelParameters;
  28741. /**
  28742. * Serializes the current fresnel parameters to a JSON representation.
  28743. * @return the JSON serialization
  28744. */
  28745. serialize(): any;
  28746. /**
  28747. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28748. * @param parsedFresnelParameters Define the JSON representation
  28749. * @returns the parsed parameters
  28750. */
  28751. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28752. }
  28753. }
  28754. declare module BABYLON {
  28755. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28756. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28757. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28758. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28759. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28760. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28761. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28762. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28763. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28764. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28765. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28766. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28767. /**
  28768. * Decorator used to define property that can be serialized as reference to a camera
  28769. * @param sourceName defines the name of the property to decorate
  28770. */
  28771. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28772. /**
  28773. * Class used to help serialization objects
  28774. */
  28775. export class SerializationHelper {
  28776. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  28777. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  28778. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  28779. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  28780. /**
  28781. * Appends the serialized animations from the source animations
  28782. * @param source Source containing the animations
  28783. * @param destination Target to store the animations
  28784. */
  28785. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28786. /**
  28787. * Static function used to serialized a specific entity
  28788. * @param entity defines the entity to serialize
  28789. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28790. * @returns a JSON compatible object representing the serialization of the entity
  28791. */
  28792. static Serialize<T>(entity: T, serializationObject?: any): any;
  28793. /**
  28794. * Creates a new entity from a serialization data object
  28795. * @param creationFunction defines a function used to instanciated the new entity
  28796. * @param source defines the source serialization data
  28797. * @param scene defines the hosting scene
  28798. * @param rootUrl defines the root url for resources
  28799. * @returns a new entity
  28800. */
  28801. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28802. /**
  28803. * Clones an object
  28804. * @param creationFunction defines the function used to instanciate the new object
  28805. * @param source defines the source object
  28806. * @returns the cloned object
  28807. */
  28808. static Clone<T>(creationFunction: () => T, source: T): T;
  28809. /**
  28810. * Instanciates a new object based on a source one (some data will be shared between both object)
  28811. * @param creationFunction defines the function used to instanciate the new object
  28812. * @param source defines the source object
  28813. * @returns the new object
  28814. */
  28815. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28816. }
  28817. }
  28818. declare module BABYLON {
  28819. /**
  28820. * This is the base class of all the camera used in the application.
  28821. * @see http://doc.babylonjs.com/features/cameras
  28822. */
  28823. export class Camera extends Node {
  28824. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28825. /**
  28826. * This is the default projection mode used by the cameras.
  28827. * It helps recreating a feeling of perspective and better appreciate depth.
  28828. * This is the best way to simulate real life cameras.
  28829. */
  28830. static readonly PERSPECTIVE_CAMERA: number;
  28831. /**
  28832. * This helps creating camera with an orthographic mode.
  28833. * 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.
  28834. */
  28835. static readonly ORTHOGRAPHIC_CAMERA: number;
  28836. /**
  28837. * This is the default FOV mode for perspective cameras.
  28838. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28839. */
  28840. static readonly FOVMODE_VERTICAL_FIXED: number;
  28841. /**
  28842. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28843. */
  28844. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28845. /**
  28846. * This specifies ther is no need for a camera rig.
  28847. * Basically only one eye is rendered corresponding to the camera.
  28848. */
  28849. static readonly RIG_MODE_NONE: number;
  28850. /**
  28851. * Simulates a camera Rig with one blue eye and one red eye.
  28852. * This can be use with 3d blue and red glasses.
  28853. */
  28854. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28855. /**
  28856. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28857. */
  28858. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28859. /**
  28860. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28861. */
  28862. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28863. /**
  28864. * Defines that both eyes of the camera will be rendered over under each other.
  28865. */
  28866. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28867. /**
  28868. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28869. */
  28870. static readonly RIG_MODE_VR: number;
  28871. /**
  28872. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28873. */
  28874. static readonly RIG_MODE_WEBVR: number;
  28875. /**
  28876. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28877. */
  28878. static readonly RIG_MODE_CUSTOM: number;
  28879. /**
  28880. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28881. */
  28882. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28883. /**
  28884. * @hidden
  28885. * Might be removed once multiview will be a thing
  28886. */
  28887. static UseAlternateWebVRRendering: boolean;
  28888. /**
  28889. * Define the input manager associated with the camera.
  28890. */
  28891. inputs: CameraInputsManager<Camera>;
  28892. /**
  28893. * Define the current local position of the camera in the scene
  28894. */
  28895. position: Vector3;
  28896. /**
  28897. * The vector the camera should consider as up.
  28898. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28899. */
  28900. upVector: Vector3;
  28901. /**
  28902. * Define the current limit on the left side for an orthographic camera
  28903. * In scene unit
  28904. */
  28905. orthoLeft: Nullable<number>;
  28906. /**
  28907. * Define the current limit on the right side for an orthographic camera
  28908. * In scene unit
  28909. */
  28910. orthoRight: Nullable<number>;
  28911. /**
  28912. * Define the current limit on the bottom side for an orthographic camera
  28913. * In scene unit
  28914. */
  28915. orthoBottom: Nullable<number>;
  28916. /**
  28917. * Define the current limit on the top side for an orthographic camera
  28918. * In scene unit
  28919. */
  28920. orthoTop: Nullable<number>;
  28921. /**
  28922. * Field Of View is set in Radians. (default is 0.8)
  28923. */
  28924. fov: number;
  28925. /**
  28926. * Define the minimum distance the camera can see from.
  28927. * This is important to note that the depth buffer are not infinite and the closer it starts
  28928. * the more your scene might encounter depth fighting issue.
  28929. */
  28930. minZ: number;
  28931. /**
  28932. * Define the maximum distance the camera can see to.
  28933. * This is important to note that the depth buffer are not infinite and the further it end
  28934. * the more your scene might encounter depth fighting issue.
  28935. */
  28936. maxZ: number;
  28937. /**
  28938. * Define the default inertia of the camera.
  28939. * This helps giving a smooth feeling to the camera movement.
  28940. */
  28941. inertia: number;
  28942. /**
  28943. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  28944. */
  28945. mode: number;
  28946. /**
  28947. * Define wether the camera is intermediate.
  28948. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28949. */
  28950. isIntermediate: boolean;
  28951. /**
  28952. * Define the viewport of the camera.
  28953. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28954. */
  28955. viewport: Viewport;
  28956. /**
  28957. * Restricts the camera to viewing objects with the same layerMask.
  28958. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28959. */
  28960. layerMask: number;
  28961. /**
  28962. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28963. */
  28964. fovMode: number;
  28965. /**
  28966. * Rig mode of the camera.
  28967. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28968. * This is normally controlled byt the camera themselves as internal use.
  28969. */
  28970. cameraRigMode: number;
  28971. /**
  28972. * Defines the distance between both "eyes" in case of a RIG
  28973. */
  28974. interaxialDistance: number;
  28975. /**
  28976. * Defines if stereoscopic rendering is done side by side or over under.
  28977. */
  28978. isStereoscopicSideBySide: boolean;
  28979. /**
  28980. * 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
  28981. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28982. * else in the scene.
  28983. */
  28984. customRenderTargets: RenderTargetTexture[];
  28985. /**
  28986. * When set, the camera will render to this render target instead of the default canvas
  28987. */
  28988. outputRenderTarget: Nullable<RenderTargetTexture>;
  28989. /**
  28990. * Observable triggered when the camera view matrix has changed.
  28991. */
  28992. onViewMatrixChangedObservable: Observable<Camera>;
  28993. /**
  28994. * Observable triggered when the camera Projection matrix has changed.
  28995. */
  28996. onProjectionMatrixChangedObservable: Observable<Camera>;
  28997. /**
  28998. * Observable triggered when the inputs have been processed.
  28999. */
  29000. onAfterCheckInputsObservable: Observable<Camera>;
  29001. /**
  29002. * Observable triggered when reset has been called and applied to the camera.
  29003. */
  29004. onRestoreStateObservable: Observable<Camera>;
  29005. /** @hidden */ cameraRigParams: any;
  29006. /** @hidden */ rigCameras: Camera[];
  29007. /** @hidden */ rigPostProcess: Nullable<PostProcess>;
  29008. protected _webvrViewMatrix: Matrix;
  29009. /** @hidden */ skipRendering: boolean;
  29010. /** @hidden */ alternateCamera: Camera;
  29011. /** @hidden */ projectionMatrix: Matrix;
  29012. /** @hidden */ postProcesses: Nullable<PostProcess>[];
  29013. /** @hidden */ activeMeshes: SmartArray<AbstractMesh>;
  29014. protected _globalPosition: Vector3;
  29015. /** hidden */ computedViewMatrix: Matrix;
  29016. private _doNotComputeProjectionMatrix;
  29017. private _transformMatrix;
  29018. private _frustumPlanes;
  29019. private _refreshFrustumPlanes;
  29020. private _storedFov;
  29021. private _stateStored;
  29022. /**
  29023. * Instantiates a new camera object.
  29024. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29025. * @see http://doc.babylonjs.com/features/cameras
  29026. * @param name Defines the name of the camera in the scene
  29027. * @param position Defines the position of the camera
  29028. * @param scene Defines the scene the camera belongs too
  29029. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29030. */
  29031. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29032. /**
  29033. * Store current camera state (fov, position, etc..)
  29034. * @returns the camera
  29035. */
  29036. storeState(): Camera;
  29037. /**
  29038. * Restores the camera state values if it has been stored. You must call storeState() first
  29039. */
  29040. protected _restoreStateValues(): boolean;
  29041. /**
  29042. * Restored camera state. You must call storeState() first.
  29043. * @returns true if restored and false otherwise
  29044. */
  29045. restoreState(): boolean;
  29046. /**
  29047. * Gets the class name of the camera.
  29048. * @returns the class name
  29049. */
  29050. getClassName(): string;
  29051. /** @hidden */ protected readonly _isCamera: boolean;
  29052. /**
  29053. * Gets a string representation of the camera useful for debug purpose.
  29054. * @param fullDetails Defines that a more verboe level of logging is required
  29055. * @returns the string representation
  29056. */
  29057. toString(fullDetails?: boolean): string;
  29058. /**
  29059. * Gets the current world space position of the camera.
  29060. */
  29061. readonly globalPosition: Vector3;
  29062. /**
  29063. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29064. * @returns the active meshe list
  29065. */
  29066. getActiveMeshes(): SmartArray<AbstractMesh>;
  29067. /**
  29068. * Check wether a mesh is part of the current active mesh list of the camera
  29069. * @param mesh Defines the mesh to check
  29070. * @returns true if active, false otherwise
  29071. */
  29072. isActiveMesh(mesh: Mesh): boolean;
  29073. /**
  29074. * Is this camera ready to be used/rendered
  29075. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29076. * @return true if the camera is ready
  29077. */
  29078. isReady(completeCheck?: boolean): boolean;
  29079. /** @hidden */ initCache(): void;
  29080. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  29081. /** @hidden */ isSynchronized(): boolean;
  29082. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  29083. /** @hidden */ isSynchronizedProjectionMatrix(): boolean;
  29084. /**
  29085. * Attach the input controls to a specific dom element to get the input from.
  29086. * @param element Defines the element the controls should be listened from
  29087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29088. */
  29089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29090. /**
  29091. * Detach the current controls from the specified dom element.
  29092. * @param element Defines the element to stop listening the inputs from
  29093. */
  29094. detachControl(element: HTMLElement): void;
  29095. /**
  29096. * Update the camera state according to the different inputs gathered during the frame.
  29097. */
  29098. update(): void;
  29099. /** @hidden */ checkInputs(): void;
  29100. /** @hidden */
  29101. readonly rigCameras: Camera[];
  29102. /**
  29103. * Gets the post process used by the rig cameras
  29104. */
  29105. readonly rigPostProcess: Nullable<PostProcess>;
  29106. /**
  29107. * Internal, gets the first post proces.
  29108. * @returns the first post process to be run on this camera.
  29109. */ getFirstPostProcess(): Nullable<PostProcess>;
  29110. private _cascadePostProcessesToRigCams;
  29111. /**
  29112. * Attach a post process to the camera.
  29113. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29114. * @param postProcess The post process to attach to the camera
  29115. * @param insertAt The position of the post process in case several of them are in use in the scene
  29116. * @returns the position the post process has been inserted at
  29117. */
  29118. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29119. /**
  29120. * Detach a post process to the camera.
  29121. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29122. * @param postProcess The post process to detach from the camera
  29123. */
  29124. detachPostProcess(postProcess: PostProcess): void;
  29125. /**
  29126. * Gets the current world matrix of the camera
  29127. */
  29128. getWorldMatrix(): Matrix;
  29129. /** @hidden */ getViewMatrix(): Matrix;
  29130. /**
  29131. * Gets the current view matrix of the camera.
  29132. * @param force forces the camera to recompute the matrix without looking at the cached state
  29133. * @returns the view matrix
  29134. */
  29135. getViewMatrix(force?: boolean): Matrix;
  29136. /**
  29137. * Freeze the projection matrix.
  29138. * It will prevent the cache check of the camera projection compute and can speed up perf
  29139. * if no parameter of the camera are meant to change
  29140. * @param projection Defines manually a projection if necessary
  29141. */
  29142. freezeProjectionMatrix(projection?: Matrix): void;
  29143. /**
  29144. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29145. */
  29146. unfreezeProjectionMatrix(): void;
  29147. /**
  29148. * Gets the current projection matrix of the camera.
  29149. * @param force forces the camera to recompute the matrix without looking at the cached state
  29150. * @returns the projection matrix
  29151. */
  29152. getProjectionMatrix(force?: boolean): Matrix;
  29153. /**
  29154. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29155. * @returns a Matrix
  29156. */
  29157. getTransformationMatrix(): Matrix;
  29158. private _updateFrustumPlanes;
  29159. /**
  29160. * Checks if a cullable object (mesh...) is in the camera frustum
  29161. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29162. * @param target The object to check
  29163. * @returns true if the object is in frustum otherwise false
  29164. */
  29165. isInFrustum(target: ICullable): boolean;
  29166. /**
  29167. * Checks if a cullable object (mesh...) is in the camera frustum
  29168. * Unlike isInFrustum this cheks the full bounding box
  29169. * @param target The object to check
  29170. * @returns true if the object is in frustum otherwise false
  29171. */
  29172. isCompletelyInFrustum(target: ICullable): boolean;
  29173. /**
  29174. * Gets a ray in the forward direction from the camera.
  29175. * @param length Defines the length of the ray to create
  29176. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29177. * @param origin Defines the start point of the ray which defaults to the camera position
  29178. * @returns the forward ray
  29179. */
  29180. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29181. /**
  29182. * Releases resources associated with this node.
  29183. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29184. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29185. */
  29186. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29187. /**
  29188. * Gets the left camera of a rig setup in case of Rigged Camera
  29189. */
  29190. readonly leftCamera: Nullable<FreeCamera>;
  29191. /**
  29192. * Gets the right camera of a rig setup in case of Rigged Camera
  29193. */
  29194. readonly rightCamera: Nullable<FreeCamera>;
  29195. /**
  29196. * Gets the left camera target of a rig setup in case of Rigged Camera
  29197. * @returns the target position
  29198. */
  29199. getLeftTarget(): Nullable<Vector3>;
  29200. /**
  29201. * Gets the right camera target of a rig setup in case of Rigged Camera
  29202. * @returns the target position
  29203. */
  29204. getRightTarget(): Nullable<Vector3>;
  29205. /**
  29206. * @hidden
  29207. */
  29208. setCameraRigMode(mode: number, rigParams: any): void;
  29209. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  29210. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29211. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  29212. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29213. /** @hidden */ getVRProjectionMatrix(): Matrix;
  29214. protected _updateCameraRotationMatrix(): void;
  29215. protected _updateWebVRCameraRotationMatrix(): void;
  29216. /**
  29217. * This function MUST be overwritten by the different WebVR cameras available.
  29218. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29219. * @hidden
  29220. */ getWebVRProjectionMatrix(): Matrix;
  29221. /**
  29222. * This function MUST be overwritten by the different WebVR cameras available.
  29223. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29224. * @hidden
  29225. */ getWebVRViewMatrix(): Matrix;
  29226. /** @hidden */
  29227. setCameraRigParameter(name: string, value: any): void;
  29228. /**
  29229. * needs to be overridden by children so sub has required properties to be copied
  29230. * @hidden
  29231. */
  29232. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29233. /**
  29234. * May need to be overridden by children
  29235. * @hidden
  29236. */ updateRigCameras(): void;
  29237. /** @hidden */ setupInputs(): void;
  29238. /**
  29239. * Serialiaze the camera setup to a json represention
  29240. * @returns the JSON representation
  29241. */
  29242. serialize(): any;
  29243. /**
  29244. * Clones the current camera.
  29245. * @param name The cloned camera name
  29246. * @returns the cloned camera
  29247. */
  29248. clone(name: string): Camera;
  29249. /**
  29250. * Gets the direction of the camera relative to a given local axis.
  29251. * @param localAxis Defines the reference axis to provide a relative direction.
  29252. * @return the direction
  29253. */
  29254. getDirection(localAxis: Vector3): Vector3;
  29255. /**
  29256. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29257. * @param localAxis Defines the reference axis to provide a relative direction.
  29258. * @param result Defines the vector to store the result in
  29259. */
  29260. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29261. /**
  29262. * Gets a camera constructor for a given camera type
  29263. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29264. * @param name The name of the camera the result will be able to instantiate
  29265. * @param scene The scene the result will construct the camera in
  29266. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29267. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29268. * @returns a factory method to construc the camera
  29269. */
  29270. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29271. /**
  29272. * Compute the world matrix of the camera.
  29273. * @returns the camera workd matrix
  29274. */
  29275. computeWorldMatrix(): Matrix;
  29276. /**
  29277. * Parse a JSON and creates the camera from the parsed information
  29278. * @param parsedCamera The JSON to parse
  29279. * @param scene The scene to instantiate the camera in
  29280. * @returns the newly constructed camera
  29281. */
  29282. static Parse(parsedCamera: any, scene: Scene): Camera;
  29283. }
  29284. }
  29285. declare module BABYLON {
  29286. /**
  29287. * Interface for any object that can request an animation frame
  29288. */
  29289. export interface ICustomAnimationFrameRequester {
  29290. /**
  29291. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29292. */
  29293. renderFunction?: Function;
  29294. /**
  29295. * Called to request the next frame to render to
  29296. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29297. */
  29298. requestAnimationFrame: Function;
  29299. /**
  29300. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29301. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29302. */
  29303. requestID?: number;
  29304. }
  29305. /**
  29306. * Interface containing an array of animations
  29307. */
  29308. export interface IAnimatable {
  29309. /**
  29310. * Array of animations
  29311. */
  29312. animations: Array<Animation>;
  29313. }
  29314. /** Interface used by value gradients (color, factor, ...) */
  29315. export interface IValueGradient {
  29316. /**
  29317. * Gets or sets the gradient value (between 0 and 1)
  29318. */
  29319. gradient: number;
  29320. }
  29321. /** Class used to store color4 gradient */
  29322. export class ColorGradient implements IValueGradient {
  29323. /**
  29324. * Gets or sets the gradient value (between 0 and 1)
  29325. */
  29326. gradient: number;
  29327. /**
  29328. * Gets or sets first associated color
  29329. */
  29330. color1: Color4;
  29331. /**
  29332. * Gets or sets second associated color
  29333. */
  29334. color2?: Color4;
  29335. /**
  29336. * Will get a color picked randomly between color1 and color2.
  29337. * If color2 is undefined then color1 will be used
  29338. * @param result defines the target Color4 to store the result in
  29339. */
  29340. getColorToRef(result: Color4): void;
  29341. }
  29342. /** Class used to store color 3 gradient */
  29343. export class Color3Gradient implements IValueGradient {
  29344. /**
  29345. * Gets or sets the gradient value (between 0 and 1)
  29346. */
  29347. gradient: number;
  29348. /**
  29349. * Gets or sets the associated color
  29350. */
  29351. color: Color3;
  29352. }
  29353. /** Class used to store factor gradient */
  29354. export class FactorGradient implements IValueGradient {
  29355. /**
  29356. * Gets or sets the gradient value (between 0 and 1)
  29357. */
  29358. gradient: number;
  29359. /**
  29360. * Gets or sets first associated factor
  29361. */
  29362. factor1: number;
  29363. /**
  29364. * Gets or sets second associated factor
  29365. */
  29366. factor2?: number;
  29367. /**
  29368. * Will get a number picked randomly between factor1 and factor2.
  29369. * If factor2 is undefined then factor1 will be used
  29370. * @returns the picked number
  29371. */
  29372. getFactor(): number;
  29373. }
  29374. /**
  29375. * @ignore
  29376. * Application error to support additional information when loading a file
  29377. */
  29378. export class LoadFileError extends Error {
  29379. /** defines the optional XHR request */
  29380. request?: XMLHttpRequest | undefined;
  29381. private static _setPrototypeOf;
  29382. /**
  29383. * Creates a new LoadFileError
  29384. * @param message defines the message of the error
  29385. * @param request defines the optional XHR request
  29386. */
  29387. constructor(message: string,
  29388. /** defines the optional XHR request */
  29389. request?: XMLHttpRequest | undefined);
  29390. }
  29391. /**
  29392. * Class used to define a retry strategy when error happens while loading assets
  29393. */
  29394. export class RetryStrategy {
  29395. /**
  29396. * Function used to defines an exponential back off strategy
  29397. * @param maxRetries defines the maximum number of retries (3 by default)
  29398. * @param baseInterval defines the interval between retries
  29399. * @returns the strategy function to use
  29400. */
  29401. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29402. }
  29403. /**
  29404. * File request interface
  29405. */
  29406. export interface IFileRequest {
  29407. /**
  29408. * Raised when the request is complete (success or error).
  29409. */
  29410. onCompleteObservable: Observable<IFileRequest>;
  29411. /**
  29412. * Aborts the request for a file.
  29413. */
  29414. abort: () => void;
  29415. }
  29416. /**
  29417. * Class containing a set of static utilities functions
  29418. */
  29419. export class Tools {
  29420. /**
  29421. * Gets or sets the base URL to use to load assets
  29422. */
  29423. static BaseUrl: string;
  29424. /**
  29425. * Enable/Disable Custom HTTP Request Headers globally.
  29426. * default = false
  29427. * @see CustomRequestHeaders
  29428. */
  29429. static UseCustomRequestHeaders: boolean;
  29430. /**
  29431. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  29432. * i.e. when loading files, where the server/service expects an Authorization header.
  29433. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  29434. */
  29435. static CustomRequestHeaders: {
  29436. [key: string]: string;
  29437. };
  29438. /**
  29439. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  29440. */
  29441. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29442. /**
  29443. * Default behaviour for cors in the application.
  29444. * It can be a string if the expected behavior is identical in the entire app.
  29445. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  29446. */
  29447. static CorsBehavior: string | ((url: string | string[]) => string);
  29448. /**
  29449. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  29450. * @ignorenaming
  29451. */
  29452. static UseFallbackTexture: boolean;
  29453. /**
  29454. * Use this object to register external classes like custom textures or material
  29455. * to allow the laoders to instantiate them
  29456. */
  29457. static RegisteredExternalClasses: {
  29458. [key: string]: Object;
  29459. };
  29460. /**
  29461. * Texture content used if a texture cannot loaded
  29462. * @ignorenaming
  29463. */
  29464. static fallbackTexture: string;
  29465. /**
  29466. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  29467. * @param u defines the coordinate on X axis
  29468. * @param v defines the coordinate on Y axis
  29469. * @param width defines the width of the source data
  29470. * @param height defines the height of the source data
  29471. * @param pixels defines the source byte array
  29472. * @param color defines the output color
  29473. */
  29474. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  29475. /**
  29476. * Interpolates between a and b via alpha
  29477. * @param a The lower value (returned when alpha = 0)
  29478. * @param b The upper value (returned when alpha = 1)
  29479. * @param alpha The interpolation-factor
  29480. * @return The mixed value
  29481. */
  29482. static Mix(a: number, b: number, alpha: number): number;
  29483. /**
  29484. * Tries to instantiate a new object from a given class name
  29485. * @param className defines the class name to instantiate
  29486. * @returns the new object or null if the system was not able to do the instantiation
  29487. */
  29488. static Instantiate(className: string): any;
  29489. /**
  29490. * Provides a slice function that will work even on IE
  29491. * @param data defines the array to slice
  29492. * @param start defines the start of the data (optional)
  29493. * @param end defines the end of the data (optional)
  29494. * @returns the new sliced array
  29495. */
  29496. static Slice<T>(data: T, start?: number, end?: number): T;
  29497. /**
  29498. * Polyfill for setImmediate
  29499. * @param action defines the action to execute after the current execution block
  29500. */
  29501. static SetImmediate(action: () => void): void;
  29502. /**
  29503. * Function indicating if a number is an exponent of 2
  29504. * @param value defines the value to test
  29505. * @returns true if the value is an exponent of 2
  29506. */
  29507. static IsExponentOfTwo(value: number): boolean;
  29508. private static _tmpFloatArray;
  29509. /**
  29510. * Returns the nearest 32-bit single precision float representation of a Number
  29511. * @param value A Number. If the parameter is of a different type, it will get converted
  29512. * to a number or to NaN if it cannot be converted
  29513. * @returns number
  29514. */
  29515. static FloatRound(value: number): number;
  29516. /**
  29517. * Find the next highest power of two.
  29518. * @param x Number to start search from.
  29519. * @return Next highest power of two.
  29520. */
  29521. static CeilingPOT(x: number): number;
  29522. /**
  29523. * Find the next lowest power of two.
  29524. * @param x Number to start search from.
  29525. * @return Next lowest power of two.
  29526. */
  29527. static FloorPOT(x: number): number;
  29528. /**
  29529. * Find the nearest power of two.
  29530. * @param x Number to start search from.
  29531. * @return Next nearest power of two.
  29532. */
  29533. static NearestPOT(x: number): number;
  29534. /**
  29535. * Get the closest exponent of two
  29536. * @param value defines the value to approximate
  29537. * @param max defines the maximum value to return
  29538. * @param mode defines how to define the closest value
  29539. * @returns closest exponent of two of the given value
  29540. */
  29541. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29542. /**
  29543. * Extracts the filename from a path
  29544. * @param path defines the path to use
  29545. * @returns the filename
  29546. */
  29547. static GetFilename(path: string): string;
  29548. /**
  29549. * Extracts the "folder" part of a path (everything before the filename).
  29550. * @param uri The URI to extract the info from
  29551. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  29552. * @returns The "folder" part of the path
  29553. */
  29554. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  29555. /**
  29556. * Extracts text content from a DOM element hierarchy
  29557. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  29558. */
  29559. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  29560. /**
  29561. * Convert an angle in radians to degrees
  29562. * @param angle defines the angle to convert
  29563. * @returns the angle in degrees
  29564. */
  29565. static ToDegrees(angle: number): number;
  29566. /**
  29567. * Convert an angle in degrees to radians
  29568. * @param angle defines the angle to convert
  29569. * @returns the angle in radians
  29570. */
  29571. static ToRadians(angle: number): number;
  29572. /**
  29573. * Encode a buffer to a base64 string
  29574. * @param buffer defines the buffer to encode
  29575. * @returns the encoded string
  29576. */
  29577. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  29578. /**
  29579. * Extracts minimum and maximum values from a list of indexed positions
  29580. * @param positions defines the positions to use
  29581. * @param indices defines the indices to the positions
  29582. * @param indexStart defines the start index
  29583. * @param indexCount defines the end index
  29584. * @param bias defines bias value to add to the result
  29585. * @return minimum and maximum values
  29586. */
  29587. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  29588. minimum: Vector3;
  29589. maximum: Vector3;
  29590. };
  29591. /**
  29592. * Extracts minimum and maximum values from a list of positions
  29593. * @param positions defines the positions to use
  29594. * @param start defines the start index in the positions array
  29595. * @param count defines the number of positions to handle
  29596. * @param bias defines bias value to add to the result
  29597. * @param stride defines the stride size to use (distance between two positions in the positions array)
  29598. * @return minimum and maximum values
  29599. */
  29600. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  29601. minimum: Vector3;
  29602. maximum: Vector3;
  29603. };
  29604. /**
  29605. * Returns an array if obj is not an array
  29606. * @param obj defines the object to evaluate as an array
  29607. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  29608. * @returns either obj directly if obj is an array or a new array containing obj
  29609. */
  29610. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  29611. /**
  29612. * Gets the pointer prefix to use
  29613. * @returns "pointer" if touch is enabled. Else returns "mouse"
  29614. */
  29615. static GetPointerPrefix(): string;
  29616. /**
  29617. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  29618. * @param func - the function to be called
  29619. * @param requester - the object that will request the next frame. Falls back to window.
  29620. * @returns frame number
  29621. */
  29622. static QueueNewFrame(func: () => void, requester?: any): number;
  29623. /**
  29624. * Ask the browser to promote the current element to fullscreen rendering mode
  29625. * @param element defines the DOM element to promote
  29626. */
  29627. static RequestFullscreen(element: HTMLElement): void;
  29628. /**
  29629. * Asks the browser to exit fullscreen mode
  29630. */
  29631. static ExitFullscreen(): void;
  29632. /**
  29633. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  29634. * @param url define the url we are trying
  29635. * @param element define the dom element where to configure the cors policy
  29636. */
  29637. static SetCorsBehavior(url: string | string[], element: {
  29638. crossOrigin: string | null;
  29639. }): void;
  29640. /**
  29641. * Removes unwanted characters from an url
  29642. * @param url defines the url to clean
  29643. * @returns the cleaned url
  29644. */
  29645. static CleanUrl(url: string): string;
  29646. /**
  29647. * Gets or sets a function used to pre-process url before using them to load assets
  29648. */
  29649. static PreprocessUrl: (url: string) => string;
  29650. /**
  29651. * Loads an image as an HTMLImageElement.
  29652. * @param input url string, ArrayBuffer, or Blob to load
  29653. * @param onLoad callback called when the image successfully loads
  29654. * @param onError callback called when the image fails to load
  29655. * @param offlineProvider offline provider for caching
  29656. * @returns the HTMLImageElement of the loaded image
  29657. */
  29658. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  29659. /**
  29660. * Loads a file
  29661. * @param url url string, ArrayBuffer, or Blob to load
  29662. * @param onSuccess callback called when the file successfully loads
  29663. * @param onProgress callback called while file is loading (if the server supports this mode)
  29664. * @param offlineProvider defines the offline provider for caching
  29665. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  29666. * @param onError callback called when the file fails to load
  29667. * @returns a file request object
  29668. */
  29669. 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;
  29670. /**
  29671. * Load a script (identified by an url). When the url returns, the
  29672. * content of this file is added into a new script element, attached to the DOM (body element)
  29673. * @param scriptUrl defines the url of the script to laod
  29674. * @param onSuccess defines the callback called when the script is loaded
  29675. * @param onError defines the callback to call if an error occurs
  29676. */
  29677. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  29678. /**
  29679. * Loads a file from a blob
  29680. * @param fileToLoad defines the blob to use
  29681. * @param callback defines the callback to call when data is loaded
  29682. * @param progressCallback defines the callback to call during loading process
  29683. * @returns a file request object
  29684. */
  29685. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  29686. /**
  29687. * Loads a file
  29688. * @param fileToLoad defines the file to load
  29689. * @param callback defines the callback to call when data is loaded
  29690. * @param progressCallBack defines the callback to call during loading process
  29691. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  29692. * @returns a file request object
  29693. */
  29694. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  29695. /**
  29696. * Creates a data url from a given string content
  29697. * @param content defines the content to convert
  29698. * @returns the new data url link
  29699. */
  29700. static FileAsURL(content: string): string;
  29701. /**
  29702. * Format the given number to a specific decimal format
  29703. * @param value defines the number to format
  29704. * @param decimals defines the number of decimals to use
  29705. * @returns the formatted string
  29706. */
  29707. static Format(value: number, decimals?: number): string;
  29708. /**
  29709. * Checks if a given vector is inside a specific range
  29710. * @param v defines the vector to test
  29711. * @param min defines the minimum range
  29712. * @param max defines the maximum range
  29713. */
  29714. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  29715. /**
  29716. * Tries to copy an object by duplicating every property
  29717. * @param source defines the source object
  29718. * @param destination defines the target object
  29719. * @param doNotCopyList defines a list of properties to avoid
  29720. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  29721. */
  29722. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  29723. /**
  29724. * Gets a boolean indicating if the given object has no own property
  29725. * @param obj defines the object to test
  29726. * @returns true if object has no own property
  29727. */
  29728. static IsEmpty(obj: any): boolean;
  29729. /**
  29730. * Function used to register events at window level
  29731. * @param events defines the events to register
  29732. */
  29733. static RegisterTopRootEvents(events: {
  29734. name: string;
  29735. handler: Nullable<(e: FocusEvent) => any>;
  29736. }[]): void;
  29737. /**
  29738. * Function used to unregister events from window level
  29739. * @param events defines the events to unregister
  29740. */
  29741. static UnregisterTopRootEvents(events: {
  29742. name: string;
  29743. handler: Nullable<(e: FocusEvent) => any>;
  29744. }[]): void;
  29745. /**
  29746. * Dumps the current bound framebuffer
  29747. * @param width defines the rendering width
  29748. * @param height defines the rendering height
  29749. * @param engine defines the hosting engine
  29750. * @param successCallback defines the callback triggered once the data are available
  29751. * @param mimeType defines the mime type of the result
  29752. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  29753. */
  29754. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29755. /**
  29756. * Converts the canvas data to blob.
  29757. * This acts as a polyfill for browsers not supporting the to blob function.
  29758. * @param canvas Defines the canvas to extract the data from
  29759. * @param successCallback Defines the callback triggered once the data are available
  29760. * @param mimeType Defines the mime type of the result
  29761. */
  29762. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  29763. /**
  29764. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  29765. * @param successCallback defines the callback triggered once the data are available
  29766. * @param mimeType defines the mime type of the result
  29767. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  29768. */
  29769. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29770. /**
  29771. * Downloads a blob in the browser
  29772. * @param blob defines the blob to download
  29773. * @param fileName defines the name of the downloaded file
  29774. */
  29775. static Download(blob: Blob, fileName: string): void;
  29776. /**
  29777. * Captures a screenshot of the current rendering
  29778. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  29779. * @param engine defines the rendering engine
  29780. * @param camera defines the source camera
  29781. * @param size This parameter can be set to a single number or to an object with the
  29782. * following (optional) properties: precision, width, height. If a single number is passed,
  29783. * it will be used for both width and height. If an object is passed, the screenshot size
  29784. * will be derived from the parameters. The precision property is a multiplier allowing
  29785. * rendering at a higher or lower resolution
  29786. * @param successCallback defines the callback receives a single parameter which contains the
  29787. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  29788. * src parameter of an <img> to display it
  29789. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  29790. * Check your browser for supported MIME types
  29791. */
  29792. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  29793. /**
  29794. * Generates an image screenshot from the specified camera.
  29795. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  29796. * @param engine The engine to use for rendering
  29797. * @param camera The camera to use for rendering
  29798. * @param size This parameter can be set to a single number or to an object with the
  29799. * following (optional) properties: precision, width, height. If a single number is passed,
  29800. * it will be used for both width and height. If an object is passed, the screenshot size
  29801. * will be derived from the parameters. The precision property is a multiplier allowing
  29802. * rendering at a higher or lower resolution
  29803. * @param successCallback The callback receives a single parameter which contains the
  29804. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  29805. * src parameter of an <img> to display it
  29806. * @param mimeType The MIME type of the screenshot image (default: image/png).
  29807. * Check your browser for supported MIME types
  29808. * @param samples Texture samples (default: 1)
  29809. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  29810. * @param fileName A name for for the downloaded file.
  29811. */
  29812. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  29813. /**
  29814. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29815. * Be aware Math.random() could cause collisions, but:
  29816. * "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"
  29817. * @returns a pseudo random id
  29818. */
  29819. static RandomId(): string;
  29820. /**
  29821. * Test if the given uri is a base64 string
  29822. * @param uri The uri to test
  29823. * @return True if the uri is a base64 string or false otherwise
  29824. */
  29825. static IsBase64(uri: string): boolean;
  29826. /**
  29827. * Decode the given base64 uri.
  29828. * @param uri The uri to decode
  29829. * @return The decoded base64 data.
  29830. */
  29831. static DecodeBase64(uri: string): ArrayBuffer;
  29832. /**
  29833. * No log
  29834. */
  29835. static readonly NoneLogLevel: number;
  29836. /**
  29837. * Only message logs
  29838. */
  29839. static readonly MessageLogLevel: number;
  29840. /**
  29841. * Only warning logs
  29842. */
  29843. static readonly WarningLogLevel: number;
  29844. /**
  29845. * Only error logs
  29846. */
  29847. static readonly ErrorLogLevel: number;
  29848. /**
  29849. * All logs
  29850. */
  29851. static readonly AllLogLevel: number;
  29852. /**
  29853. * Gets a value indicating the number of loading errors
  29854. * @ignorenaming
  29855. */
  29856. static readonly errorsCount: number;
  29857. /**
  29858. * Callback called when a new log is added
  29859. */
  29860. static OnNewCacheEntry: (entry: string) => void;
  29861. /**
  29862. * Log a message to the console
  29863. * @param message defines the message to log
  29864. */
  29865. static Log(message: string): void;
  29866. /**
  29867. * Write a warning message to the console
  29868. * @param message defines the message to log
  29869. */
  29870. static Warn(message: string): void;
  29871. /**
  29872. * Write an error message to the console
  29873. * @param message defines the message to log
  29874. */
  29875. static Error(message: string): void;
  29876. /**
  29877. * Gets current log cache (list of logs)
  29878. */
  29879. static readonly LogCache: string;
  29880. /**
  29881. * Clears the log cache
  29882. */
  29883. static ClearLogCache(): void;
  29884. /**
  29885. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  29886. */
  29887. static LogLevels: number;
  29888. /**
  29889. * Checks if the loaded document was accessed via `file:`-Protocol.
  29890. * @returns boolean
  29891. */
  29892. static IsFileURL(): boolean;
  29893. /**
  29894. * Checks if the window object exists
  29895. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  29896. */
  29897. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  29898. /**
  29899. * No performance log
  29900. */
  29901. static readonly PerformanceNoneLogLevel: number;
  29902. /**
  29903. * Use user marks to log performance
  29904. */
  29905. static readonly PerformanceUserMarkLogLevel: number;
  29906. /**
  29907. * Log performance to the console
  29908. */
  29909. static readonly PerformanceConsoleLogLevel: number;
  29910. private static _performance;
  29911. /**
  29912. * Sets the current performance log level
  29913. */
  29914. static PerformanceLogLevel: number;
  29915. private static _StartPerformanceCounterDisabled;
  29916. private static _EndPerformanceCounterDisabled;
  29917. private static _StartUserMark;
  29918. private static _EndUserMark;
  29919. private static _StartPerformanceConsole;
  29920. private static _EndPerformanceConsole;
  29921. /**
  29922. * Injects the @see CustomRequestHeaders into the given request
  29923. * @param request the request that should be used for injection
  29924. */
  29925. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  29926. /**
  29927. * Starts a performance counter
  29928. */
  29929. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29930. /**
  29931. * Ends a specific performance coutner
  29932. */
  29933. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29934. /**
  29935. * Gets either window.performance.now() if supported or Date.now() else
  29936. */
  29937. static readonly Now: number;
  29938. /**
  29939. * This method will return the name of the class used to create the instance of the given object.
  29940. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  29941. * @param object the object to get the class name from
  29942. * @param isType defines if the object is actually a type
  29943. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  29944. */
  29945. static GetClassName(object: any, isType?: boolean): string;
  29946. /**
  29947. * Gets the first element of an array satisfying a given predicate
  29948. * @param array defines the array to browse
  29949. * @param predicate defines the predicate to use
  29950. * @returns null if not found or the element
  29951. */
  29952. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  29953. /**
  29954. * This method will return the name of the full name of the class, including its owning module (if any).
  29955. * 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).
  29956. * @param object the object to get the class name from
  29957. * @param isType defines if the object is actually a type
  29958. * @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.
  29959. * @ignorenaming
  29960. */
  29961. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  29962. /**
  29963. * Returns a promise that resolves after the given amount of time.
  29964. * @param delay Number of milliseconds to delay
  29965. * @returns Promise that resolves after the given amount of time
  29966. */
  29967. static DelayAsync(delay: number): Promise<void>;
  29968. /**
  29969. * Gets the current gradient from an array of IValueGradient
  29970. * @param ratio defines the current ratio to get
  29971. * @param gradients defines the array of IValueGradient
  29972. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  29973. */
  29974. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  29975. }
  29976. /**
  29977. * This class is used to track a performance counter which is number based.
  29978. * The user has access to many properties which give statistics of different nature.
  29979. *
  29980. * The implementer can track two kinds of Performance Counter: time and count.
  29981. * 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.
  29982. * 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.
  29983. */
  29984. export class PerfCounter {
  29985. /**
  29986. * Gets or sets a global boolean to turn on and off all the counters
  29987. */
  29988. static Enabled: boolean;
  29989. /**
  29990. * Returns the smallest value ever
  29991. */
  29992. readonly min: number;
  29993. /**
  29994. * Returns the biggest value ever
  29995. */
  29996. readonly max: number;
  29997. /**
  29998. * Returns the average value since the performance counter is running
  29999. */
  30000. readonly average: number;
  30001. /**
  30002. * Returns the average value of the last second the counter was monitored
  30003. */
  30004. readonly lastSecAverage: number;
  30005. /**
  30006. * Returns the current value
  30007. */
  30008. readonly current: number;
  30009. /**
  30010. * Gets the accumulated total
  30011. */
  30012. readonly total: number;
  30013. /**
  30014. * Gets the total value count
  30015. */
  30016. readonly count: number;
  30017. /**
  30018. * Creates a new counter
  30019. */
  30020. constructor();
  30021. /**
  30022. * Call this method to start monitoring a new frame.
  30023. * 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.
  30024. */
  30025. fetchNewFrame(): void;
  30026. /**
  30027. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30028. * @param newCount the count value to add to the monitored count
  30029. * @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.
  30030. */
  30031. addCount(newCount: number, fetchResult: boolean): void;
  30032. /**
  30033. * Start monitoring this performance counter
  30034. */
  30035. beginMonitoring(): void;
  30036. /**
  30037. * Compute the time lapsed since the previous beginMonitoring() call.
  30038. * @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
  30039. */
  30040. endMonitoring(newFrame?: boolean): void;
  30041. private _fetchResult;
  30042. private _startMonitoringTime;
  30043. private _min;
  30044. private _max;
  30045. private _average;
  30046. private _current;
  30047. private _totalValueCount;
  30048. private _totalAccumulated;
  30049. private _lastSecAverage;
  30050. private _lastSecAccumulated;
  30051. private _lastSecTime;
  30052. private _lastSecValueCount;
  30053. }
  30054. /**
  30055. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30056. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30057. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30058. * @param name The name of the class, case should be preserved
  30059. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30060. */
  30061. export function className(name: string, module?: string): (target: Object) => void;
  30062. /**
  30063. * An implementation of a loop for asynchronous functions.
  30064. */
  30065. export class AsyncLoop {
  30066. /**
  30067. * Defines the number of iterations for the loop
  30068. */
  30069. iterations: number;
  30070. /**
  30071. * Defines the current index of the loop.
  30072. */
  30073. index: number;
  30074. private _done;
  30075. private _fn;
  30076. private _successCallback;
  30077. /**
  30078. * Constructor.
  30079. * @param iterations the number of iterations.
  30080. * @param func the function to run each iteration
  30081. * @param successCallback the callback that will be called upon succesful execution
  30082. * @param offset starting offset.
  30083. */
  30084. constructor(
  30085. /**
  30086. * Defines the number of iterations for the loop
  30087. */
  30088. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30089. /**
  30090. * Execute the next iteration. Must be called after the last iteration was finished.
  30091. */
  30092. executeNext(): void;
  30093. /**
  30094. * Break the loop and run the success callback.
  30095. */
  30096. breakLoop(): void;
  30097. /**
  30098. * Create and run an async loop.
  30099. * @param iterations the number of iterations.
  30100. * @param fn the function to run each iteration
  30101. * @param successCallback the callback that will be called upon succesful execution
  30102. * @param offset starting offset.
  30103. * @returns the created async loop object
  30104. */
  30105. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30106. /**
  30107. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30108. * @param iterations total number of iterations
  30109. * @param syncedIterations number of synchronous iterations in each async iteration.
  30110. * @param fn the function to call each iteration.
  30111. * @param callback a success call back that will be called when iterating stops.
  30112. * @param breakFunction a break condition (optional)
  30113. * @param timeout timeout settings for the setTimeout function. default - 0.
  30114. * @returns the created async loop object
  30115. */
  30116. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30117. }
  30118. }
  30119. declare module BABYLON {
  30120. /** @hidden */
  30121. export interface ICollisionCoordinator {
  30122. createCollider(): Collider;
  30123. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30124. init(scene: Scene): void;
  30125. }
  30126. /** @hidden */
  30127. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30128. private _scene;
  30129. private _scaledPosition;
  30130. private _scaledVelocity;
  30131. private _finalPosition;
  30132. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30133. createCollider(): Collider;
  30134. init(scene: Scene): void;
  30135. private _collideWithWorld;
  30136. }
  30137. }
  30138. declare module BABYLON {
  30139. /**
  30140. * This class defines the direct association between an animation and a target
  30141. */
  30142. export class TargetedAnimation {
  30143. /**
  30144. * Animation to perform
  30145. */
  30146. animation: Animation;
  30147. /**
  30148. * Target to animate
  30149. */
  30150. target: any;
  30151. }
  30152. /**
  30153. * Use this class to create coordinated animations on multiple targets
  30154. */
  30155. export class AnimationGroup implements IDisposable {
  30156. /** The name of the animation group */
  30157. name: string;
  30158. private _scene;
  30159. private _targetedAnimations;
  30160. private _animatables;
  30161. private _from;
  30162. private _to;
  30163. private _isStarted;
  30164. private _isPaused;
  30165. private _speedRatio;
  30166. /**
  30167. * Gets or sets the unique id of the node
  30168. */
  30169. uniqueId: number;
  30170. /**
  30171. * This observable will notify when one animation have ended
  30172. */
  30173. onAnimationEndObservable: Observable<TargetedAnimation>;
  30174. /**
  30175. * Observer raised when one animation loops
  30176. */
  30177. onAnimationLoopObservable: Observable<TargetedAnimation>;
  30178. /**
  30179. * This observable will notify when all animations have ended.
  30180. */
  30181. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  30182. /**
  30183. * This observable will notify when all animations have paused.
  30184. */
  30185. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  30186. /**
  30187. * This observable will notify when all animations are playing.
  30188. */
  30189. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  30190. /**
  30191. * Gets the first frame
  30192. */
  30193. readonly from: number;
  30194. /**
  30195. * Gets the last frame
  30196. */
  30197. readonly to: number;
  30198. /**
  30199. * Define if the animations are started
  30200. */
  30201. readonly isStarted: boolean;
  30202. /**
  30203. * Gets a value indicating that the current group is playing
  30204. */
  30205. readonly isPlaying: boolean;
  30206. /**
  30207. * Gets or sets the speed ratio to use for all animations
  30208. */
  30209. /**
  30210. * Gets or sets the speed ratio to use for all animations
  30211. */
  30212. speedRatio: number;
  30213. /**
  30214. * Gets the targeted animations for this animation group
  30215. */
  30216. readonly targetedAnimations: Array<TargetedAnimation>;
  30217. /**
  30218. * returning the list of animatables controlled by this animation group.
  30219. */
  30220. readonly animatables: Array<Animatable>;
  30221. /**
  30222. * Instantiates a new Animation Group.
  30223. * This helps managing several animations at once.
  30224. * @see http://doc.babylonjs.com/how_to/group
  30225. * @param name Defines the name of the group
  30226. * @param scene Defines the scene the group belongs to
  30227. */
  30228. constructor(
  30229. /** The name of the animation group */
  30230. name: string, scene?: Nullable<Scene>);
  30231. /**
  30232. * Add an animation (with its target) in the group
  30233. * @param animation defines the animation we want to add
  30234. * @param target defines the target of the animation
  30235. * @returns the TargetedAnimation object
  30236. */
  30237. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  30238. /**
  30239. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  30240. * It can add constant keys at begin or end
  30241. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  30242. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  30243. * @returns the animation group
  30244. */
  30245. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  30246. /**
  30247. * Start all animations on given targets
  30248. * @param loop defines if animations must loop
  30249. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  30250. * @param from defines the from key (optional)
  30251. * @param to defines the to key (optional)
  30252. * @returns the current animation group
  30253. */
  30254. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  30255. /**
  30256. * Pause all animations
  30257. * @returns the animation group
  30258. */
  30259. pause(): AnimationGroup;
  30260. /**
  30261. * Play all animations to initial state
  30262. * This function will start() the animations if they were not started or will restart() them if they were paused
  30263. * @param loop defines if animations must loop
  30264. * @returns the animation group
  30265. */
  30266. play(loop?: boolean): AnimationGroup;
  30267. /**
  30268. * Reset all animations to initial state
  30269. * @returns the animation group
  30270. */
  30271. reset(): AnimationGroup;
  30272. /**
  30273. * Restart animations from key 0
  30274. * @returns the animation group
  30275. */
  30276. restart(): AnimationGroup;
  30277. /**
  30278. * Stop all animations
  30279. * @returns the animation group
  30280. */
  30281. stop(): AnimationGroup;
  30282. /**
  30283. * Set animation weight for all animatables
  30284. * @param weight defines the weight to use
  30285. * @return the animationGroup
  30286. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30287. */
  30288. setWeightForAllAnimatables(weight: number): AnimationGroup;
  30289. /**
  30290. * Synchronize and normalize all animatables with a source animatable
  30291. * @param root defines the root animatable to synchronize with
  30292. * @return the animationGroup
  30293. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30294. */
  30295. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  30296. /**
  30297. * Goes to a specific frame in this animation group
  30298. * @param frame the frame number to go to
  30299. * @return the animationGroup
  30300. */
  30301. goToFrame(frame: number): AnimationGroup;
  30302. /**
  30303. * Dispose all associated resources
  30304. */
  30305. dispose(): void;
  30306. private _checkAnimationGroupEnded;
  30307. /**
  30308. * Clone the current animation group and returns a copy
  30309. * @param newName defines the name of the new group
  30310. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  30311. * @returns the new aniamtion group
  30312. */
  30313. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  30314. /**
  30315. * Returns a new AnimationGroup object parsed from the source provided.
  30316. * @param parsedAnimationGroup defines the source
  30317. * @param scene defines the scene that will receive the animationGroup
  30318. * @returns a new AnimationGroup
  30319. */
  30320. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  30321. /**
  30322. * Returns the string "AnimationGroup"
  30323. * @returns "AnimationGroup"
  30324. */
  30325. getClassName(): string;
  30326. /**
  30327. * Creates a detailled string about the object
  30328. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  30329. * @returns a string representing the object
  30330. */
  30331. toString(fullDetails?: boolean): string;
  30332. }
  30333. }
  30334. declare module BABYLON {
  30335. /**
  30336. * Define an interface for all classes that will hold resources
  30337. */
  30338. export interface IDisposable {
  30339. /**
  30340. * Releases all held resources
  30341. */
  30342. dispose(): void;
  30343. }
  30344. /** Interface defining initialization parameters for Scene class */
  30345. export interface SceneOptions {
  30346. /**
  30347. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  30348. * It will improve performance when the number of geometries becomes important.
  30349. */
  30350. useGeometryUniqueIdsMap?: boolean;
  30351. /**
  30352. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  30353. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30354. */
  30355. useMaterialMeshMap?: boolean;
  30356. /**
  30357. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  30358. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30359. */
  30360. useClonedMeshhMap?: boolean;
  30361. }
  30362. /**
  30363. * Represents a scene to be rendered by the engine.
  30364. * @see http://doc.babylonjs.com/features/scene
  30365. */
  30366. export class Scene extends AbstractScene implements IAnimatable {
  30367. private static _uniqueIdCounter;
  30368. /** The fog is deactivated */
  30369. static readonly FOGMODE_NONE: number;
  30370. /** The fog density is following an exponential function */
  30371. static readonly FOGMODE_EXP: number;
  30372. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  30373. static readonly FOGMODE_EXP2: number;
  30374. /** The fog density is following a linear function. */
  30375. static readonly FOGMODE_LINEAR: number;
  30376. /**
  30377. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  30378. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30379. */
  30380. static MinDeltaTime: number;
  30381. /**
  30382. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  30383. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30384. */
  30385. static MaxDeltaTime: number;
  30386. /**
  30387. * Factory used to create the default material.
  30388. * @param name The name of the material to create
  30389. * @param scene The scene to create the material for
  30390. * @returns The default material
  30391. */
  30392. static DefaultMaterialFactory(scene: Scene): Material;
  30393. /**
  30394. * Factory used to create the a collision coordinator.
  30395. * @returns The collision coordinator
  30396. */
  30397. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  30398. /** @hidden */ protected readonly _isScene: boolean;
  30399. /**
  30400. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  30401. */
  30402. autoClear: boolean;
  30403. /**
  30404. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  30405. */
  30406. autoClearDepthAndStencil: boolean;
  30407. /**
  30408. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  30409. */
  30410. clearColor: Color4;
  30411. /**
  30412. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  30413. */
  30414. ambientColor: Color3;
  30415. /** @hidden */ environmentBRDFTexture: BaseTexture;
  30416. /** @hidden */
  30417. protected _environmentTexture: Nullable<BaseTexture>;
  30418. /**
  30419. * Texture used in all pbr material as the reflection texture.
  30420. * As in the majority of the scene they are the same (exception for multi room and so on),
  30421. * this is easier to reference from here than from all the materials.
  30422. */
  30423. /**
  30424. * Texture used in all pbr material as the reflection texture.
  30425. * As in the majority of the scene they are the same (exception for multi room and so on),
  30426. * this is easier to set here than in all the materials.
  30427. */
  30428. environmentTexture: Nullable<BaseTexture>;
  30429. /** @hidden */
  30430. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30431. /**
  30432. * Default image processing configuration used either in the rendering
  30433. * Forward main pass or through the imageProcessingPostProcess if present.
  30434. * As in the majority of the scene they are the same (exception for multi camera),
  30435. * this is easier to reference from here than from all the materials and post process.
  30436. *
  30437. * No setter as we it is a shared configuration, you can set the values instead.
  30438. */
  30439. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  30440. private _forceWireframe;
  30441. /**
  30442. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  30443. */
  30444. forceWireframe: boolean;
  30445. private _forcePointsCloud;
  30446. /**
  30447. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  30448. */
  30449. forcePointsCloud: boolean;
  30450. /**
  30451. * Gets or sets the active clipplane 1
  30452. */
  30453. clipPlane: Nullable<Plane>;
  30454. /**
  30455. * Gets or sets the active clipplane 2
  30456. */
  30457. clipPlane2: Nullable<Plane>;
  30458. /**
  30459. * Gets or sets the active clipplane 3
  30460. */
  30461. clipPlane3: Nullable<Plane>;
  30462. /**
  30463. * Gets or sets the active clipplane 4
  30464. */
  30465. clipPlane4: Nullable<Plane>;
  30466. /**
  30467. * Gets or sets a boolean indicating if animations are enabled
  30468. */
  30469. animationsEnabled: boolean;
  30470. private _animationPropertiesOverride;
  30471. /**
  30472. * Gets or sets the animation properties override
  30473. */
  30474. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  30475. /**
  30476. * Gets or sets a boolean indicating if a constant deltatime has to be used
  30477. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  30478. */
  30479. useConstantAnimationDeltaTime: boolean;
  30480. /**
  30481. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  30482. * Please note that it requires to run a ray cast through the scene on every frame
  30483. */
  30484. constantlyUpdateMeshUnderPointer: boolean;
  30485. /**
  30486. * Defines the HTML cursor to use when hovering over interactive elements
  30487. */
  30488. hoverCursor: string;
  30489. /**
  30490. * Defines the HTML default cursor to use (empty by default)
  30491. */
  30492. defaultCursor: string;
  30493. /**
  30494. * This is used to call preventDefault() on pointer down
  30495. * in order to block unwanted artifacts like system double clicks
  30496. */
  30497. preventDefaultOnPointerDown: boolean;
  30498. /**
  30499. * This is used to call preventDefault() on pointer up
  30500. * in order to block unwanted artifacts like system double clicks
  30501. */
  30502. preventDefaultOnPointerUp: boolean;
  30503. /**
  30504. * Gets or sets user defined metadata
  30505. */
  30506. metadata: any;
  30507. /**
  30508. * For internal use only. Please do not use.
  30509. */
  30510. reservedDataStore: any;
  30511. /**
  30512. * Gets the name of the plugin used to load this scene (null by default)
  30513. */
  30514. loadingPluginName: string;
  30515. /**
  30516. * Use this array to add regular expressions used to disable offline support for specific urls
  30517. */
  30518. disableOfflineSupportExceptionRules: RegExp[];
  30519. /**
  30520. * An event triggered when the scene is disposed.
  30521. */
  30522. onDisposeObservable: Observable<Scene>;
  30523. private _onDisposeObserver;
  30524. /** Sets a function to be executed when this scene is disposed. */
  30525. onDispose: () => void;
  30526. /**
  30527. * An event triggered before rendering the scene (right after animations and physics)
  30528. */
  30529. onBeforeRenderObservable: Observable<Scene>;
  30530. private _onBeforeRenderObserver;
  30531. /** Sets a function to be executed before rendering this scene */
  30532. beforeRender: Nullable<() => void>;
  30533. /**
  30534. * An event triggered after rendering the scene
  30535. */
  30536. onAfterRenderObservable: Observable<Scene>;
  30537. private _onAfterRenderObserver;
  30538. /** Sets a function to be executed after rendering this scene */
  30539. afterRender: Nullable<() => void>;
  30540. /**
  30541. * An event triggered before animating the scene
  30542. */
  30543. onBeforeAnimationsObservable: Observable<Scene>;
  30544. /**
  30545. * An event triggered after animations processing
  30546. */
  30547. onAfterAnimationsObservable: Observable<Scene>;
  30548. /**
  30549. * An event triggered before draw calls are ready to be sent
  30550. */
  30551. onBeforeDrawPhaseObservable: Observable<Scene>;
  30552. /**
  30553. * An event triggered after draw calls have been sent
  30554. */
  30555. onAfterDrawPhaseObservable: Observable<Scene>;
  30556. /**
  30557. * An event triggered when the scene is ready
  30558. */
  30559. onReadyObservable: Observable<Scene>;
  30560. /**
  30561. * An event triggered before rendering a camera
  30562. */
  30563. onBeforeCameraRenderObservable: Observable<Camera>;
  30564. private _onBeforeCameraRenderObserver;
  30565. /** Sets a function to be executed before rendering a camera*/
  30566. beforeCameraRender: () => void;
  30567. /**
  30568. * An event triggered after rendering a camera
  30569. */
  30570. onAfterCameraRenderObservable: Observable<Camera>;
  30571. private _onAfterCameraRenderObserver;
  30572. /** Sets a function to be executed after rendering a camera*/
  30573. afterCameraRender: () => void;
  30574. /**
  30575. * An event triggered when active meshes evaluation is about to start
  30576. */
  30577. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  30578. /**
  30579. * An event triggered when active meshes evaluation is done
  30580. */
  30581. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  30582. /**
  30583. * An event triggered when particles rendering is about to start
  30584. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  30585. */
  30586. onBeforeParticlesRenderingObservable: Observable<Scene>;
  30587. /**
  30588. * An event triggered when particles rendering is done
  30589. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  30590. */
  30591. onAfterParticlesRenderingObservable: Observable<Scene>;
  30592. /**
  30593. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  30594. */
  30595. onDataLoadedObservable: Observable<Scene>;
  30596. /**
  30597. * An event triggered when a camera is created
  30598. */
  30599. onNewCameraAddedObservable: Observable<Camera>;
  30600. /**
  30601. * An event triggered when a camera is removed
  30602. */
  30603. onCameraRemovedObservable: Observable<Camera>;
  30604. /**
  30605. * An event triggered when a light is created
  30606. */
  30607. onNewLightAddedObservable: Observable<Light>;
  30608. /**
  30609. * An event triggered when a light is removed
  30610. */
  30611. onLightRemovedObservable: Observable<Light>;
  30612. /**
  30613. * An event triggered when a geometry is created
  30614. */
  30615. onNewGeometryAddedObservable: Observable<Geometry>;
  30616. /**
  30617. * An event triggered when a geometry is removed
  30618. */
  30619. onGeometryRemovedObservable: Observable<Geometry>;
  30620. /**
  30621. * An event triggered when a transform node is created
  30622. */
  30623. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  30624. /**
  30625. * An event triggered when a transform node is removed
  30626. */
  30627. onTransformNodeRemovedObservable: Observable<TransformNode>;
  30628. /**
  30629. * An event triggered when a mesh is created
  30630. */
  30631. onNewMeshAddedObservable: Observable<AbstractMesh>;
  30632. /**
  30633. * An event triggered when a mesh is removed
  30634. */
  30635. onMeshRemovedObservable: Observable<AbstractMesh>;
  30636. /**
  30637. * An event triggered when a material is created
  30638. */
  30639. onNewMaterialAddedObservable: Observable<Material>;
  30640. /**
  30641. * An event triggered when a material is removed
  30642. */
  30643. onMaterialRemovedObservable: Observable<Material>;
  30644. /**
  30645. * An event triggered when a texture is created
  30646. */
  30647. onNewTextureAddedObservable: Observable<BaseTexture>;
  30648. /**
  30649. * An event triggered when a texture is removed
  30650. */
  30651. onTextureRemovedObservable: Observable<BaseTexture>;
  30652. /**
  30653. * An event triggered when render targets are about to be rendered
  30654. * Can happen multiple times per frame.
  30655. */
  30656. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  30657. /**
  30658. * An event triggered when render targets were rendered.
  30659. * Can happen multiple times per frame.
  30660. */
  30661. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  30662. /**
  30663. * An event triggered before calculating deterministic simulation step
  30664. */
  30665. onBeforeStepObservable: Observable<Scene>;
  30666. /**
  30667. * An event triggered after calculating deterministic simulation step
  30668. */
  30669. onAfterStepObservable: Observable<Scene>;
  30670. /**
  30671. * An event triggered when the activeCamera property is updated
  30672. */
  30673. onActiveCameraChanged: Observable<Scene>;
  30674. /**
  30675. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  30676. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  30677. * 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)
  30678. */
  30679. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  30680. /**
  30681. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  30682. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  30683. * 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)
  30684. */
  30685. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  30686. /**
  30687. * This Observable will when a mesh has been imported into the scene.
  30688. */
  30689. onMeshImportedObservable: Observable<AbstractMesh>;
  30690. /** @hidden */ registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  30691. /**
  30692. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  30693. */
  30694. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  30695. /**
  30696. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  30697. */
  30698. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  30699. /**
  30700. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  30701. */
  30702. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  30703. private _onPointerMove;
  30704. private _onPointerDown;
  30705. private _onPointerUp;
  30706. /** Callback called when a pointer move is detected */
  30707. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  30708. /** Callback called when a pointer down is detected */
  30709. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  30710. /** Callback called when a pointer up is detected */
  30711. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  30712. /** Callback called when a pointer pick is detected */
  30713. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  30714. /**
  30715. * 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).
  30716. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  30717. */
  30718. onPrePointerObservable: Observable<PointerInfoPre>;
  30719. /**
  30720. * Observable event triggered each time an input event is received from the rendering canvas
  30721. */
  30722. onPointerObservable: Observable<PointerInfo>;
  30723. /**
  30724. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  30725. */
  30726. readonly unTranslatedPointer: Vector2;
  30727. /** The distance in pixel that you have to move to prevent some events */
  30728. static DragMovementThreshold: number;
  30729. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  30730. static LongPressDelay: number;
  30731. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  30732. static DoubleClickDelay: number;
  30733. /** If you need to check double click without raising a single click at first click, enable this flag */
  30734. static ExclusiveDoubleClickMode: boolean;
  30735. private _initClickEvent;
  30736. private _initActionManager;
  30737. private _delayedSimpleClick;
  30738. private _delayedSimpleClickTimeout;
  30739. private _previousDelayedSimpleClickTimeout;
  30740. private _meshPickProceed;
  30741. private _previousButtonPressed;
  30742. private _currentPickResult;
  30743. private _previousPickResult;
  30744. private _totalPointersPressed;
  30745. private _doubleClickOccured;
  30746. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  30747. cameraToUseForPointers: Nullable<Camera>;
  30748. private _pointerX;
  30749. private _pointerY;
  30750. private _unTranslatedPointerX;
  30751. private _unTranslatedPointerY;
  30752. private _startingPointerPosition;
  30753. private _previousStartingPointerPosition;
  30754. private _startingPointerTime;
  30755. private _previousStartingPointerTime;
  30756. private _pointerCaptures;
  30757. private _timeAccumulator;
  30758. private _currentStepId;
  30759. private _currentInternalStep;
  30760. /** @hidden */ mirroredCameraPosition: Nullable<Vector3>;
  30761. /**
  30762. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  30763. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  30764. */
  30765. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  30766. /**
  30767. * Observable event triggered each time an keyboard event is received from the hosting window
  30768. */
  30769. onKeyboardObservable: Observable<KeyboardInfo>;
  30770. private _onKeyDown;
  30771. private _onKeyUp;
  30772. private _onCanvasFocusObserver;
  30773. private _onCanvasBlurObserver;
  30774. private _useRightHandedSystem;
  30775. /**
  30776. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  30777. */
  30778. useRightHandedSystem: boolean;
  30779. /**
  30780. * Sets the step Id used by deterministic lock step
  30781. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30782. * @param newStepId defines the step Id
  30783. */
  30784. setStepId(newStepId: number): void;
  30785. /**
  30786. * Gets the step Id used by deterministic lock step
  30787. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30788. * @returns the step Id
  30789. */
  30790. getStepId(): number;
  30791. /**
  30792. * Gets the internal step used by deterministic lock step
  30793. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30794. * @returns the internal step
  30795. */
  30796. getInternalStep(): number;
  30797. private _fogEnabled;
  30798. /**
  30799. * Gets or sets a boolean indicating if fog is enabled on this scene
  30800. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30801. * (Default is true)
  30802. */
  30803. fogEnabled: boolean;
  30804. private _fogMode;
  30805. /**
  30806. * Gets or sets the fog mode to use
  30807. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30808. * | mode | value |
  30809. * | --- | --- |
  30810. * | FOGMODE_NONE | 0 |
  30811. * | FOGMODE_EXP | 1 |
  30812. * | FOGMODE_EXP2 | 2 |
  30813. * | FOGMODE_LINEAR | 3 |
  30814. */
  30815. fogMode: number;
  30816. /**
  30817. * Gets or sets the fog color to use
  30818. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30819. * (Default is Color3(0.2, 0.2, 0.3))
  30820. */
  30821. fogColor: Color3;
  30822. /**
  30823. * Gets or sets the fog density to use
  30824. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30825. * (Default is 0.1)
  30826. */
  30827. fogDensity: number;
  30828. /**
  30829. * Gets or sets the fog start distance to use
  30830. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30831. * (Default is 0)
  30832. */
  30833. fogStart: number;
  30834. /**
  30835. * Gets or sets the fog end distance to use
  30836. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30837. * (Default is 1000)
  30838. */
  30839. fogEnd: number;
  30840. private _shadowsEnabled;
  30841. /**
  30842. * Gets or sets a boolean indicating if shadows are enabled on this scene
  30843. */
  30844. shadowsEnabled: boolean;
  30845. private _lightsEnabled;
  30846. /**
  30847. * Gets or sets a boolean indicating if lights are enabled on this scene
  30848. */
  30849. lightsEnabled: boolean;
  30850. /** All of the active cameras added to this scene. */
  30851. activeCameras: Camera[];
  30852. private _activeCamera;
  30853. /** Gets or sets the current active camera */
  30854. activeCamera: Nullable<Camera>;
  30855. private _defaultMaterial;
  30856. /** The default material used on meshes when no material is affected */
  30857. /** The default material used on meshes when no material is affected */
  30858. defaultMaterial: Material;
  30859. private _texturesEnabled;
  30860. /**
  30861. * Gets or sets a boolean indicating if textures are enabled on this scene
  30862. */
  30863. texturesEnabled: boolean;
  30864. /**
  30865. * Gets or sets a boolean indicating if particles are enabled on this scene
  30866. */
  30867. particlesEnabled: boolean;
  30868. /**
  30869. * Gets or sets a boolean indicating if sprites are enabled on this scene
  30870. */
  30871. spritesEnabled: boolean;
  30872. private _skeletonsEnabled;
  30873. /**
  30874. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  30875. */
  30876. skeletonsEnabled: boolean;
  30877. /**
  30878. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  30879. */
  30880. lensFlaresEnabled: boolean;
  30881. /**
  30882. * Gets or sets a boolean indicating if collisions are enabled on this scene
  30883. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  30884. */
  30885. collisionsEnabled: boolean;
  30886. private _collisionCoordinator;
  30887. /** @hidden */
  30888. readonly collisionCoordinator: ICollisionCoordinator;
  30889. /**
  30890. * Defines the gravity applied to this scene (used only for collisions)
  30891. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  30892. */
  30893. gravity: Vector3;
  30894. /**
  30895. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  30896. */
  30897. postProcessesEnabled: boolean;
  30898. /**
  30899. * The list of postprocesses added to the scene
  30900. */
  30901. postProcesses: PostProcess[];
  30902. /**
  30903. * Gets the current postprocess manager
  30904. */
  30905. postProcessManager: PostProcessManager;
  30906. /**
  30907. * Gets or sets a boolean indicating if render targets are enabled on this scene
  30908. */
  30909. renderTargetsEnabled: boolean;
  30910. /**
  30911. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  30912. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  30913. */
  30914. dumpNextRenderTargets: boolean;
  30915. /**
  30916. * The list of user defined render targets added to the scene
  30917. */
  30918. customRenderTargets: RenderTargetTexture[];
  30919. /**
  30920. * Defines if texture loading must be delayed
  30921. * If true, textures will only be loaded when they need to be rendered
  30922. */
  30923. useDelayedTextureLoading: boolean;
  30924. /**
  30925. * Gets the list of meshes imported to the scene through SceneLoader
  30926. */
  30927. importedMeshesFiles: String[];
  30928. /**
  30929. * Gets or sets a boolean indicating if probes are enabled on this scene
  30930. */
  30931. probesEnabled: boolean;
  30932. /**
  30933. * Gets or sets the current offline provider to use to store scene data
  30934. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30935. */
  30936. offlineProvider: IOfflineProvider;
  30937. /**
  30938. * Gets or sets the action manager associated with the scene
  30939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  30940. */
  30941. actionManager: AbstractActionManager;
  30942. private _meshesForIntersections;
  30943. /**
  30944. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  30945. */
  30946. proceduralTexturesEnabled: boolean;
  30947. private _engine;
  30948. private _totalVertices;
  30949. /** @hidden */ activeIndices: PerfCounter;
  30950. /** @hidden */ activeParticles: PerfCounter;
  30951. /** @hidden */ activeBones: PerfCounter;
  30952. private _animationRatio;
  30953. /** @hidden */ animationTimeLast: number;
  30954. /** @hidden */ animationTime: number;
  30955. /**
  30956. * Gets or sets a general scale for animation speed
  30957. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  30958. */
  30959. animationTimeScale: number;
  30960. /** @hidden */ cachedMaterial: Nullable<Material>;
  30961. /** @hidden */ cachedEffect: Nullable<Effect>;
  30962. /** @hidden */ cachedVisibility: Nullable<number>;
  30963. private _renderId;
  30964. private _frameId;
  30965. private _executeWhenReadyTimeoutId;
  30966. private _intermediateRendering;
  30967. private _viewUpdateFlag;
  30968. private _projectionUpdateFlag;
  30969. private _alternateViewUpdateFlag;
  30970. private _alternateProjectionUpdateFlag;
  30971. /** @hidden */ toBeDisposed: Nullable<IDisposable>[];
  30972. private _activeRequests;
  30973. /** @hidden */ pendingData: any[];
  30974. private _isDisposed;
  30975. /**
  30976. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  30977. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  30978. */
  30979. dispatchAllSubMeshesOfActiveMeshes: boolean;
  30980. private _activeMeshes;
  30981. private _processedMaterials;
  30982. private _renderTargets;
  30983. /** @hidden */ activeParticleSystems: SmartArray<IParticleSystem>;
  30984. private _activeSkeletons;
  30985. private _softwareSkinnedMeshes;
  30986. private _renderingManager;
  30987. /** @hidden */ activeAnimatables: Animatable[];
  30988. private _transformMatrix;
  30989. private _sceneUbo;
  30990. private _alternateSceneUbo;
  30991. private _viewMatrix;
  30992. private _projectionMatrix;
  30993. private _alternateViewMatrix;
  30994. private _alternateProjectionMatrix;
  30995. private _alternateTransformMatrix;
  30996. private _useAlternateCameraConfiguration;
  30997. private _alternateRendering;
  30998. private _wheelEventName;
  30999. /** @hidden */ forcedViewPosition: Nullable<Vector3>;
  31000. /** @hidden */ protected readonly _isAlternateRenderingEnabled: boolean;
  31001. private _frustumPlanes;
  31002. /**
  31003. * Gets the list of frustum planes (built from the active camera)
  31004. */
  31005. readonly frustumPlanes: Plane[];
  31006. /**
  31007. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31008. * This is useful if there are more lights that the maximum simulteanous authorized
  31009. */
  31010. requireLightSorting: boolean;
  31011. /** @hidden */
  31012. readonly useMaterialMeshMap: boolean;
  31013. /** @hidden */
  31014. readonly useClonedMeshhMap: boolean;
  31015. private _pointerOverMesh;
  31016. private _pickedDownMesh;
  31017. private _pickedUpMesh;
  31018. private _externalData;
  31019. private _uid;
  31020. /**
  31021. * @hidden
  31022. * Backing store of defined scene components.
  31023. */ components: ISceneComponent[];
  31024. /**
  31025. * @hidden
  31026. * Backing store of defined scene components.
  31027. */ serializableComponents: ISceneSerializableComponent[];
  31028. /**
  31029. * List of components to register on the next registration step.
  31030. */
  31031. private _transientComponents;
  31032. /**
  31033. * Registers the transient components if needed.
  31034. */
  31035. private _registerTransientComponents;
  31036. /**
  31037. * @hidden
  31038. * Add a component to the scene.
  31039. * Note that the ccomponent could be registered on th next frame if this is called after
  31040. * the register component stage.
  31041. * @param component Defines the component to add to the scene
  31042. */ addComponent(component: ISceneComponent): void;
  31043. /**
  31044. * @hidden
  31045. * Gets a component from the scene.
  31046. * @param name defines the name of the component to retrieve
  31047. * @returns the component or null if not present
  31048. */ getComponent(name: string): Nullable<ISceneComponent>;
  31049. /**
  31050. * @hidden
  31051. * Defines the actions happening before camera updates.
  31052. */ beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31053. /**
  31054. * @hidden
  31055. * Defines the actions happening before clear the canvas.
  31056. */ beforeClearStage: Stage<SimpleStageAction>;
  31057. /**
  31058. * @hidden
  31059. * Defines the actions when collecting render targets for the frame.
  31060. */ gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31061. /**
  31062. * @hidden
  31063. * Defines the actions happening for one camera in the frame.
  31064. */ gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31065. /**
  31066. * @hidden
  31067. * Defines the actions happening during the per mesh ready checks.
  31068. */ isReadyForMeshStage: Stage<MeshStageAction>;
  31069. /**
  31070. * @hidden
  31071. * Defines the actions happening before evaluate active mesh checks.
  31072. */ beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31073. /**
  31074. * @hidden
  31075. * Defines the actions happening during the evaluate sub mesh checks.
  31076. */ evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31077. /**
  31078. * @hidden
  31079. * Defines the actions happening during the active mesh stage.
  31080. */ activeMeshStage: Stage<ActiveMeshStageAction>;
  31081. /**
  31082. * @hidden
  31083. * Defines the actions happening during the per camera render target step.
  31084. */ cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  31085. /**
  31086. * @hidden
  31087. * Defines the actions happening just before the active camera is drawing.
  31088. */ beforeCameraDrawStage: Stage<CameraStageAction>;
  31089. /**
  31090. * @hidden
  31091. * Defines the actions happening just before a render target is drawing.
  31092. */ beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31093. /**
  31094. * @hidden
  31095. * Defines the actions happening just before a rendering group is drawing.
  31096. */ beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31097. /**
  31098. * @hidden
  31099. * Defines the actions happening just before a mesh is drawing.
  31100. */ beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31101. /**
  31102. * @hidden
  31103. * Defines the actions happening just after a mesh has been drawn.
  31104. */ afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31105. /**
  31106. * @hidden
  31107. * Defines the actions happening just after a rendering group has been drawn.
  31108. */ afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31109. /**
  31110. * @hidden
  31111. * Defines the actions happening just after the active camera has been drawn.
  31112. */ afterCameraDrawStage: Stage<CameraStageAction>;
  31113. /**
  31114. * @hidden
  31115. * Defines the actions happening just after a render target has been drawn.
  31116. */ afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31117. /**
  31118. * @hidden
  31119. * Defines the actions happening just after rendering all cameras and computing intersections.
  31120. */ afterRenderStage: Stage<SimpleStageAction>;
  31121. /**
  31122. * @hidden
  31123. * Defines the actions happening when a pointer move event happens.
  31124. */ pointerMoveStage: Stage<PointerMoveStageAction>;
  31125. /**
  31126. * @hidden
  31127. * Defines the actions happening when a pointer down event happens.
  31128. */ pointerDownStage: Stage<PointerUpDownStageAction>;
  31129. /**
  31130. * @hidden
  31131. * Defines the actions happening when a pointer up event happens.
  31132. */ pointerUpStage: Stage<PointerUpDownStageAction>;
  31133. /**
  31134. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  31135. */
  31136. private geometriesByUniqueId;
  31137. /**
  31138. * Creates a new Scene
  31139. * @param engine defines the engine to use to render this scene
  31140. * @param options defines the scene options
  31141. */
  31142. constructor(engine: Engine, options?: SceneOptions);
  31143. private _defaultMeshCandidates;
  31144. /**
  31145. * @hidden
  31146. */ getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  31147. private _defaultSubMeshCandidates;
  31148. /**
  31149. * @hidden
  31150. */ getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  31151. /**
  31152. * Sets the default candidate providers for the scene.
  31153. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  31154. * and getCollidingSubMeshCandidates to their default function
  31155. */
  31156. setDefaultCandidateProviders(): void;
  31157. /**
  31158. * Gets the mesh that is currently under the pointer
  31159. */
  31160. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31161. /**
  31162. * Gets or sets the current on-screen X position of the pointer
  31163. */
  31164. pointerX: number;
  31165. /**
  31166. * Gets or sets the current on-screen Y position of the pointer
  31167. */
  31168. pointerY: number;
  31169. /**
  31170. * Gets the cached material (ie. the latest rendered one)
  31171. * @returns the cached material
  31172. */
  31173. getCachedMaterial(): Nullable<Material>;
  31174. /**
  31175. * Gets the cached effect (ie. the latest rendered one)
  31176. * @returns the cached effect
  31177. */
  31178. getCachedEffect(): Nullable<Effect>;
  31179. /**
  31180. * Gets the cached visibility state (ie. the latest rendered one)
  31181. * @returns the cached visibility state
  31182. */
  31183. getCachedVisibility(): Nullable<number>;
  31184. /**
  31185. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  31186. * @param material defines the current material
  31187. * @param effect defines the current effect
  31188. * @param visibility defines the current visibility state
  31189. * @returns true if one parameter is not cached
  31190. */
  31191. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  31192. /**
  31193. * Gets the engine associated with the scene
  31194. * @returns an Engine
  31195. */
  31196. getEngine(): Engine;
  31197. /**
  31198. * Gets the total number of vertices rendered per frame
  31199. * @returns the total number of vertices rendered per frame
  31200. */
  31201. getTotalVertices(): number;
  31202. /**
  31203. * Gets the performance counter for total vertices
  31204. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31205. */
  31206. readonly totalVerticesPerfCounter: PerfCounter;
  31207. /**
  31208. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  31209. * @returns the total number of active indices rendered per frame
  31210. */
  31211. getActiveIndices(): number;
  31212. /**
  31213. * Gets the performance counter for active indices
  31214. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31215. */
  31216. readonly totalActiveIndicesPerfCounter: PerfCounter;
  31217. /**
  31218. * Gets the total number of active particles rendered per frame
  31219. * @returns the total number of active particles rendered per frame
  31220. */
  31221. getActiveParticles(): number;
  31222. /**
  31223. * Gets the performance counter for active particles
  31224. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31225. */
  31226. readonly activeParticlesPerfCounter: PerfCounter;
  31227. /**
  31228. * Gets the total number of active bones rendered per frame
  31229. * @returns the total number of active bones rendered per frame
  31230. */
  31231. getActiveBones(): number;
  31232. /**
  31233. * Gets the performance counter for active bones
  31234. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31235. */
  31236. readonly activeBonesPerfCounter: PerfCounter;
  31237. /**
  31238. * Gets the array of active meshes
  31239. * @returns an array of AbstractMesh
  31240. */
  31241. getActiveMeshes(): SmartArray<AbstractMesh>;
  31242. /**
  31243. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  31244. * @returns a number
  31245. */
  31246. getAnimationRatio(): number;
  31247. /**
  31248. * Gets an unique Id for the current render phase
  31249. * @returns a number
  31250. */
  31251. getRenderId(): number;
  31252. /**
  31253. * Gets an unique Id for the current frame
  31254. * @returns a number
  31255. */
  31256. getFrameId(): number;
  31257. /** Call this function if you want to manually increment the render Id*/
  31258. incrementRenderId(): void;
  31259. private _updatePointerPosition;
  31260. private _createUbo;
  31261. private _createAlternateUbo;
  31262. private _setRayOnPointerInfo;
  31263. /**
  31264. * Use this method to simulate a pointer move on a mesh
  31265. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31266. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31267. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31268. * @returns the current scene
  31269. */
  31270. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31271. private _processPointerMove;
  31272. private _checkPrePointerObservable;
  31273. /**
  31274. * Use this method to simulate a pointer down on a mesh
  31275. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31276. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31277. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31278. * @returns the current scene
  31279. */
  31280. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31281. private _processPointerDown;
  31282. /**
  31283. * Use this method to simulate a pointer up on a mesh
  31284. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31285. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31286. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31287. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31288. * @returns the current scene
  31289. */
  31290. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  31291. private _processPointerUp;
  31292. /**
  31293. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31294. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31295. * @returns true if the pointer was captured
  31296. */
  31297. isPointerCaptured(pointerId?: number): boolean;
  31298. /** @hidden */ isPointerSwiping(): boolean;
  31299. /**
  31300. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31301. * @param attachUp defines if you want to attach events to pointerup
  31302. * @param attachDown defines if you want to attach events to pointerdown
  31303. * @param attachMove defines if you want to attach events to pointermove
  31304. */
  31305. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31306. /** Detaches all event handlers*/
  31307. detachControl(): void;
  31308. /**
  31309. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  31310. * Delay loaded resources are not taking in account
  31311. * @return true if all required resources are ready
  31312. */
  31313. isReady(): boolean;
  31314. /** Resets all cached information relative to material (including effect and visibility) */
  31315. resetCachedMaterial(): void;
  31316. /**
  31317. * Registers a function to be called before every frame render
  31318. * @param func defines the function to register
  31319. */
  31320. registerBeforeRender(func: () => void): void;
  31321. /**
  31322. * Unregisters a function called before every frame render
  31323. * @param func defines the function to unregister
  31324. */
  31325. unregisterBeforeRender(func: () => void): void;
  31326. /**
  31327. * Registers a function to be called after every frame render
  31328. * @param func defines the function to register
  31329. */
  31330. registerAfterRender(func: () => void): void;
  31331. /**
  31332. * Unregisters a function called after every frame render
  31333. * @param func defines the function to unregister
  31334. */
  31335. unregisterAfterRender(func: () => void): void;
  31336. private _executeOnceBeforeRender;
  31337. /**
  31338. * The provided function will run before render once and will be disposed afterwards.
  31339. * A timeout delay can be provided so that the function will be executed in N ms.
  31340. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  31341. * @param func The function to be executed.
  31342. * @param timeout optional delay in ms
  31343. */
  31344. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  31345. /** @hidden */ addPendingData(data: any): void;
  31346. /** @hidden */ removePendingData(data: any): void;
  31347. /**
  31348. * Returns the number of items waiting to be loaded
  31349. * @returns the number of items waiting to be loaded
  31350. */
  31351. getWaitingItemsCount(): number;
  31352. /**
  31353. * Returns a boolean indicating if the scene is still loading data
  31354. */
  31355. readonly isLoading: boolean;
  31356. /**
  31357. * Registers a function to be executed when the scene is ready
  31358. * @param {Function} func - the function to be executed
  31359. */
  31360. executeWhenReady(func: () => void): void;
  31361. /**
  31362. * Returns a promise that resolves when the scene is ready
  31363. * @returns A promise that resolves when the scene is ready
  31364. */
  31365. whenReadyAsync(): Promise<void>;
  31366. /** @hidden */ checkIsReady(): void;
  31367. /**
  31368. * Gets all animatable attached to the scene
  31369. */
  31370. readonly animatables: Animatable[];
  31371. /**
  31372. * Resets the last animation time frame.
  31373. * Useful to override when animations start running when loading a scene for the first time.
  31374. */
  31375. resetLastAnimationTimeFrame(): void;
  31376. /** @hidden */ switchToAlternateCameraConfiguration(active: boolean): void;
  31377. /**
  31378. * Gets the current view matrix
  31379. * @returns a Matrix
  31380. */
  31381. getViewMatrix(): Matrix;
  31382. /**
  31383. * Gets the current projection matrix
  31384. * @returns a Matrix
  31385. */
  31386. getProjectionMatrix(): Matrix;
  31387. /**
  31388. * Gets the current transform matrix
  31389. * @returns a Matrix made of View * Projection
  31390. */
  31391. getTransformMatrix(): Matrix;
  31392. /**
  31393. * Sets the current transform matrix
  31394. * @param view defines the View matrix to use
  31395. * @param projection defines the Projection matrix to use
  31396. */
  31397. setTransformMatrix(view: Matrix, projection: Matrix): void;
  31398. /** @hidden */ setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  31399. /**
  31400. * Gets the uniform buffer used to store scene data
  31401. * @returns a UniformBuffer
  31402. */
  31403. getSceneUniformBuffer(): UniformBuffer;
  31404. /**
  31405. * Gets an unique (relatively to the current scene) Id
  31406. * @returns an unique number for the scene
  31407. */
  31408. getUniqueId(): number;
  31409. /**
  31410. * Add a mesh to the list of scene's meshes
  31411. * @param newMesh defines the mesh to add
  31412. * @param recursive if all child meshes should also be added to the scene
  31413. */
  31414. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  31415. /**
  31416. * Remove a mesh for the list of scene's meshes
  31417. * @param toRemove defines the mesh to remove
  31418. * @param recursive if all child meshes should also be removed from the scene
  31419. * @returns the index where the mesh was in the mesh list
  31420. */
  31421. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  31422. /**
  31423. * Add a transform node to the list of scene's transform nodes
  31424. * @param newTransformNode defines the transform node to add
  31425. */
  31426. addTransformNode(newTransformNode: TransformNode): void;
  31427. /**
  31428. * Remove a transform node for the list of scene's transform nodes
  31429. * @param toRemove defines the transform node to remove
  31430. * @returns the index where the transform node was in the transform node list
  31431. */
  31432. removeTransformNode(toRemove: TransformNode): number;
  31433. /**
  31434. * Remove a skeleton for the list of scene's skeletons
  31435. * @param toRemove defines the skeleton to remove
  31436. * @returns the index where the skeleton was in the skeleton list
  31437. */
  31438. removeSkeleton(toRemove: Skeleton): number;
  31439. /**
  31440. * Remove a morph target for the list of scene's morph targets
  31441. * @param toRemove defines the morph target to remove
  31442. * @returns the index where the morph target was in the morph target list
  31443. */
  31444. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  31445. /**
  31446. * Remove a light for the list of scene's lights
  31447. * @param toRemove defines the light to remove
  31448. * @returns the index where the light was in the light list
  31449. */
  31450. removeLight(toRemove: Light): number;
  31451. /**
  31452. * Remove a camera for the list of scene's cameras
  31453. * @param toRemove defines the camera to remove
  31454. * @returns the index where the camera was in the camera list
  31455. */
  31456. removeCamera(toRemove: Camera): number;
  31457. /**
  31458. * Remove a particle system for the list of scene's particle systems
  31459. * @param toRemove defines the particle system to remove
  31460. * @returns the index where the particle system was in the particle system list
  31461. */
  31462. removeParticleSystem(toRemove: IParticleSystem): number;
  31463. /**
  31464. * Remove a animation for the list of scene's animations
  31465. * @param toRemove defines the animation to remove
  31466. * @returns the index where the animation was in the animation list
  31467. */
  31468. removeAnimation(toRemove: Animation): number;
  31469. /**
  31470. * Removes the given animation group from this scene.
  31471. * @param toRemove The animation group to remove
  31472. * @returns The index of the removed animation group
  31473. */
  31474. removeAnimationGroup(toRemove: AnimationGroup): number;
  31475. /**
  31476. * Removes the given multi-material from this scene.
  31477. * @param toRemove The multi-material to remove
  31478. * @returns The index of the removed multi-material
  31479. */
  31480. removeMultiMaterial(toRemove: MultiMaterial): number;
  31481. /**
  31482. * Removes the given material from this scene.
  31483. * @param toRemove The material to remove
  31484. * @returns The index of the removed material
  31485. */
  31486. removeMaterial(toRemove: Material): number;
  31487. /**
  31488. * Removes the given action manager from this scene.
  31489. * @param toRemove The action manager to remove
  31490. * @returns The index of the removed action manager
  31491. */
  31492. removeActionManager(toRemove: AbstractActionManager): number;
  31493. /**
  31494. * Removes the given texture from this scene.
  31495. * @param toRemove The texture to remove
  31496. * @returns The index of the removed texture
  31497. */
  31498. removeTexture(toRemove: BaseTexture): number;
  31499. /**
  31500. * Adds the given light to this scene
  31501. * @param newLight The light to add
  31502. */
  31503. addLight(newLight: Light): void;
  31504. /**
  31505. * Sorts the list list based on light priorities
  31506. */
  31507. sortLightsByPriority(): void;
  31508. /**
  31509. * Adds the given camera to this scene
  31510. * @param newCamera The camera to add
  31511. */
  31512. addCamera(newCamera: Camera): void;
  31513. /**
  31514. * Adds the given skeleton to this scene
  31515. * @param newSkeleton The skeleton to add
  31516. */
  31517. addSkeleton(newSkeleton: Skeleton): void;
  31518. /**
  31519. * Adds the given particle system to this scene
  31520. * @param newParticleSystem The particle system to add
  31521. */
  31522. addParticleSystem(newParticleSystem: IParticleSystem): void;
  31523. /**
  31524. * Adds the given animation to this scene
  31525. * @param newAnimation The animation to add
  31526. */
  31527. addAnimation(newAnimation: Animation): void;
  31528. /**
  31529. * Adds the given animation group to this scene.
  31530. * @param newAnimationGroup The animation group to add
  31531. */
  31532. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  31533. /**
  31534. * Adds the given multi-material to this scene
  31535. * @param newMultiMaterial The multi-material to add
  31536. */
  31537. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  31538. /**
  31539. * Adds the given material to this scene
  31540. * @param newMaterial The material to add
  31541. */
  31542. addMaterial(newMaterial: Material): void;
  31543. /**
  31544. * Adds the given morph target to this scene
  31545. * @param newMorphTargetManager The morph target to add
  31546. */
  31547. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  31548. /**
  31549. * Adds the given geometry to this scene
  31550. * @param newGeometry The geometry to add
  31551. */
  31552. addGeometry(newGeometry: Geometry): void;
  31553. /**
  31554. * Adds the given action manager to this scene
  31555. * @param newActionManager The action manager to add
  31556. */
  31557. addActionManager(newActionManager: AbstractActionManager): void;
  31558. /**
  31559. * Adds the given texture to this scene.
  31560. * @param newTexture The texture to add
  31561. */
  31562. addTexture(newTexture: BaseTexture): void;
  31563. /**
  31564. * Switch active camera
  31565. * @param newCamera defines the new active camera
  31566. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  31567. */
  31568. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  31569. /**
  31570. * sets the active camera of the scene using its ID
  31571. * @param id defines the camera's ID
  31572. * @return the new active camera or null if none found.
  31573. */
  31574. setActiveCameraByID(id: string): Nullable<Camera>;
  31575. /**
  31576. * sets the active camera of the scene using its name
  31577. * @param name defines the camera's name
  31578. * @returns the new active camera or null if none found.
  31579. */
  31580. setActiveCameraByName(name: string): Nullable<Camera>;
  31581. /**
  31582. * get an animation group using its name
  31583. * @param name defines the material's name
  31584. * @return the animation group or null if none found.
  31585. */
  31586. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  31587. /**
  31588. * get a material using its id
  31589. * @param id defines the material's ID
  31590. * @return the material or null if none found.
  31591. */
  31592. getMaterialByID(id: string): Nullable<Material>;
  31593. /**
  31594. * Gets a material using its name
  31595. * @param name defines the material's name
  31596. * @return the material or null if none found.
  31597. */
  31598. getMaterialByName(name: string): Nullable<Material>;
  31599. /**
  31600. * Gets a camera using its id
  31601. * @param id defines the id to look for
  31602. * @returns the camera or null if not found
  31603. */
  31604. getCameraByID(id: string): Nullable<Camera>;
  31605. /**
  31606. * Gets a camera using its unique id
  31607. * @param uniqueId defines the unique id to look for
  31608. * @returns the camera or null if not found
  31609. */
  31610. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  31611. /**
  31612. * Gets a camera using its name
  31613. * @param name defines the camera's name
  31614. * @return the camera or null if none found.
  31615. */
  31616. getCameraByName(name: string): Nullable<Camera>;
  31617. /**
  31618. * Gets a bone using its id
  31619. * @param id defines the bone's id
  31620. * @return the bone or null if not found
  31621. */
  31622. getBoneByID(id: string): Nullable<Bone>;
  31623. /**
  31624. * Gets a bone using its id
  31625. * @param name defines the bone's name
  31626. * @return the bone or null if not found
  31627. */
  31628. getBoneByName(name: string): Nullable<Bone>;
  31629. /**
  31630. * Gets a light node using its name
  31631. * @param name defines the the light's name
  31632. * @return the light or null if none found.
  31633. */
  31634. getLightByName(name: string): Nullable<Light>;
  31635. /**
  31636. * Gets a light node using its id
  31637. * @param id defines the light's id
  31638. * @return the light or null if none found.
  31639. */
  31640. getLightByID(id: string): Nullable<Light>;
  31641. /**
  31642. * Gets a light node using its scene-generated unique ID
  31643. * @param uniqueId defines the light's unique id
  31644. * @return the light or null if none found.
  31645. */
  31646. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  31647. /**
  31648. * Gets a particle system by id
  31649. * @param id defines the particle system id
  31650. * @return the corresponding system or null if none found
  31651. */
  31652. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  31653. /**
  31654. * Gets a geometry using its ID
  31655. * @param id defines the geometry's id
  31656. * @return the geometry or null if none found.
  31657. */
  31658. getGeometryByID(id: string): Nullable<Geometry>;
  31659. private _getGeometryByUniqueID;
  31660. /**
  31661. * Add a new geometry to this scene
  31662. * @param geometry defines the geometry to be added to the scene.
  31663. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  31664. * @return a boolean defining if the geometry was added or not
  31665. */
  31666. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  31667. /**
  31668. * Removes an existing geometry
  31669. * @param geometry defines the geometry to be removed from the scene
  31670. * @return a boolean defining if the geometry was removed or not
  31671. */
  31672. removeGeometry(geometry: Geometry): boolean;
  31673. /**
  31674. * Gets the list of geometries attached to the scene
  31675. * @returns an array of Geometry
  31676. */
  31677. getGeometries(): Geometry[];
  31678. /**
  31679. * Gets the first added mesh found of a given ID
  31680. * @param id defines the id to search for
  31681. * @return the mesh found or null if not found at all
  31682. */
  31683. getMeshByID(id: string): Nullable<AbstractMesh>;
  31684. /**
  31685. * Gets a list of meshes using their id
  31686. * @param id defines the id to search for
  31687. * @returns a list of meshes
  31688. */
  31689. getMeshesByID(id: string): Array<AbstractMesh>;
  31690. /**
  31691. * Gets the first added transform node found of a given ID
  31692. * @param id defines the id to search for
  31693. * @return the found transform node or null if not found at all.
  31694. */
  31695. getTransformNodeByID(id: string): Nullable<TransformNode>;
  31696. /**
  31697. * Gets a list of transform nodes using their id
  31698. * @param id defines the id to search for
  31699. * @returns a list of transform nodes
  31700. */
  31701. getTransformNodesByID(id: string): Array<TransformNode>;
  31702. /**
  31703. * Gets a mesh with its auto-generated unique id
  31704. * @param uniqueId defines the unique id to search for
  31705. * @return the found mesh or null if not found at all.
  31706. */
  31707. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  31708. /**
  31709. * Gets a the last added mesh using a given id
  31710. * @param id defines the id to search for
  31711. * @return the found mesh or null if not found at all.
  31712. */
  31713. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  31714. /**
  31715. * Gets a the last added node (Mesh, Camera, Light) using a given id
  31716. * @param id defines the id to search for
  31717. * @return the found node or null if not found at all
  31718. */
  31719. getLastEntryByID(id: string): Nullable<Node>;
  31720. /**
  31721. * Gets a node (Mesh, Camera, Light) using a given id
  31722. * @param id defines the id to search for
  31723. * @return the found node or null if not found at all
  31724. */
  31725. getNodeByID(id: string): Nullable<Node>;
  31726. /**
  31727. * Gets a node (Mesh, Camera, Light) using a given name
  31728. * @param name defines the name to search for
  31729. * @return the found node or null if not found at all.
  31730. */
  31731. getNodeByName(name: string): Nullable<Node>;
  31732. /**
  31733. * Gets a mesh using a given name
  31734. * @param name defines the name to search for
  31735. * @return the found mesh or null if not found at all.
  31736. */
  31737. getMeshByName(name: string): Nullable<AbstractMesh>;
  31738. /**
  31739. * Gets a transform node using a given name
  31740. * @param name defines the name to search for
  31741. * @return the found transform node or null if not found at all.
  31742. */
  31743. getTransformNodeByName(name: string): Nullable<TransformNode>;
  31744. /**
  31745. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  31746. * @param id defines the id to search for
  31747. * @return the found skeleton or null if not found at all.
  31748. */
  31749. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  31750. /**
  31751. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  31752. * @param id defines the id to search for
  31753. * @return the found skeleton or null if not found at all.
  31754. */
  31755. getSkeletonById(id: string): Nullable<Skeleton>;
  31756. /**
  31757. * Gets a skeleton using a given name
  31758. * @param name defines the name to search for
  31759. * @return the found skeleton or null if not found at all.
  31760. */
  31761. getSkeletonByName(name: string): Nullable<Skeleton>;
  31762. /**
  31763. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  31764. * @param id defines the id to search for
  31765. * @return the found morph target manager or null if not found at all.
  31766. */
  31767. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  31768. /**
  31769. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  31770. * @param id defines the id to search for
  31771. * @return the found morph target or null if not found at all.
  31772. */
  31773. getMorphTargetById(id: string): Nullable<MorphTarget>;
  31774. /**
  31775. * Gets a boolean indicating if the given mesh is active
  31776. * @param mesh defines the mesh to look for
  31777. * @returns true if the mesh is in the active list
  31778. */
  31779. isActiveMesh(mesh: AbstractMesh): boolean;
  31780. /**
  31781. * Return a unique id as a string which can serve as an identifier for the scene
  31782. */
  31783. readonly uid: string;
  31784. /**
  31785. * Add an externaly attached data from its key.
  31786. * This method call will fail and return false, if such key already exists.
  31787. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31788. * @param key the unique key that identifies the data
  31789. * @param data the data object to associate to the key for this Engine instance
  31790. * @return true if no such key were already present and the data was added successfully, false otherwise
  31791. */
  31792. addExternalData<T>(key: string, data: T): boolean;
  31793. /**
  31794. * Get an externaly attached data from its key
  31795. * @param key the unique key that identifies the data
  31796. * @return the associated data, if present (can be null), or undefined if not present
  31797. */
  31798. getExternalData<T>(key: string): Nullable<T>;
  31799. /**
  31800. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31801. * @param key the unique key that identifies the data
  31802. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31803. * @return the associated data, can be null if the factory returned null.
  31804. */
  31805. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31806. /**
  31807. * Remove an externaly attached data from the Engine instance
  31808. * @param key the unique key that identifies the data
  31809. * @return true if the data was successfully removed, false if it doesn't exist
  31810. */
  31811. removeExternalData(key: string): boolean;
  31812. private _evaluateSubMesh;
  31813. /**
  31814. * Clear the processed materials smart array preventing retention point in material dispose.
  31815. */
  31816. freeProcessedMaterials(): void;
  31817. private _preventFreeActiveMeshesAndRenderingGroups;
  31818. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  31819. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  31820. * when disposing several meshes in a row or a hierarchy of meshes.
  31821. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  31822. */
  31823. blockfreeActiveMeshesAndRenderingGroups: boolean;
  31824. /**
  31825. * Clear the active meshes smart array preventing retention point in mesh dispose.
  31826. */
  31827. freeActiveMeshes(): void;
  31828. /**
  31829. * Clear the info related to rendering groups preventing retention points during dispose.
  31830. */
  31831. freeRenderingGroups(): void;
  31832. /** @hidden */ isInIntermediateRendering(): boolean;
  31833. /**
  31834. * Lambda returning the list of potentially active meshes.
  31835. */
  31836. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  31837. /**
  31838. * Lambda returning the list of potentially active sub meshes.
  31839. */
  31840. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  31841. /**
  31842. * Lambda returning the list of potentially intersecting sub meshes.
  31843. */
  31844. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  31845. /**
  31846. * Lambda returning the list of potentially colliding sub meshes.
  31847. */
  31848. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  31849. private _activeMeshesFrozen;
  31850. /**
  31851. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  31852. * @returns the current scene
  31853. */
  31854. freezeActiveMeshes(): Scene;
  31855. /**
  31856. * Use this function to restart evaluating active meshes on every frame
  31857. * @returns the current scene
  31858. */
  31859. unfreezeActiveMeshes(): Scene;
  31860. private _evaluateActiveMeshes;
  31861. private _activeMesh;
  31862. /**
  31863. * Update the transform matrix to update from the current active camera
  31864. * @param force defines a boolean used to force the update even if cache is up to date
  31865. */
  31866. updateTransformMatrix(force?: boolean): void;
  31867. /**
  31868. * 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)
  31869. * @param alternateCamera defines the camera to use
  31870. */
  31871. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  31872. /** @hidden */ allowPostProcessClearColor: boolean;
  31873. private _renderForCamera;
  31874. private _processSubCameras;
  31875. private _checkIntersections;
  31876. /** @hidden */ advancePhysicsEngineStep(step: number): void;
  31877. /**
  31878. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  31879. */
  31880. getDeterministicFrameTime: () => number;
  31881. /** @hidden */ animate(): void;
  31882. /**
  31883. * Render the scene
  31884. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  31885. */
  31886. render(updateCameras?: boolean): void;
  31887. /**
  31888. * Freeze all materials
  31889. * A frozen material will not be updatable but should be faster to render
  31890. */
  31891. freezeMaterials(): void;
  31892. /**
  31893. * Unfreeze all materials
  31894. * A frozen material will not be updatable but should be faster to render
  31895. */
  31896. unfreezeMaterials(): void;
  31897. /**
  31898. * Releases all held ressources
  31899. */
  31900. dispose(): void;
  31901. /**
  31902. * Gets if the scene is already disposed
  31903. */
  31904. readonly isDisposed: boolean;
  31905. /**
  31906. * Call this function to reduce memory footprint of the scene.
  31907. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  31908. */
  31909. clearCachedVertexData(): void;
  31910. /**
  31911. * This function will remove the local cached buffer data from texture.
  31912. * It will save memory but will prevent the texture from being rebuilt
  31913. */
  31914. cleanCachedTextureBuffer(): void;
  31915. /**
  31916. * Get the world extend vectors with an optional filter
  31917. *
  31918. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  31919. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  31920. */
  31921. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  31922. min: Vector3;
  31923. max: Vector3;
  31924. };
  31925. /**
  31926. * Creates a ray that can be used to pick in the scene
  31927. * @param x defines the x coordinate of the origin (on-screen)
  31928. * @param y defines the y coordinate of the origin (on-screen)
  31929. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  31930. * @param camera defines the camera to use for the picking
  31931. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  31932. * @returns a Ray
  31933. */
  31934. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  31935. /**
  31936. * Creates a ray that can be used to pick in the scene
  31937. * @param x defines the x coordinate of the origin (on-screen)
  31938. * @param y defines the y coordinate of the origin (on-screen)
  31939. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  31940. * @param result defines the ray where to store the picking ray
  31941. * @param camera defines the camera to use for the picking
  31942. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  31943. * @returns the current scene
  31944. */
  31945. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  31946. /**
  31947. * Creates a ray that can be used to pick in the scene
  31948. * @param x defines the x coordinate of the origin (on-screen)
  31949. * @param y defines the y coordinate of the origin (on-screen)
  31950. * @param camera defines the camera to use for the picking
  31951. * @returns a Ray
  31952. */
  31953. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  31954. /**
  31955. * Creates a ray that can be used to pick in the scene
  31956. * @param x defines the x coordinate of the origin (on-screen)
  31957. * @param y defines the y coordinate of the origin (on-screen)
  31958. * @param result defines the ray where to store the picking ray
  31959. * @param camera defines the camera to use for the picking
  31960. * @returns the current scene
  31961. */
  31962. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  31963. /** Launch a ray to try to pick a mesh in the scene
  31964. * @param x position on screen
  31965. * @param y position on screen
  31966. * @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
  31967. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  31968. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  31969. * @returns a PickingInfo
  31970. */
  31971. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  31972. /** Use the given ray to pick a mesh in the scene
  31973. * @param ray The ray to use to pick meshes
  31974. * @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
  31975. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  31976. * @returns a PickingInfo
  31977. */
  31978. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  31979. /**
  31980. * Launch a ray to try to pick a mesh in the scene
  31981. * @param x X position on screen
  31982. * @param y Y position on screen
  31983. * @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
  31984. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  31985. * @returns an array of PickingInfo
  31986. */
  31987. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  31988. /**
  31989. * Launch a ray to try to pick a mesh in the scene
  31990. * @param ray Ray to use
  31991. * @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
  31992. * @returns an array of PickingInfo
  31993. */
  31994. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  31995. /**
  31996. * Force the value of meshUnderPointer
  31997. * @param mesh defines the mesh to use
  31998. */
  31999. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32000. /**
  32001. * Gets the mesh under the pointer
  32002. * @returns a Mesh or null if no mesh is under the pointer
  32003. */
  32004. getPointerOverMesh(): Nullable<AbstractMesh>;
  32005. /** @hidden */ rebuildGeometries(): void;
  32006. /** @hidden */ rebuildTextures(): void;
  32007. private _getByTags;
  32008. /**
  32009. * Get a list of meshes by tags
  32010. * @param tagsQuery defines the tags query to use
  32011. * @param forEach defines a predicate used to filter results
  32012. * @returns an array of Mesh
  32013. */
  32014. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32015. /**
  32016. * Get a list of cameras by tags
  32017. * @param tagsQuery defines the tags query to use
  32018. * @param forEach defines a predicate used to filter results
  32019. * @returns an array of Camera
  32020. */
  32021. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32022. /**
  32023. * Get a list of lights by tags
  32024. * @param tagsQuery defines the tags query to use
  32025. * @param forEach defines a predicate used to filter results
  32026. * @returns an array of Light
  32027. */
  32028. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32029. /**
  32030. * Get a list of materials by tags
  32031. * @param tagsQuery defines the tags query to use
  32032. * @param forEach defines a predicate used to filter results
  32033. * @returns an array of Material
  32034. */
  32035. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32036. /**
  32037. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32038. * This allowed control for front to back rendering or reversly depending of the special needs.
  32039. *
  32040. * @param renderingGroupId The rendering group id corresponding to its index
  32041. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32042. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32043. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32044. */
  32045. 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;
  32046. /**
  32047. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32048. *
  32049. * @param renderingGroupId The rendering group id corresponding to its index
  32050. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32051. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32052. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32053. */
  32054. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32055. /**
  32056. * Gets the current auto clear configuration for one rendering group of the rendering
  32057. * manager.
  32058. * @param index the rendering group index to get the information for
  32059. * @returns The auto clear setup for the requested rendering group
  32060. */
  32061. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32062. private _blockMaterialDirtyMechanism;
  32063. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32064. blockMaterialDirtyMechanism: boolean;
  32065. /**
  32066. * Will flag all materials as dirty to trigger new shader compilation
  32067. * @param flag defines the flag used to specify which material part must be marked as dirty
  32068. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  32069. */
  32070. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32071. /** @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;
  32072. /** @hidden */ loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32073. }
  32074. }
  32075. declare module BABYLON {
  32076. /**
  32077. * Set of assets to keep when moving a scene into an asset container.
  32078. */
  32079. export class KeepAssets extends AbstractScene {
  32080. }
  32081. /**
  32082. * Container with a set of assets that can be added or removed from a scene.
  32083. */
  32084. export class AssetContainer extends AbstractScene {
  32085. /**
  32086. * The scene the AssetContainer belongs to.
  32087. */
  32088. scene: Scene;
  32089. /**
  32090. * Instantiates an AssetContainer.
  32091. * @param scene The scene the AssetContainer belongs to.
  32092. */
  32093. constructor(scene: Scene);
  32094. /**
  32095. * Adds all the assets from the container to the scene.
  32096. */
  32097. addAllToScene(): void;
  32098. /**
  32099. * Removes all the assets in the container from the scene
  32100. */
  32101. removeAllFromScene(): void;
  32102. /**
  32103. * Disposes all the assets in the container
  32104. */
  32105. dispose(): void;
  32106. private _moveAssets;
  32107. /**
  32108. * Removes all the assets contained in the scene and adds them to the container.
  32109. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  32110. */
  32111. moveAllFromScene(keepAssets?: KeepAssets): void;
  32112. /**
  32113. * 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.
  32114. * @returns the root mesh
  32115. */
  32116. createRootMesh(): Mesh;
  32117. }
  32118. }
  32119. declare module BABYLON {
  32120. /**
  32121. * Defines how the parser contract is defined.
  32122. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  32123. */
  32124. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  32125. /**
  32126. * Defines how the individual parser contract is defined.
  32127. * These parser can parse an individual asset
  32128. */
  32129. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  32130. /**
  32131. * Base class of the scene acting as a container for the different elements composing a scene.
  32132. * This class is dynamically extended by the different components of the scene increasing
  32133. * flexibility and reducing coupling
  32134. */
  32135. export abstract class AbstractScene {
  32136. /**
  32137. * Stores the list of available parsers in the application.
  32138. */
  32139. private static _BabylonFileParsers;
  32140. /**
  32141. * Stores the list of available individual parsers in the application.
  32142. */
  32143. private static _IndividualBabylonFileParsers;
  32144. /**
  32145. * Adds a parser in the list of available ones
  32146. * @param name Defines the name of the parser
  32147. * @param parser Defines the parser to add
  32148. */
  32149. static AddParser(name: string, parser: BabylonFileParser): void;
  32150. /**
  32151. * Gets a general parser from the list of avaialble ones
  32152. * @param name Defines the name of the parser
  32153. * @returns the requested parser or null
  32154. */
  32155. static GetParser(name: string): Nullable<BabylonFileParser>;
  32156. /**
  32157. * Adds n individual parser in the list of available ones
  32158. * @param name Defines the name of the parser
  32159. * @param parser Defines the parser to add
  32160. */
  32161. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  32162. /**
  32163. * Gets an individual parser from the list of avaialble ones
  32164. * @param name Defines the name of the parser
  32165. * @returns the requested parser or null
  32166. */
  32167. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  32168. /**
  32169. * Parser json data and populate both a scene and its associated container object
  32170. * @param jsonData Defines the data to parse
  32171. * @param scene Defines the scene to parse the data for
  32172. * @param container Defines the container attached to the parsing sequence
  32173. * @param rootUrl Defines the root url of the data
  32174. */
  32175. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  32176. /**
  32177. * Gets the list of root nodes (ie. nodes with no parent)
  32178. */
  32179. rootNodes: Node[];
  32180. /** All of the cameras added to this scene
  32181. * @see http://doc.babylonjs.com/babylon101/cameras
  32182. */
  32183. cameras: Camera[];
  32184. /**
  32185. * All of the lights added to this scene
  32186. * @see http://doc.babylonjs.com/babylon101/lights
  32187. */
  32188. lights: Light[];
  32189. /**
  32190. * All of the (abstract) meshes added to this scene
  32191. */
  32192. meshes: AbstractMesh[];
  32193. /**
  32194. * The list of skeletons added to the scene
  32195. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32196. */
  32197. skeletons: Skeleton[];
  32198. /**
  32199. * All of the particle systems added to this scene
  32200. * @see http://doc.babylonjs.com/babylon101/particles
  32201. */
  32202. particleSystems: IParticleSystem[];
  32203. /**
  32204. * Gets a list of Animations associated with the scene
  32205. */
  32206. animations: Animation[];
  32207. /**
  32208. * All of the animation groups added to this scene
  32209. * @see http://doc.babylonjs.com/how_to/group
  32210. */
  32211. animationGroups: AnimationGroup[];
  32212. /**
  32213. * All of the multi-materials added to this scene
  32214. * @see http://doc.babylonjs.com/how_to/multi_materials
  32215. */
  32216. multiMaterials: MultiMaterial[];
  32217. /**
  32218. * All of the materials added to this scene
  32219. * In the context of a Scene, it is not supposed to be modified manually.
  32220. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  32221. * Note also that the order of the Material wihin the array is not significant and might change.
  32222. * @see http://doc.babylonjs.com/babylon101/materials
  32223. */
  32224. materials: Material[];
  32225. /**
  32226. * The list of morph target managers added to the scene
  32227. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  32228. */
  32229. morphTargetManagers: MorphTargetManager[];
  32230. /**
  32231. * The list of geometries used in the scene.
  32232. */
  32233. geometries: Geometry[];
  32234. /**
  32235. * All of the tranform nodes added to this scene
  32236. * In the context of a Scene, it is not supposed to be modified manually.
  32237. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  32238. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  32239. * @see http://doc.babylonjs.com/how_to/transformnode
  32240. */
  32241. transformNodes: TransformNode[];
  32242. /**
  32243. * ActionManagers available on the scene.
  32244. */
  32245. actionManagers: AbstractActionManager[];
  32246. /**
  32247. * Textures to keep.
  32248. */
  32249. textures: BaseTexture[];
  32250. }
  32251. }
  32252. declare module BABYLON {
  32253. /**
  32254. * Defines a sound that can be played in the application.
  32255. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  32256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32257. */
  32258. export class Sound {
  32259. /**
  32260. * The name of the sound in the scene.
  32261. */
  32262. name: string;
  32263. /**
  32264. * Does the sound autoplay once loaded.
  32265. */
  32266. autoplay: boolean;
  32267. /**
  32268. * Does the sound loop after it finishes playing once.
  32269. */
  32270. loop: boolean;
  32271. /**
  32272. * Does the sound use a custom attenuation curve to simulate the falloff
  32273. * happening when the source gets further away from the camera.
  32274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  32275. */
  32276. useCustomAttenuation: boolean;
  32277. /**
  32278. * The sound track id this sound belongs to.
  32279. */
  32280. soundTrackId: number;
  32281. /**
  32282. * Is this sound currently played.
  32283. */
  32284. isPlaying: boolean;
  32285. /**
  32286. * Is this sound currently paused.
  32287. */
  32288. isPaused: boolean;
  32289. /**
  32290. * Does this sound enables spatial sound.
  32291. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32292. */
  32293. spatialSound: boolean;
  32294. /**
  32295. * Define the reference distance the sound should be heard perfectly.
  32296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32297. */
  32298. refDistance: number;
  32299. /**
  32300. * Define the roll off factor of spatial sounds.
  32301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32302. */
  32303. rolloffFactor: number;
  32304. /**
  32305. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  32306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32307. */
  32308. maxDistance: number;
  32309. /**
  32310. * Define the distance attenuation model the sound will follow.
  32311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32312. */
  32313. distanceModel: string;
  32314. /**
  32315. * @hidden
  32316. * Back Compat
  32317. **/
  32318. onended: () => any;
  32319. /**
  32320. * Observable event when the current playing sound finishes.
  32321. */
  32322. onEndedObservable: Observable<Sound>;
  32323. private _panningModel;
  32324. private _playbackRate;
  32325. private _streaming;
  32326. private _startTime;
  32327. private _startOffset;
  32328. private _position;
  32329. /** @hidden */ positionInEmitterSpace: boolean;
  32330. private _localDirection;
  32331. private _volume;
  32332. private _isReadyToPlay;
  32333. private _isDirectional;
  32334. private _readyToPlayCallback;
  32335. private _audioBuffer;
  32336. private _soundSource;
  32337. private _streamingSource;
  32338. private _soundPanner;
  32339. private _soundGain;
  32340. private _inputAudioNode;
  32341. private _outputAudioNode;
  32342. private _coneInnerAngle;
  32343. private _coneOuterAngle;
  32344. private _coneOuterGain;
  32345. private _scene;
  32346. private _connectedTransformNode;
  32347. private _customAttenuationFunction;
  32348. private _registerFunc;
  32349. private _isOutputConnected;
  32350. private _htmlAudioElement;
  32351. private _urlType;
  32352. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  32353. /**
  32354. * Create a sound and attach it to a scene
  32355. * @param name Name of your sound
  32356. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  32357. * @param scene defines the scene the sound belongs to
  32358. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  32359. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  32360. */
  32361. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  32362. /**
  32363. * Release the sound and its associated resources
  32364. */
  32365. dispose(): void;
  32366. /**
  32367. * Gets if the sounds is ready to be played or not.
  32368. * @returns true if ready, otherwise false
  32369. */
  32370. isReady(): boolean;
  32371. private _soundLoaded;
  32372. /**
  32373. * Sets the data of the sound from an audiobuffer
  32374. * @param audioBuffer The audioBuffer containing the data
  32375. */
  32376. setAudioBuffer(audioBuffer: AudioBuffer): void;
  32377. /**
  32378. * Updates the current sounds options such as maxdistance, loop...
  32379. * @param options A JSON object containing values named as the object properties
  32380. */
  32381. updateOptions(options: any): void;
  32382. private _createSpatialParameters;
  32383. private _updateSpatialParameters;
  32384. /**
  32385. * Switch the panning model to HRTF:
  32386. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  32387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32388. */
  32389. switchPanningModelToHRTF(): void;
  32390. /**
  32391. * Switch the panning model to Equal Power:
  32392. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  32393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32394. */
  32395. switchPanningModelToEqualPower(): void;
  32396. private _switchPanningModel;
  32397. /**
  32398. * Connect this sound to a sound track audio node like gain...
  32399. * @param soundTrackAudioNode the sound track audio node to connect to
  32400. */
  32401. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  32402. /**
  32403. * Transform this sound into a directional source
  32404. * @param coneInnerAngle Size of the inner cone in degree
  32405. * @param coneOuterAngle Size of the outer cone in degree
  32406. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  32407. */
  32408. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  32409. /**
  32410. * Gets or sets the inner angle for the directional cone.
  32411. */
  32412. /**
  32413. * Gets or sets the inner angle for the directional cone.
  32414. */
  32415. directionalConeInnerAngle: number;
  32416. /**
  32417. * Gets or sets the outer angle for the directional cone.
  32418. */
  32419. /**
  32420. * Gets or sets the outer angle for the directional cone.
  32421. */
  32422. directionalConeOuterAngle: number;
  32423. /**
  32424. * Sets the position of the emitter if spatial sound is enabled
  32425. * @param newPosition Defines the new posisiton
  32426. */
  32427. setPosition(newPosition: Vector3): void;
  32428. /**
  32429. * Sets the local direction of the emitter if spatial sound is enabled
  32430. * @param newLocalDirection Defines the new local direction
  32431. */
  32432. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  32433. private _updateDirection;
  32434. /** @hidden */
  32435. updateDistanceFromListener(): void;
  32436. /**
  32437. * Sets a new custom attenuation function for the sound.
  32438. * @param callback Defines the function used for the attenuation
  32439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  32440. */
  32441. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  32442. /**
  32443. * Play the sound
  32444. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  32445. * @param offset (optional) Start the sound setting it at a specific time
  32446. */
  32447. play(time?: number, offset?: number): void;
  32448. private _onended;
  32449. /**
  32450. * Stop the sound
  32451. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  32452. */
  32453. stop(time?: number): void;
  32454. /**
  32455. * Put the sound in pause
  32456. */
  32457. pause(): void;
  32458. /**
  32459. * Sets a dedicated volume for this sounds
  32460. * @param newVolume Define the new volume of the sound
  32461. * @param time Define in how long the sound should be at this value
  32462. */
  32463. setVolume(newVolume: number, time?: number): void;
  32464. /**
  32465. * Set the sound play back rate
  32466. * @param newPlaybackRate Define the playback rate the sound should be played at
  32467. */
  32468. setPlaybackRate(newPlaybackRate: number): void;
  32469. /**
  32470. * Gets the volume of the sound.
  32471. * @returns the volume of the sound
  32472. */
  32473. getVolume(): number;
  32474. /**
  32475. * Attach the sound to a dedicated mesh
  32476. * @param transformNode The transform node to connect the sound with
  32477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  32478. */
  32479. attachToMesh(transformNode: TransformNode): void;
  32480. /**
  32481. * Detach the sound from the previously attached mesh
  32482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  32483. */
  32484. detachFromMesh(): void;
  32485. private _onRegisterAfterWorldMatrixUpdate;
  32486. /**
  32487. * Clone the current sound in the scene.
  32488. * @returns the new sound clone
  32489. */
  32490. clone(): Nullable<Sound>;
  32491. /**
  32492. * Gets the current underlying audio buffer containing the data
  32493. * @returns the audio buffer
  32494. */
  32495. getAudioBuffer(): Nullable<AudioBuffer>;
  32496. /**
  32497. * Serializes the Sound in a JSON representation
  32498. * @returns the JSON representation of the sound
  32499. */
  32500. serialize(): any;
  32501. /**
  32502. * Parse a JSON representation of a sound to innstantiate in a given scene
  32503. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  32504. * @param scene Define the scene the new parsed sound should be created in
  32505. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  32506. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  32507. * @returns the newly parsed sound
  32508. */
  32509. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  32510. }
  32511. }
  32512. declare module BABYLON {
  32513. /**
  32514. * This defines an action helpful to play a defined sound on a triggered action.
  32515. */
  32516. export class PlaySoundAction extends Action {
  32517. private _sound;
  32518. /**
  32519. * Instantiate the action
  32520. * @param triggerOptions defines the trigger options
  32521. * @param sound defines the sound to play
  32522. * @param condition defines the trigger related conditions
  32523. */
  32524. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  32525. /** @hidden */ prepare(): void;
  32526. /**
  32527. * Execute the action and play the sound.
  32528. */
  32529. execute(): void;
  32530. /**
  32531. * Serializes the actions and its related information.
  32532. * @param parent defines the object to serialize in
  32533. * @returns the serialized object
  32534. */
  32535. serialize(parent: any): any;
  32536. }
  32537. /**
  32538. * This defines an action helpful to stop a defined sound on a triggered action.
  32539. */
  32540. export class StopSoundAction extends Action {
  32541. private _sound;
  32542. /**
  32543. * Instantiate the action
  32544. * @param triggerOptions defines the trigger options
  32545. * @param sound defines the sound to stop
  32546. * @param condition defines the trigger related conditions
  32547. */
  32548. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  32549. /** @hidden */ prepare(): void;
  32550. /**
  32551. * Execute the action and stop the sound.
  32552. */
  32553. execute(): void;
  32554. /**
  32555. * Serializes the actions and its related information.
  32556. * @param parent defines the object to serialize in
  32557. * @returns the serialized object
  32558. */
  32559. serialize(parent: any): any;
  32560. }
  32561. }
  32562. declare module BABYLON {
  32563. /**
  32564. * This defines an action responsible to change the value of a property
  32565. * by interpolating between its current value and the newly set one once triggered.
  32566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32567. */
  32568. export class InterpolateValueAction extends Action {
  32569. /**
  32570. * Defines the path of the property where the value should be interpolated
  32571. */
  32572. propertyPath: string;
  32573. /**
  32574. * Defines the target value at the end of the interpolation.
  32575. */
  32576. value: any;
  32577. /**
  32578. * Defines the time it will take for the property to interpolate to the value.
  32579. */
  32580. duration: number;
  32581. /**
  32582. * Defines if the other scene animations should be stopped when the action has been triggered
  32583. */
  32584. stopOtherAnimations?: boolean;
  32585. /**
  32586. * Defines a callback raised once the interpolation animation has been done.
  32587. */
  32588. onInterpolationDone?: () => void;
  32589. /**
  32590. * Observable triggered once the interpolation animation has been done.
  32591. */
  32592. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  32593. private _target;
  32594. private _effectiveTarget;
  32595. private _property;
  32596. /**
  32597. * Instantiate the action
  32598. * @param triggerOptions defines the trigger options
  32599. * @param target defines the object containing the value to interpolate
  32600. * @param propertyPath defines the path to the property in the target object
  32601. * @param value defines the target value at the end of the interpolation
  32602. * @param duration deines the time it will take for the property to interpolate to the value.
  32603. * @param condition defines the trigger related conditions
  32604. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  32605. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  32606. */
  32607. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  32608. /** @hidden */ prepare(): void;
  32609. /**
  32610. * Execute the action starts the value interpolation.
  32611. */
  32612. execute(): void;
  32613. /**
  32614. * Serializes the actions and its related information.
  32615. * @param parent defines the object to serialize in
  32616. * @returns the serialized object
  32617. */
  32618. serialize(parent: any): any;
  32619. }
  32620. }
  32621. declare module BABYLON {
  32622. /**
  32623. * Options allowed during the creation of a sound track.
  32624. */
  32625. export interface ISoundTrackOptions {
  32626. /**
  32627. * The volume the sound track should take during creation
  32628. */
  32629. volume?: number;
  32630. /**
  32631. * Define if the sound track is the main sound track of the scene
  32632. */
  32633. mainTrack?: boolean;
  32634. }
  32635. /**
  32636. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  32637. * It will be also used in a future release to apply effects on a specific track.
  32638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  32639. */
  32640. export class SoundTrack {
  32641. /**
  32642. * The unique identifier of the sound track in the scene.
  32643. */
  32644. id: number;
  32645. /**
  32646. * The list of sounds included in the sound track.
  32647. */
  32648. soundCollection: Array<Sound>;
  32649. private _outputAudioNode;
  32650. private _scene;
  32651. private _isMainTrack;
  32652. private _connectedAnalyser;
  32653. private _options;
  32654. private _isInitialized;
  32655. /**
  32656. * Creates a new sound track.
  32657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  32658. * @param scene Define the scene the sound track belongs to
  32659. * @param options
  32660. */
  32661. constructor(scene: Scene, options?: ISoundTrackOptions);
  32662. private _initializeSoundTrackAudioGraph;
  32663. /**
  32664. * Release the sound track and its associated resources
  32665. */
  32666. dispose(): void;
  32667. /**
  32668. * Adds a sound to this sound track
  32669. * @param sound define the cound to add
  32670. * @ignoreNaming
  32671. */
  32672. AddSound(sound: Sound): void;
  32673. /**
  32674. * Removes a sound to this sound track
  32675. * @param sound define the cound to remove
  32676. * @ignoreNaming
  32677. */
  32678. RemoveSound(sound: Sound): void;
  32679. /**
  32680. * Set a global volume for the full sound track.
  32681. * @param newVolume Define the new volume of the sound track
  32682. */
  32683. setVolume(newVolume: number): void;
  32684. /**
  32685. * Switch the panning model to HRTF:
  32686. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  32687. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32688. */
  32689. switchPanningModelToHRTF(): void;
  32690. /**
  32691. * Switch the panning model to Equal Power:
  32692. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  32693. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32694. */
  32695. switchPanningModelToEqualPower(): void;
  32696. /**
  32697. * Connect the sound track to an audio analyser allowing some amazing
  32698. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32700. * @param analyser The analyser to connect to the engine
  32701. */
  32702. connectToAnalyser(analyser: Analyser): void;
  32703. }
  32704. }
  32705. declare module BABYLON {
  32706. interface AbstractScene {
  32707. /**
  32708. * The list of sounds used in the scene.
  32709. */
  32710. sounds: Nullable<Array<Sound>>;
  32711. }
  32712. interface Scene {
  32713. /**
  32714. * @hidden
  32715. * Backing field
  32716. */ mainSoundTrack: SoundTrack;
  32717. /**
  32718. * The main sound track played by the scene.
  32719. * It cotains your primary collection of sounds.
  32720. */
  32721. mainSoundTrack: SoundTrack;
  32722. /**
  32723. * The list of sound tracks added to the scene
  32724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32725. */
  32726. soundTracks: Nullable<Array<SoundTrack>>;
  32727. /**
  32728. * Gets a sound using a given name
  32729. * @param name defines the name to search for
  32730. * @return the found sound or null if not found at all.
  32731. */
  32732. getSoundByName(name: string): Nullable<Sound>;
  32733. /**
  32734. * Gets or sets if audio support is enabled
  32735. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32736. */
  32737. audioEnabled: boolean;
  32738. /**
  32739. * Gets or sets if audio will be output to headphones
  32740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32741. */
  32742. headphone: boolean;
  32743. }
  32744. /**
  32745. * Defines the sound scene component responsible to manage any sounds
  32746. * in a given scene.
  32747. */
  32748. export class AudioSceneComponent implements ISceneSerializableComponent {
  32749. /**
  32750. * The component name helpfull to identify the component in the list of scene components.
  32751. */
  32752. readonly name: string;
  32753. /**
  32754. * The scene the component belongs to.
  32755. */
  32756. scene: Scene;
  32757. private _audioEnabled;
  32758. /**
  32759. * Gets whether audio is enabled or not.
  32760. * Please use related enable/disable method to switch state.
  32761. */
  32762. readonly audioEnabled: boolean;
  32763. private _headphone;
  32764. /**
  32765. * Gets whether audio is outputing to headphone or not.
  32766. * Please use the according Switch methods to change output.
  32767. */
  32768. readonly headphone: boolean;
  32769. /**
  32770. * Creates a new instance of the component for the given scene
  32771. * @param scene Defines the scene to register the component in
  32772. */
  32773. constructor(scene: Scene);
  32774. /**
  32775. * Registers the component in a given scene
  32776. */
  32777. register(): void;
  32778. /**
  32779. * Rebuilds the elements related to this component in case of
  32780. * context lost for instance.
  32781. */
  32782. rebuild(): void;
  32783. /**
  32784. * Serializes the component data to the specified json object
  32785. * @param serializationObject The object to serialize to
  32786. */
  32787. serialize(serializationObject: any): void;
  32788. /**
  32789. * Adds all the element from the container to the scene
  32790. * @param container the container holding the elements
  32791. */
  32792. addFromContainer(container: AbstractScene): void;
  32793. /**
  32794. * Removes all the elements in the container from the scene
  32795. * @param container contains the elements to remove
  32796. */
  32797. removeFromContainer(container: AbstractScene): void;
  32798. /**
  32799. * Disposes the component and the associated ressources.
  32800. */
  32801. dispose(): void;
  32802. /**
  32803. * Disables audio in the associated scene.
  32804. */
  32805. disableAudio(): void;
  32806. /**
  32807. * Enables audio in the associated scene.
  32808. */
  32809. enableAudio(): void;
  32810. /**
  32811. * Switch audio to headphone output.
  32812. */
  32813. switchAudioModeForHeadphones(): void;
  32814. /**
  32815. * Switch audio to normal speakers.
  32816. */
  32817. switchAudioModeForNormalSpeakers(): void;
  32818. private _afterRender;
  32819. }
  32820. }
  32821. declare module BABYLON {
  32822. /**
  32823. * Wraps one or more Sound objects and selects one with random weight for playback.
  32824. */
  32825. export class WeightedSound {
  32826. /** When true a Sound will be selected and played when the current playing Sound completes. */
  32827. loop: boolean;
  32828. private _coneInnerAngle;
  32829. private _coneOuterAngle;
  32830. private _volume;
  32831. /** A Sound is currently playing. */
  32832. isPlaying: boolean;
  32833. /** A Sound is currently paused. */
  32834. isPaused: boolean;
  32835. private _sounds;
  32836. private _weights;
  32837. private _currentIndex?;
  32838. /**
  32839. * Creates a new WeightedSound from the list of sounds given.
  32840. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  32841. * @param sounds Array of Sounds that will be selected from.
  32842. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  32843. */
  32844. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  32845. /**
  32846. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  32847. */
  32848. /**
  32849. * The size of cone in degress for a directional sound in which there will be no attenuation.
  32850. */
  32851. directionalConeInnerAngle: number;
  32852. /**
  32853. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  32854. * Listener angles between innerAngle and outerAngle will falloff linearly.
  32855. */
  32856. /**
  32857. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  32858. * Listener angles between innerAngle and outerAngle will falloff linearly.
  32859. */
  32860. directionalConeOuterAngle: number;
  32861. /**
  32862. * Playback volume.
  32863. */
  32864. /**
  32865. * Playback volume.
  32866. */
  32867. volume: number;
  32868. private _onended;
  32869. /**
  32870. * Suspend playback
  32871. */
  32872. pause(): void;
  32873. /**
  32874. * Stop playback
  32875. */
  32876. stop(): void;
  32877. /**
  32878. * Start playback.
  32879. * @param startOffset Position the clip head at a specific time in seconds.
  32880. */
  32881. play(startOffset?: number): void;
  32882. }
  32883. }
  32884. declare module BABYLON {
  32885. /**
  32886. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  32887. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  32888. */
  32889. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  32890. /**
  32891. * Gets the name of the behavior.
  32892. */
  32893. readonly name: string;
  32894. /**
  32895. * The easing function used by animations
  32896. */
  32897. static EasingFunction: BackEase;
  32898. /**
  32899. * The easing mode used by animations
  32900. */
  32901. static EasingMode: number;
  32902. /**
  32903. * The duration of the animation, in milliseconds
  32904. */
  32905. transitionDuration: number;
  32906. /**
  32907. * Length of the distance animated by the transition when lower radius is reached
  32908. */
  32909. lowerRadiusTransitionRange: number;
  32910. /**
  32911. * Length of the distance animated by the transition when upper radius is reached
  32912. */
  32913. upperRadiusTransitionRange: number;
  32914. private _autoTransitionRange;
  32915. /**
  32916. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32917. */
  32918. /**
  32919. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32920. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  32921. */
  32922. autoTransitionRange: boolean;
  32923. private _attachedCamera;
  32924. private _onAfterCheckInputsObserver;
  32925. private _onMeshTargetChangedObserver;
  32926. /**
  32927. * Initializes the behavior.
  32928. */
  32929. init(): void;
  32930. /**
  32931. * Attaches the behavior to its arc rotate camera.
  32932. * @param camera Defines the camera to attach the behavior to
  32933. */
  32934. attach(camera: ArcRotateCamera): void;
  32935. /**
  32936. * Detaches the behavior from its current arc rotate camera.
  32937. */
  32938. detach(): void;
  32939. private _radiusIsAnimating;
  32940. private _radiusBounceTransition;
  32941. private _animatables;
  32942. private _cachedWheelPrecision;
  32943. /**
  32944. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  32945. * @param radiusLimit The limit to check against.
  32946. * @return Bool to indicate if at limit.
  32947. */
  32948. private _isRadiusAtLimit;
  32949. /**
  32950. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  32951. * @param radiusDelta The delta by which to animate to. Can be negative.
  32952. */
  32953. private _applyBoundRadiusAnimation;
  32954. /**
  32955. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  32956. */
  32957. protected _clearAnimationLocks(): void;
  32958. /**
  32959. * Stops and removes all animations that have been applied to the camera
  32960. */
  32961. stopAllAnimations(): void;
  32962. }
  32963. }
  32964. declare module BABYLON {
  32965. /**
  32966. * 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.
  32967. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  32968. */
  32969. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  32970. /**
  32971. * Gets the name of the behavior.
  32972. */
  32973. readonly name: string;
  32974. private _mode;
  32975. private _radiusScale;
  32976. private _positionScale;
  32977. private _defaultElevation;
  32978. private _elevationReturnTime;
  32979. private _elevationReturnWaitTime;
  32980. private _zoomStopsAnimation;
  32981. private _framingTime;
  32982. /**
  32983. * The easing function used by animations
  32984. */
  32985. static EasingFunction: ExponentialEase;
  32986. /**
  32987. * The easing mode used by animations
  32988. */
  32989. static EasingMode: number;
  32990. /**
  32991. * Sets the current mode used by the behavior
  32992. */
  32993. /**
  32994. * Gets current mode used by the behavior.
  32995. */
  32996. mode: number;
  32997. /**
  32998. * Sets the scale applied to the radius (1 by default)
  32999. */
  33000. /**
  33001. * Gets the scale applied to the radius
  33002. */
  33003. radiusScale: number;
  33004. /**
  33005. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33006. */
  33007. /**
  33008. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33009. */
  33010. positionScale: number;
  33011. /**
  33012. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33013. * behaviour is triggered, in radians.
  33014. */
  33015. /**
  33016. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33017. * behaviour is triggered, in radians.
  33018. */
  33019. defaultElevation: number;
  33020. /**
  33021. * Sets the time (in milliseconds) taken to return to the default beta position.
  33022. * Negative value indicates camera should not return to default.
  33023. */
  33024. /**
  33025. * Gets the time (in milliseconds) taken to return to the default beta position.
  33026. * Negative value indicates camera should not return to default.
  33027. */
  33028. elevationReturnTime: number;
  33029. /**
  33030. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33031. */
  33032. /**
  33033. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33034. */
  33035. elevationReturnWaitTime: number;
  33036. /**
  33037. * Sets the flag that indicates if user zooming should stop animation.
  33038. */
  33039. /**
  33040. * Gets the flag that indicates if user zooming should stop animation.
  33041. */
  33042. zoomStopsAnimation: boolean;
  33043. /**
  33044. * Sets the transition time when framing the mesh, in milliseconds
  33045. */
  33046. /**
  33047. * Gets the transition time when framing the mesh, in milliseconds
  33048. */
  33049. framingTime: number;
  33050. /**
  33051. * Define if the behavior should automatically change the configured
  33052. * camera limits and sensibilities.
  33053. */
  33054. autoCorrectCameraLimitsAndSensibility: boolean;
  33055. private _onPrePointerObservableObserver;
  33056. private _onAfterCheckInputsObserver;
  33057. private _onMeshTargetChangedObserver;
  33058. private _attachedCamera;
  33059. private _isPointerDown;
  33060. private _lastInteractionTime;
  33061. /**
  33062. * Initializes the behavior.
  33063. */
  33064. init(): void;
  33065. /**
  33066. * Attaches the behavior to its arc rotate camera.
  33067. * @param camera Defines the camera to attach the behavior to
  33068. */
  33069. attach(camera: ArcRotateCamera): void;
  33070. /**
  33071. * Detaches the behavior from its current arc rotate camera.
  33072. */
  33073. detach(): void;
  33074. private _animatables;
  33075. private _betaIsAnimating;
  33076. private _betaTransition;
  33077. private _radiusTransition;
  33078. private _vectorTransition;
  33079. /**
  33080. * Targets the given mesh and updates zoom level accordingly.
  33081. * @param mesh The mesh to target.
  33082. * @param radius Optional. If a cached radius position already exists, overrides default.
  33083. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33084. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33085. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33086. */
  33087. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33088. /**
  33089. * Targets the given mesh with its children and updates zoom level accordingly.
  33090. * @param mesh The mesh to target.
  33091. * @param radius Optional. If a cached radius position already exists, overrides default.
  33092. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33093. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33094. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33095. */
  33096. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33097. /**
  33098. * Targets the given meshes with their children and updates zoom level accordingly.
  33099. * @param meshes The mesh to target.
  33100. * @param radius Optional. If a cached radius position already exists, overrides default.
  33101. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33102. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33103. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33104. */
  33105. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33106. /**
  33107. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  33108. * @param minimumWorld Determines the smaller position of the bounding box extend
  33109. * @param maximumWorld Determines the bigger position of the bounding box extend
  33110. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33111. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33112. */
  33113. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33114. /**
  33115. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33116. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33117. * frustum width.
  33118. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33119. * to fully enclose the mesh in the viewing frustum.
  33120. */
  33121. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33122. /**
  33123. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33124. * is automatically returned to its default position (expected to be above ground plane).
  33125. */
  33126. private _maintainCameraAboveGround;
  33127. /**
  33128. * Returns the frustum slope based on the canvas ratio and camera FOV
  33129. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33130. */
  33131. private _getFrustumSlope;
  33132. /**
  33133. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33134. */
  33135. private _clearAnimationLocks;
  33136. /**
  33137. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33138. */
  33139. private _applyUserInteraction;
  33140. /**
  33141. * Stops and removes all animations that have been applied to the camera
  33142. */
  33143. stopAllAnimations(): void;
  33144. /**
  33145. * Gets a value indicating if the user is moving the camera
  33146. */
  33147. readonly isUserIsMoving: boolean;
  33148. /**
  33149. * The camera can move all the way towards the mesh.
  33150. */
  33151. static IgnoreBoundsSizeMode: number;
  33152. /**
  33153. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33154. */
  33155. static FitFrustumSidesMode: number;
  33156. }
  33157. }
  33158. declare module BABYLON {
  33159. /**
  33160. * Manage the pointers inputs to control an arc rotate camera.
  33161. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33162. */
  33163. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  33164. /**
  33165. * Defines the camera the input is attached to.
  33166. */
  33167. camera: ArcRotateCamera;
  33168. /**
  33169. * Defines the buttons associated with the input to handle camera move.
  33170. */
  33171. buttons: number[];
  33172. /**
  33173. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  33174. */
  33175. angularSensibilityX: number;
  33176. /**
  33177. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  33178. */
  33179. angularSensibilityY: number;
  33180. /**
  33181. * Defines the pointer pinch precision or how fast is the camera zooming.
  33182. */
  33183. pinchPrecision: number;
  33184. /**
  33185. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  33186. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33187. */
  33188. pinchDeltaPercentage: number;
  33189. /**
  33190. * Defines the pointer panning sensibility or how fast is the camera moving.
  33191. */
  33192. panningSensibility: number;
  33193. /**
  33194. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  33195. */
  33196. multiTouchPanning: boolean;
  33197. /**
  33198. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  33199. */
  33200. multiTouchPanAndZoom: boolean;
  33201. /**
  33202. * Revers pinch action direction.
  33203. */
  33204. pinchInwards: boolean;
  33205. private _isPanClick;
  33206. private _pointerInput;
  33207. private _observer;
  33208. private _onMouseMove;
  33209. private _onGestureStart;
  33210. private _onGesture;
  33211. private _MSGestureHandler;
  33212. private _onLostFocus;
  33213. private _onContextMenu;
  33214. /**
  33215. * Attach the input controls to a specific dom element to get the input from.
  33216. * @param element Defines the element the controls should be listened from
  33217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33218. */
  33219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33220. /**
  33221. * Detach the current controls from the specified dom element.
  33222. * @param element Defines the element to stop listening the inputs from
  33223. */
  33224. detachControl(element: Nullable<HTMLElement>): void;
  33225. /**
  33226. * Gets the class name of the current intput.
  33227. * @returns the class name
  33228. */
  33229. getClassName(): string;
  33230. /**
  33231. * Get the friendly name associated with the input class.
  33232. * @returns the input friendly name
  33233. */
  33234. getSimpleName(): string;
  33235. }
  33236. }
  33237. declare module BABYLON {
  33238. /**
  33239. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  33240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33241. */
  33242. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  33243. /**
  33244. * Defines the camera the input is attached to.
  33245. */
  33246. camera: ArcRotateCamera;
  33247. /**
  33248. * Defines the list of key codes associated with the up action (increase alpha)
  33249. */
  33250. keysUp: number[];
  33251. /**
  33252. * Defines the list of key codes associated with the down action (decrease alpha)
  33253. */
  33254. keysDown: number[];
  33255. /**
  33256. * Defines the list of key codes associated with the left action (increase beta)
  33257. */
  33258. keysLeft: number[];
  33259. /**
  33260. * Defines the list of key codes associated with the right action (decrease beta)
  33261. */
  33262. keysRight: number[];
  33263. /**
  33264. * Defines the list of key codes associated with the reset action.
  33265. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  33266. */
  33267. keysReset: number[];
  33268. /**
  33269. * Defines the panning sensibility of the inputs.
  33270. * (How fast is the camera paning)
  33271. */
  33272. panningSensibility: number;
  33273. /**
  33274. * Defines the zooming sensibility of the inputs.
  33275. * (How fast is the camera zooming)
  33276. */
  33277. zoomingSensibility: number;
  33278. /**
  33279. * Defines wether maintaining the alt key down switch the movement mode from
  33280. * orientation to zoom.
  33281. */
  33282. useAltToZoom: boolean;
  33283. /**
  33284. * Rotation speed of the camera
  33285. */
  33286. angularSpeed: number;
  33287. private _keys;
  33288. private _ctrlPressed;
  33289. private _altPressed;
  33290. private _onCanvasBlurObserver;
  33291. private _onKeyboardObserver;
  33292. private _engine;
  33293. private _scene;
  33294. /**
  33295. * Attach the input controls to a specific dom element to get the input from.
  33296. * @param element Defines the element the controls should be listened from
  33297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33298. */
  33299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33300. /**
  33301. * Detach the current controls from the specified dom element.
  33302. * @param element Defines the element to stop listening the inputs from
  33303. */
  33304. detachControl(element: Nullable<HTMLElement>): void;
  33305. /**
  33306. * Update the current camera state depending on the inputs that have been used this frame.
  33307. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  33308. */
  33309. checkInputs(): void;
  33310. /**
  33311. * Gets the class name of the current intput.
  33312. * @returns the class name
  33313. */
  33314. getClassName(): string;
  33315. /**
  33316. * Get the friendly name associated with the input class.
  33317. * @returns the input friendly name
  33318. */
  33319. getSimpleName(): string;
  33320. }
  33321. }
  33322. declare module BABYLON {
  33323. /**
  33324. * Manage the mouse wheel inputs to control an arc rotate camera.
  33325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33326. */
  33327. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  33328. /**
  33329. * Defines the camera the input is attached to.
  33330. */
  33331. camera: ArcRotateCamera;
  33332. /**
  33333. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  33334. */
  33335. wheelPrecision: number;
  33336. /**
  33337. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  33338. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  33339. */
  33340. wheelDeltaPercentage: number;
  33341. private _wheel;
  33342. private _observer;
  33343. /**
  33344. * Attach the input controls to a specific dom element to get the input from.
  33345. * @param element Defines the element the controls should be listened from
  33346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33347. */
  33348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33349. /**
  33350. * Detach the current controls from the specified dom element.
  33351. * @param element Defines the element to stop listening the inputs from
  33352. */
  33353. detachControl(element: Nullable<HTMLElement>): void;
  33354. /**
  33355. * Gets the class name of the current intput.
  33356. * @returns the class name
  33357. */
  33358. getClassName(): string;
  33359. /**
  33360. * Get the friendly name associated with the input class.
  33361. * @returns the input friendly name
  33362. */
  33363. getSimpleName(): string;
  33364. }
  33365. }
  33366. declare module BABYLON {
  33367. /**
  33368. * Default Inputs manager for the ArcRotateCamera.
  33369. * It groups all the default supported inputs for ease of use.
  33370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33371. */
  33372. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  33373. /**
  33374. * Instantiates a new ArcRotateCameraInputsManager.
  33375. * @param camera Defines the camera the inputs belong to
  33376. */
  33377. constructor(camera: ArcRotateCamera);
  33378. /**
  33379. * Add mouse wheel input support to the input manager.
  33380. * @returns the current input manager
  33381. */
  33382. addMouseWheel(): ArcRotateCameraInputsManager;
  33383. /**
  33384. * Add pointers input support to the input manager.
  33385. * @returns the current input manager
  33386. */
  33387. addPointers(): ArcRotateCameraInputsManager;
  33388. /**
  33389. * Add keyboard input support to the input manager.
  33390. * @returns the current input manager
  33391. */
  33392. addKeyboard(): ArcRotateCameraInputsManager;
  33393. }
  33394. }
  33395. declare module BABYLON {
  33396. /**
  33397. * This represents an orbital type of camera.
  33398. *
  33399. * 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.
  33400. * 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.
  33401. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  33402. */
  33403. export class ArcRotateCamera extends TargetCamera {
  33404. /**
  33405. * Defines the rotation angle of the camera along the longitudinal axis.
  33406. */
  33407. alpha: number;
  33408. /**
  33409. * Defines the rotation angle of the camera along the latitudinal axis.
  33410. */
  33411. beta: number;
  33412. /**
  33413. * Defines the radius of the camera from it s target point.
  33414. */
  33415. radius: number;
  33416. protected _target: Vector3;
  33417. protected _targetHost: Nullable<AbstractMesh>;
  33418. /**
  33419. * Defines the target point of the camera.
  33420. * The camera looks towards it form the radius distance.
  33421. */
  33422. target: Vector3;
  33423. /**
  33424. * Current inertia value on the longitudinal axis.
  33425. * The bigger this number the longer it will take for the camera to stop.
  33426. */
  33427. inertialAlphaOffset: number;
  33428. /**
  33429. * Current inertia value on the latitudinal axis.
  33430. * The bigger this number the longer it will take for the camera to stop.
  33431. */
  33432. inertialBetaOffset: number;
  33433. /**
  33434. * Current inertia value on the radius axis.
  33435. * The bigger this number the longer it will take for the camera to stop.
  33436. */
  33437. inertialRadiusOffset: number;
  33438. /**
  33439. * Minimum allowed angle on the longitudinal axis.
  33440. * This can help limiting how the Camera is able to move in the scene.
  33441. */
  33442. lowerAlphaLimit: Nullable<number>;
  33443. /**
  33444. * Maximum allowed angle on the longitudinal axis.
  33445. * This can help limiting how the Camera is able to move in the scene.
  33446. */
  33447. upperAlphaLimit: Nullable<number>;
  33448. /**
  33449. * Minimum allowed angle on the latitudinal axis.
  33450. * This can help limiting how the Camera is able to move in the scene.
  33451. */
  33452. lowerBetaLimit: number;
  33453. /**
  33454. * Maximum allowed angle on the latitudinal axis.
  33455. * This can help limiting how the Camera is able to move in the scene.
  33456. */
  33457. upperBetaLimit: number;
  33458. /**
  33459. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  33460. * This can help limiting how the Camera is able to move in the scene.
  33461. */
  33462. lowerRadiusLimit: Nullable<number>;
  33463. /**
  33464. * Maximum allowed distance of the camera to the target (The camera can not get further).
  33465. * This can help limiting how the Camera is able to move in the scene.
  33466. */
  33467. upperRadiusLimit: Nullable<number>;
  33468. /**
  33469. * Defines the current inertia value used during panning of the camera along the X axis.
  33470. */
  33471. inertialPanningX: number;
  33472. /**
  33473. * Defines the current inertia value used during panning of the camera along the Y axis.
  33474. */
  33475. inertialPanningY: number;
  33476. /**
  33477. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  33478. * Basically if your fingers moves away from more than this distance you will be considered
  33479. * in pinch mode.
  33480. */
  33481. pinchToPanMaxDistance: number;
  33482. /**
  33483. * Defines the maximum distance the camera can pan.
  33484. * This could help keeping the cammera always in your scene.
  33485. */
  33486. panningDistanceLimit: Nullable<number>;
  33487. /**
  33488. * Defines the target of the camera before paning.
  33489. */
  33490. panningOriginTarget: Vector3;
  33491. /**
  33492. * Defines the value of the inertia used during panning.
  33493. * 0 would mean stop inertia and one would mean no decelleration at all.
  33494. */
  33495. panningInertia: number;
  33496. /**
  33497. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  33498. */
  33499. angularSensibilityX: number;
  33500. /**
  33501. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  33502. */
  33503. angularSensibilityY: number;
  33504. /**
  33505. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  33506. */
  33507. pinchPrecision: number;
  33508. /**
  33509. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  33510. * It will be used instead of pinchDeltaPrecision if different from 0.
  33511. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33512. */
  33513. pinchDeltaPercentage: number;
  33514. /**
  33515. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  33516. */
  33517. panningSensibility: number;
  33518. /**
  33519. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  33520. */
  33521. keysUp: number[];
  33522. /**
  33523. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  33524. */
  33525. keysDown: number[];
  33526. /**
  33527. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  33528. */
  33529. keysLeft: number[];
  33530. /**
  33531. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  33532. */
  33533. keysRight: number[];
  33534. /**
  33535. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  33536. */
  33537. wheelPrecision: number;
  33538. /**
  33539. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  33540. * It will be used instead of pinchDeltaPrecision if different from 0.
  33541. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33542. */
  33543. wheelDeltaPercentage: number;
  33544. /**
  33545. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  33546. */
  33547. zoomOnFactor: number;
  33548. /**
  33549. * Defines a screen offset for the camera position.
  33550. */
  33551. targetScreenOffset: Vector2;
  33552. /**
  33553. * Allows the camera to be completely reversed.
  33554. * If false the camera can not arrive upside down.
  33555. */
  33556. allowUpsideDown: boolean;
  33557. /**
  33558. * Define if double tap/click is used to restore the previously saved state of the camera.
  33559. */
  33560. useInputToRestoreState: boolean;
  33561. /** @hidden */ viewMatrix: Matrix;
  33562. /** @hidden */ useCtrlForPanning: boolean;
  33563. /** @hidden */ panningMouseButton: number;
  33564. /**
  33565. * Defines the input associated to the camera.
  33566. */
  33567. inputs: ArcRotateCameraInputsManager;
  33568. /** @hidden */ reset: () => void;
  33569. /**
  33570. * Defines the allowed panning axis.
  33571. */
  33572. panningAxis: Vector3;
  33573. protected _localDirection: Vector3;
  33574. protected _transformedDirection: Vector3;
  33575. private _bouncingBehavior;
  33576. /**
  33577. * Gets the bouncing behavior of the camera if it has been enabled.
  33578. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33579. */
  33580. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  33581. /**
  33582. * Defines if the bouncing behavior of the camera is enabled on the camera.
  33583. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33584. */
  33585. useBouncingBehavior: boolean;
  33586. private _framingBehavior;
  33587. /**
  33588. * Gets the framing behavior of the camera if it has been enabled.
  33589. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33590. */
  33591. readonly framingBehavior: Nullable<FramingBehavior>;
  33592. /**
  33593. * Defines if the framing behavior of the camera is enabled on the camera.
  33594. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33595. */
  33596. useFramingBehavior: boolean;
  33597. private _autoRotationBehavior;
  33598. /**
  33599. * Gets the auto rotation behavior of the camera if it has been enabled.
  33600. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  33601. */
  33602. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  33603. /**
  33604. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  33605. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  33606. */
  33607. useAutoRotationBehavior: boolean;
  33608. /**
  33609. * Observable triggered when the mesh target has been changed on the camera.
  33610. */
  33611. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  33612. /**
  33613. * Event raised when the camera is colliding with a mesh.
  33614. */
  33615. onCollide: (collidedMesh: AbstractMesh) => void;
  33616. /**
  33617. * Defines whether the camera should check collision with the objects oh the scene.
  33618. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  33619. */
  33620. checkCollisions: boolean;
  33621. /**
  33622. * Defines the collision radius of the camera.
  33623. * This simulates a sphere around the camera.
  33624. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  33625. */
  33626. collisionRadius: Vector3;
  33627. protected _collider: Collider;
  33628. protected _previousPosition: Vector3;
  33629. protected _collisionVelocity: Vector3;
  33630. protected _newPosition: Vector3;
  33631. protected _previousAlpha: number;
  33632. protected _previousBeta: number;
  33633. protected _previousRadius: number;
  33634. protected _collisionTriggered: boolean;
  33635. protected _targetBoundingCenter: Nullable<Vector3>;
  33636. private _computationVector;
  33637. private _tempAxisVector;
  33638. private _tempAxisRotationMatrix;
  33639. /**
  33640. * Instantiates a new ArcRotateCamera in a given scene
  33641. * @param name Defines the name of the camera
  33642. * @param alpha Defines the camera rotation along the logitudinal axis
  33643. * @param beta Defines the camera rotation along the latitudinal axis
  33644. * @param radius Defines the camera distance from its target
  33645. * @param target Defines the camera target
  33646. * @param scene Defines the scene the camera belongs to
  33647. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  33648. */
  33649. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  33650. /** @hidden */ initCache(): void;
  33651. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  33652. protected _getTargetPosition(): Vector3;
  33653. private _storedAlpha;
  33654. private _storedBeta;
  33655. private _storedRadius;
  33656. private _storedTarget;
  33657. /**
  33658. * Stores the current state of the camera (alpha, beta, radius and target)
  33659. * @returns the camera itself
  33660. */
  33661. storeState(): Camera;
  33662. /**
  33663. * @hidden
  33664. * Restored camera state. You must call storeState() first
  33665. */ restoreStateValues(): boolean;
  33666. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  33667. /**
  33668. * Attached controls to the current camera.
  33669. * @param element Defines the element the controls should be listened from
  33670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33671. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  33672. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  33673. */
  33674. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  33675. /**
  33676. * Detach the current controls from the camera.
  33677. * The camera will stop reacting to inputs.
  33678. * @param element Defines the element to stop listening the inputs from
  33679. */
  33680. detachControl(element: HTMLElement): void;
  33681. /** @hidden */ checkInputs(): void;
  33682. protected _checkLimits(): void;
  33683. /**
  33684. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  33685. */
  33686. rebuildAnglesAndRadius(): void;
  33687. /**
  33688. * Use a position to define the current camera related information like aplha, beta and radius
  33689. * @param position Defines the position to set the camera at
  33690. */
  33691. setPosition(position: Vector3): void;
  33692. /**
  33693. * Defines the target the camera should look at.
  33694. * This will automatically adapt alpha beta and radius to fit within the new target.
  33695. * @param target Defines the new target as a Vector or a mesh
  33696. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  33697. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  33698. */
  33699. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  33700. /** @hidden */ getViewMatrix(): Matrix;
  33701. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  33702. /**
  33703. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  33704. * @param meshes Defines the mesh to zoom on
  33705. * @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)
  33706. */
  33707. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  33708. /**
  33709. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  33710. * The target will be changed but the radius
  33711. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  33712. * @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)
  33713. */
  33714. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  33715. min: Vector3;
  33716. max: Vector3;
  33717. distance: number;
  33718. }, doNotUpdateMaxZ?: boolean): void;
  33719. /**
  33720. * @override
  33721. * Override Camera.createRigCamera
  33722. */
  33723. createRigCamera(name: string, cameraIndex: number): Camera;
  33724. /**
  33725. * @hidden
  33726. * @override
  33727. * Override Camera._updateRigCameras
  33728. */ updateRigCameras(): void;
  33729. /**
  33730. * Destroy the camera and release the current resources hold by it.
  33731. */
  33732. dispose(): void;
  33733. /**
  33734. * Gets the current object class name.
  33735. * @return the class name
  33736. */
  33737. getClassName(): string;
  33738. }
  33739. }
  33740. declare module BABYLON {
  33741. /**
  33742. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  33743. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  33744. */
  33745. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  33746. /**
  33747. * Gets the name of the behavior.
  33748. */
  33749. readonly name: string;
  33750. private _zoomStopsAnimation;
  33751. private _idleRotationSpeed;
  33752. private _idleRotationWaitTime;
  33753. private _idleRotationSpinupTime;
  33754. /**
  33755. * Sets the flag that indicates if user zooming should stop animation.
  33756. */
  33757. /**
  33758. * Gets the flag that indicates if user zooming should stop animation.
  33759. */
  33760. zoomStopsAnimation: boolean;
  33761. /**
  33762. * Sets the default speed at which the camera rotates around the model.
  33763. */
  33764. /**
  33765. * Gets the default speed at which the camera rotates around the model.
  33766. */
  33767. idleRotationSpeed: number;
  33768. /**
  33769. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  33770. */
  33771. /**
  33772. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  33773. */
  33774. idleRotationWaitTime: number;
  33775. /**
  33776. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  33777. */
  33778. /**
  33779. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  33780. */
  33781. idleRotationSpinupTime: number;
  33782. /**
  33783. * Gets a value indicating if the camera is currently rotating because of this behavior
  33784. */
  33785. readonly rotationInProgress: boolean;
  33786. private _onPrePointerObservableObserver;
  33787. private _onAfterCheckInputsObserver;
  33788. private _attachedCamera;
  33789. private _isPointerDown;
  33790. private _lastFrameTime;
  33791. private _lastInteractionTime;
  33792. private _cameraRotationSpeed;
  33793. /**
  33794. * Initializes the behavior.
  33795. */
  33796. init(): void;
  33797. /**
  33798. * Attaches the behavior to its arc rotate camera.
  33799. * @param camera Defines the camera to attach the behavior to
  33800. */
  33801. attach(camera: ArcRotateCamera): void;
  33802. /**
  33803. * Detaches the behavior from its current arc rotate camera.
  33804. */
  33805. detach(): void;
  33806. /**
  33807. * Returns true if user is scrolling.
  33808. * @return true if user is scrolling.
  33809. */
  33810. private _userIsZooming;
  33811. private _lastFrameRadius;
  33812. private _shouldAnimationStopForInteraction;
  33813. /**
  33814. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33815. */
  33816. private _applyUserInteraction;
  33817. private _userIsMoving;
  33818. }
  33819. }
  33820. declare module BABYLON {
  33821. /**
  33822. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  33823. */
  33824. export class AttachToBoxBehavior implements Behavior<Mesh> {
  33825. private ui;
  33826. /**
  33827. * The name of the behavior
  33828. */
  33829. name: string;
  33830. /**
  33831. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  33832. */
  33833. distanceAwayFromFace: number;
  33834. /**
  33835. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  33836. */
  33837. distanceAwayFromBottomOfFace: number;
  33838. private _faceVectors;
  33839. private _target;
  33840. private _scene;
  33841. private _onRenderObserver;
  33842. private _tmpMatrix;
  33843. private _tmpVector;
  33844. /**
  33845. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  33846. * @param ui The transform node that should be attched to the mesh
  33847. */
  33848. constructor(ui: TransformNode);
  33849. /**
  33850. * Initializes the behavior
  33851. */
  33852. init(): void;
  33853. private _closestFace;
  33854. private _zeroVector;
  33855. private _lookAtTmpMatrix;
  33856. private _lookAtToRef;
  33857. /**
  33858. * Attaches the AttachToBoxBehavior to the passed in mesh
  33859. * @param target The mesh that the specified node will be attached to
  33860. */
  33861. attach(target: Mesh): void;
  33862. /**
  33863. * Detaches the behavior from the mesh
  33864. */
  33865. detach(): void;
  33866. }
  33867. }
  33868. declare module BABYLON {
  33869. /**
  33870. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  33871. */
  33872. export class FadeInOutBehavior implements Behavior<Mesh> {
  33873. /**
  33874. * Time in milliseconds to delay before fading in (Default: 0)
  33875. */
  33876. delay: number;
  33877. /**
  33878. * Time in milliseconds for the mesh to fade in (Default: 300)
  33879. */
  33880. fadeInTime: number;
  33881. private _millisecondsPerFrame;
  33882. private _hovered;
  33883. private _hoverValue;
  33884. private _ownerNode;
  33885. /**
  33886. * Instatiates the FadeInOutBehavior
  33887. */
  33888. constructor();
  33889. /**
  33890. * The name of the behavior
  33891. */
  33892. readonly name: string;
  33893. /**
  33894. * Initializes the behavior
  33895. */
  33896. init(): void;
  33897. /**
  33898. * Attaches the fade behavior on the passed in mesh
  33899. * @param ownerNode The mesh that will be faded in/out once attached
  33900. */
  33901. attach(ownerNode: Mesh): void;
  33902. /**
  33903. * Detaches the behavior from the mesh
  33904. */
  33905. detach(): void;
  33906. /**
  33907. * Triggers the mesh to begin fading in or out
  33908. * @param value if the object should fade in or out (true to fade in)
  33909. */
  33910. fadeIn(value: boolean): void;
  33911. private _update;
  33912. private _setAllVisibility;
  33913. }
  33914. }
  33915. declare module BABYLON {
  33916. /**
  33917. * Class containing a set of static utilities functions for managing Pivots
  33918. * @hidden
  33919. */
  33920. export class PivotTools {
  33921. private static _PivotCached;
  33922. private static _OldPivotPoint;
  33923. private static _PivotTranslation;
  33924. private static _PivotTmpVector;
  33925. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  33926. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  33927. }
  33928. }
  33929. declare module BABYLON {
  33930. /**
  33931. * Class containing static functions to help procedurally build meshes
  33932. */
  33933. export class PlaneBuilder {
  33934. /**
  33935. * Creates a plane mesh
  33936. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  33937. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  33938. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  33939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  33940. * * 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
  33941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33942. * @param name defines the name of the mesh
  33943. * @param options defines the options used to create the mesh
  33944. * @param scene defines the hosting scene
  33945. * @returns the plane mesh
  33946. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  33947. */
  33948. static CreatePlane(name: string, options: {
  33949. size?: number;
  33950. width?: number;
  33951. height?: number;
  33952. sideOrientation?: number;
  33953. frontUVs?: Vector4;
  33954. backUVs?: Vector4;
  33955. updatable?: boolean;
  33956. sourcePlane?: Plane;
  33957. }, scene: Scene): Mesh;
  33958. }
  33959. }
  33960. declare module BABYLON {
  33961. /**
  33962. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  33963. */
  33964. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  33965. private static _AnyMouseID;
  33966. private _attachedNode;
  33967. private _dragPlane;
  33968. private _scene;
  33969. private _pointerObserver;
  33970. private _beforeRenderObserver;
  33971. private static _planeScene;
  33972. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  33973. /**
  33974. * 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)
  33975. */
  33976. maxDragAngle: number;
  33977. /**
  33978. * @hidden
  33979. */ useAlternatePickedPointAboveMaxDragAngle: boolean;
  33980. /**
  33981. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  33982. */
  33983. currentDraggingPointerID: number;
  33984. /**
  33985. * The last position where the pointer hit the drag plane in world space
  33986. */
  33987. lastDragPosition: Vector3;
  33988. /**
  33989. * If the behavior is currently in a dragging state
  33990. */
  33991. dragging: boolean;
  33992. /**
  33993. * 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)
  33994. */
  33995. dragDeltaRatio: number;
  33996. /**
  33997. * If the drag plane orientation should be updated during the dragging (Default: true)
  33998. */
  33999. updateDragPlane: boolean;
  34000. private _debugMode;
  34001. private _moving;
  34002. /**
  34003. * Fires each time the attached mesh is dragged with the pointer
  34004. * * delta between last drag position and current drag position in world space
  34005. * * dragDistance along the drag axis
  34006. * * dragPlaneNormal normal of the current drag plane used during the drag
  34007. * * dragPlanePoint in world space where the drag intersects the drag plane
  34008. */
  34009. onDragObservable: Observable<{
  34010. delta: Vector3;
  34011. dragPlanePoint: Vector3;
  34012. dragPlaneNormal: Vector3;
  34013. dragDistance: number;
  34014. pointerId: number;
  34015. }>;
  34016. /**
  34017. * Fires each time a drag begins (eg. mouse down on mesh)
  34018. */
  34019. onDragStartObservable: Observable<{
  34020. dragPlanePoint: Vector3;
  34021. pointerId: number;
  34022. }>;
  34023. /**
  34024. * Fires each time a drag ends (eg. mouse release after drag)
  34025. */
  34026. onDragEndObservable: Observable<{
  34027. dragPlanePoint: Vector3;
  34028. pointerId: number;
  34029. }>;
  34030. /**
  34031. * If the attached mesh should be moved when dragged
  34032. */
  34033. moveAttached: boolean;
  34034. /**
  34035. * If the drag behavior will react to drag events (Default: true)
  34036. */
  34037. enabled: boolean;
  34038. /**
  34039. * If camera controls should be detached during the drag
  34040. */
  34041. detachCameraControls: boolean;
  34042. /**
  34043. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  34044. */
  34045. useObjectOrienationForDragging: boolean;
  34046. private _options;
  34047. /**
  34048. * Creates a pointer drag behavior that can be attached to a mesh
  34049. * @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)
  34050. */
  34051. constructor(options?: {
  34052. dragAxis?: Vector3;
  34053. dragPlaneNormal?: Vector3;
  34054. });
  34055. /**
  34056. * Predicate to determine if it is valid to move the object to a new position when it is moved
  34057. */
  34058. validateDrag: (targetPosition: Vector3) => boolean;
  34059. /**
  34060. * The name of the behavior
  34061. */
  34062. readonly name: string;
  34063. /**
  34064. * Initializes the behavior
  34065. */
  34066. init(): void;
  34067. private _tmpVector;
  34068. private _alternatePickedPoint;
  34069. private _worldDragAxis;
  34070. private _targetPosition;
  34071. private _attachedElement;
  34072. /**
  34073. * Attaches the drag behavior the passed in mesh
  34074. * @param ownerNode The mesh that will be dragged around once attached
  34075. */
  34076. attach(ownerNode: AbstractMesh): void;
  34077. /**
  34078. * Force relase the drag action by code.
  34079. */
  34080. releaseDrag(): void;
  34081. private _startDragRay;
  34082. private _lastPointerRay;
  34083. /**
  34084. * Simulates the start of a pointer drag event on the behavior
  34085. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  34086. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  34087. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  34088. */
  34089. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  34090. private _startDrag;
  34091. private _dragDelta;
  34092. private _moveDrag;
  34093. private _pickWithRayOnDragPlane;
  34094. private _pointA;
  34095. private _pointB;
  34096. private _pointC;
  34097. private _lineA;
  34098. private _lineB;
  34099. private _localAxis;
  34100. private _lookAt;
  34101. private _updateDragPlanePosition;
  34102. /**
  34103. * Detaches the behavior from the mesh
  34104. */
  34105. detach(): void;
  34106. }
  34107. }
  34108. declare module BABYLON {
  34109. /**
  34110. * A behavior that when attached to a mesh will allow the mesh to be scaled
  34111. */
  34112. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  34113. private _dragBehaviorA;
  34114. private _dragBehaviorB;
  34115. private _startDistance;
  34116. private _initialScale;
  34117. private _targetScale;
  34118. private _ownerNode;
  34119. private _sceneRenderObserver;
  34120. /**
  34121. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  34122. */
  34123. constructor();
  34124. /**
  34125. * The name of the behavior
  34126. */
  34127. readonly name: string;
  34128. /**
  34129. * Initializes the behavior
  34130. */
  34131. init(): void;
  34132. private _getCurrentDistance;
  34133. /**
  34134. * Attaches the scale behavior the passed in mesh
  34135. * @param ownerNode The mesh that will be scaled around once attached
  34136. */
  34137. attach(ownerNode: Mesh): void;
  34138. /**
  34139. * Detaches the behavior from the mesh
  34140. */
  34141. detach(): void;
  34142. }
  34143. }
  34144. declare module BABYLON {
  34145. /**
  34146. * 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
  34147. */
  34148. export class SixDofDragBehavior implements Behavior<Mesh> {
  34149. private static _virtualScene;
  34150. private _ownerNode;
  34151. private _sceneRenderObserver;
  34152. private _scene;
  34153. private _targetPosition;
  34154. private _virtualOriginMesh;
  34155. private _virtualDragMesh;
  34156. private _pointerObserver;
  34157. private _moving;
  34158. private _startingOrientation;
  34159. /**
  34160. * 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)
  34161. */
  34162. private zDragFactor;
  34163. /**
  34164. * If the object should rotate to face the drag origin
  34165. */
  34166. rotateDraggedObject: boolean;
  34167. /**
  34168. * If the behavior is currently in a dragging state
  34169. */
  34170. dragging: boolean;
  34171. /**
  34172. * 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)
  34173. */
  34174. dragDeltaRatio: number;
  34175. /**
  34176. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34177. */
  34178. currentDraggingPointerID: number;
  34179. /**
  34180. * If camera controls should be detached during the drag
  34181. */
  34182. detachCameraControls: boolean;
  34183. /**
  34184. * Fires each time a drag starts
  34185. */
  34186. onDragStartObservable: Observable<{}>;
  34187. /**
  34188. * Fires each time a drag ends (eg. mouse release after drag)
  34189. */
  34190. onDragEndObservable: Observable<{}>;
  34191. /**
  34192. * 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
  34193. */
  34194. constructor();
  34195. /**
  34196. * The name of the behavior
  34197. */
  34198. readonly name: string;
  34199. /**
  34200. * Initializes the behavior
  34201. */
  34202. init(): void;
  34203. /**
  34204. * Attaches the scale behavior the passed in mesh
  34205. * @param ownerNode The mesh that will be scaled around once attached
  34206. */
  34207. attach(ownerNode: Mesh): void;
  34208. /**
  34209. * Detaches the behavior from the mesh
  34210. */
  34211. detach(): void;
  34212. }
  34213. }
  34214. declare module BABYLON {
  34215. /**
  34216. * Class used to apply inverse kinematics to bones
  34217. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  34218. */
  34219. export class BoneIKController {
  34220. private static _tmpVecs;
  34221. private static _tmpQuat;
  34222. private static _tmpMats;
  34223. /**
  34224. * Gets or sets the target mesh
  34225. */
  34226. targetMesh: AbstractMesh;
  34227. /** Gets or sets the mesh used as pole */
  34228. poleTargetMesh: AbstractMesh;
  34229. /**
  34230. * Gets or sets the bone used as pole
  34231. */
  34232. poleTargetBone: Nullable<Bone>;
  34233. /**
  34234. * Gets or sets the target position
  34235. */
  34236. targetPosition: Vector3;
  34237. /**
  34238. * Gets or sets the pole target position
  34239. */
  34240. poleTargetPosition: Vector3;
  34241. /**
  34242. * Gets or sets the pole target local offset
  34243. */
  34244. poleTargetLocalOffset: Vector3;
  34245. /**
  34246. * Gets or sets the pole angle
  34247. */
  34248. poleAngle: number;
  34249. /**
  34250. * Gets or sets the mesh associated with the controller
  34251. */
  34252. mesh: AbstractMesh;
  34253. /**
  34254. * 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)
  34255. */
  34256. slerpAmount: number;
  34257. private _bone1Quat;
  34258. private _bone1Mat;
  34259. private _bone2Ang;
  34260. private _bone1;
  34261. private _bone2;
  34262. private _bone1Length;
  34263. private _bone2Length;
  34264. private _maxAngle;
  34265. private _maxReach;
  34266. private _rightHandedSystem;
  34267. private _bendAxis;
  34268. private _slerping;
  34269. private _adjustRoll;
  34270. /**
  34271. * Gets or sets maximum allowed angle
  34272. */
  34273. maxAngle: number;
  34274. /**
  34275. * Creates a new BoneIKController
  34276. * @param mesh defines the mesh to control
  34277. * @param bone defines the bone to control
  34278. * @param options defines options to set up the controller
  34279. */
  34280. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  34281. targetMesh?: AbstractMesh;
  34282. poleTargetMesh?: AbstractMesh;
  34283. poleTargetBone?: Bone;
  34284. poleTargetLocalOffset?: Vector3;
  34285. poleAngle?: number;
  34286. bendAxis?: Vector3;
  34287. maxAngle?: number;
  34288. slerpAmount?: number;
  34289. });
  34290. private _setMaxAngle;
  34291. /**
  34292. * Force the controller to update the bones
  34293. */
  34294. update(): void;
  34295. }
  34296. }
  34297. declare module BABYLON {
  34298. /**
  34299. * Class used to make a bone look toward a point in space
  34300. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  34301. */
  34302. export class BoneLookController {
  34303. private static _tmpVecs;
  34304. private static _tmpQuat;
  34305. private static _tmpMats;
  34306. /**
  34307. * The target Vector3 that the bone will look at
  34308. */
  34309. target: Vector3;
  34310. /**
  34311. * The mesh that the bone is attached to
  34312. */
  34313. mesh: AbstractMesh;
  34314. /**
  34315. * The bone that will be looking to the target
  34316. */
  34317. bone: Bone;
  34318. /**
  34319. * The up axis of the coordinate system that is used when the bone is rotated
  34320. */
  34321. upAxis: Vector3;
  34322. /**
  34323. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  34324. */
  34325. upAxisSpace: Space;
  34326. /**
  34327. * Used to make an adjustment to the yaw of the bone
  34328. */
  34329. adjustYaw: number;
  34330. /**
  34331. * Used to make an adjustment to the pitch of the bone
  34332. */
  34333. adjustPitch: number;
  34334. /**
  34335. * Used to make an adjustment to the roll of the bone
  34336. */
  34337. adjustRoll: number;
  34338. /**
  34339. * 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)
  34340. */
  34341. slerpAmount: number;
  34342. private _minYaw;
  34343. private _maxYaw;
  34344. private _minPitch;
  34345. private _maxPitch;
  34346. private _minYawSin;
  34347. private _minYawCos;
  34348. private _maxYawSin;
  34349. private _maxYawCos;
  34350. private _midYawConstraint;
  34351. private _minPitchTan;
  34352. private _maxPitchTan;
  34353. private _boneQuat;
  34354. private _slerping;
  34355. private _transformYawPitch;
  34356. private _transformYawPitchInv;
  34357. private _firstFrameSkipped;
  34358. private _yawRange;
  34359. private _fowardAxis;
  34360. /**
  34361. * Gets or sets the minimum yaw angle that the bone can look to
  34362. */
  34363. minYaw: number;
  34364. /**
  34365. * Gets or sets the maximum yaw angle that the bone can look to
  34366. */
  34367. maxYaw: number;
  34368. /**
  34369. * Gets or sets the minimum pitch angle that the bone can look to
  34370. */
  34371. minPitch: number;
  34372. /**
  34373. * Gets or sets the maximum pitch angle that the bone can look to
  34374. */
  34375. maxPitch: number;
  34376. /**
  34377. * Create a BoneLookController
  34378. * @param mesh the mesh that the bone belongs to
  34379. * @param bone the bone that will be looking to the target
  34380. * @param target the target Vector3 to look at
  34381. * @param options optional settings:
  34382. * * maxYaw: the maximum angle the bone will yaw to
  34383. * * minYaw: the minimum angle the bone will yaw to
  34384. * * maxPitch: the maximum angle the bone will pitch to
  34385. * * minPitch: the minimum angle the bone will yaw to
  34386. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  34387. * * upAxis: the up axis of the coordinate system
  34388. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  34389. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  34390. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  34391. * * adjustYaw: used to make an adjustment to the yaw of the bone
  34392. * * adjustPitch: used to make an adjustment to the pitch of the bone
  34393. * * adjustRoll: used to make an adjustment to the roll of the bone
  34394. **/
  34395. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  34396. maxYaw?: number;
  34397. minYaw?: number;
  34398. maxPitch?: number;
  34399. minPitch?: number;
  34400. slerpAmount?: number;
  34401. upAxis?: Vector3;
  34402. upAxisSpace?: Space;
  34403. yawAxis?: Vector3;
  34404. pitchAxis?: Vector3;
  34405. adjustYaw?: number;
  34406. adjustPitch?: number;
  34407. adjustRoll?: number;
  34408. });
  34409. /**
  34410. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  34411. */
  34412. update(): void;
  34413. private _getAngleDiff;
  34414. private _getAngleBetween;
  34415. private _isAngleBetween;
  34416. }
  34417. }
  34418. declare module BABYLON {
  34419. /**
  34420. * Manage the gamepad inputs to control an arc rotate camera.
  34421. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34422. */
  34423. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  34424. /**
  34425. * Defines the camera the input is attached to.
  34426. */
  34427. camera: ArcRotateCamera;
  34428. /**
  34429. * Defines the gamepad the input is gathering event from.
  34430. */
  34431. gamepad: Nullable<Gamepad>;
  34432. /**
  34433. * Defines the gamepad rotation sensiblity.
  34434. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  34435. */
  34436. gamepadRotationSensibility: number;
  34437. /**
  34438. * Defines the gamepad move sensiblity.
  34439. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  34440. */
  34441. gamepadMoveSensibility: number;
  34442. private _onGamepadConnectedObserver;
  34443. private _onGamepadDisconnectedObserver;
  34444. /**
  34445. * Attach the input controls to a specific dom element to get the input from.
  34446. * @param element Defines the element the controls should be listened from
  34447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34448. */
  34449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34450. /**
  34451. * Detach the current controls from the specified dom element.
  34452. * @param element Defines the element to stop listening the inputs from
  34453. */
  34454. detachControl(element: Nullable<HTMLElement>): void;
  34455. /**
  34456. * Update the current camera state depending on the inputs that have been used this frame.
  34457. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34458. */
  34459. checkInputs(): void;
  34460. /**
  34461. * Gets the class name of the current intput.
  34462. * @returns the class name
  34463. */
  34464. getClassName(): string;
  34465. /**
  34466. * Get the friendly name associated with the input class.
  34467. * @returns the input friendly name
  34468. */
  34469. getSimpleName(): string;
  34470. }
  34471. }
  34472. declare module BABYLON {
  34473. interface ArcRotateCameraInputsManager {
  34474. /**
  34475. * Add orientation input support to the input manager.
  34476. * @returns the current input manager
  34477. */
  34478. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  34479. }
  34480. /**
  34481. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  34482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34483. */
  34484. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  34485. /**
  34486. * Defines the camera the input is attached to.
  34487. */
  34488. camera: ArcRotateCamera;
  34489. /**
  34490. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  34491. */
  34492. alphaCorrection: number;
  34493. /**
  34494. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  34495. */
  34496. gammaCorrection: number;
  34497. private _alpha;
  34498. private _gamma;
  34499. private _dirty;
  34500. private _deviceOrientationHandler;
  34501. /**
  34502. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  34503. */
  34504. constructor();
  34505. /**
  34506. * Attach the input controls to a specific dom element to get the input from.
  34507. * @param element Defines the element the controls should be listened from
  34508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34509. */
  34510. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34511. /** @hidden */ onOrientationEvent(evt: DeviceOrientationEvent): void;
  34512. /**
  34513. * Update the current camera state depending on the inputs that have been used this frame.
  34514. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34515. */
  34516. checkInputs(): void;
  34517. /**
  34518. * Detach the current controls from the specified dom element.
  34519. * @param element Defines the element to stop listening the inputs from
  34520. */
  34521. detachControl(element: Nullable<HTMLElement>): void;
  34522. /**
  34523. * Gets the class name of the current intput.
  34524. * @returns the class name
  34525. */
  34526. getClassName(): string;
  34527. /**
  34528. * Get the friendly name associated with the input class.
  34529. * @returns the input friendly name
  34530. */
  34531. getSimpleName(): string;
  34532. }
  34533. }
  34534. declare module BABYLON {
  34535. /**
  34536. * Listen to mouse events to control the camera.
  34537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34538. */
  34539. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  34540. /**
  34541. * Defines the camera the input is attached to.
  34542. */
  34543. camera: FlyCamera;
  34544. /**
  34545. * Defines if touch is enabled. (Default is true.)
  34546. */
  34547. touchEnabled: boolean;
  34548. /**
  34549. * Defines the buttons associated with the input to handle camera rotation.
  34550. */
  34551. buttons: number[];
  34552. /**
  34553. * Assign buttons for Yaw control.
  34554. */
  34555. buttonsYaw: number[];
  34556. /**
  34557. * Assign buttons for Pitch control.
  34558. */
  34559. buttonsPitch: number[];
  34560. /**
  34561. * Assign buttons for Roll control.
  34562. */
  34563. buttonsRoll: number[];
  34564. /**
  34565. * Detect if any button is being pressed while mouse is moved.
  34566. * -1 = Mouse locked.
  34567. * 0 = Left button.
  34568. * 1 = Middle Button.
  34569. * 2 = Right Button.
  34570. */
  34571. activeButton: number;
  34572. /**
  34573. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  34574. * Higher values reduce its sensitivity.
  34575. */
  34576. angularSensibility: number;
  34577. private _mousemoveCallback;
  34578. private _observer;
  34579. private _rollObserver;
  34580. private previousPosition;
  34581. private noPreventDefault;
  34582. private element;
  34583. /**
  34584. * Listen to mouse events to control the camera.
  34585. * @param touchEnabled Define if touch is enabled. (Default is true.)
  34586. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34587. */
  34588. constructor(touchEnabled?: boolean);
  34589. /**
  34590. * Attach the mouse control to the HTML DOM element.
  34591. * @param element Defines the element that listens to the input events.
  34592. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  34593. */
  34594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34595. /**
  34596. * Detach the current controls from the specified dom element.
  34597. * @param element Defines the element to stop listening the inputs from
  34598. */
  34599. detachControl(element: Nullable<HTMLElement>): void;
  34600. /**
  34601. * Gets the class name of the current input.
  34602. * @returns the class name.
  34603. */
  34604. getClassName(): string;
  34605. /**
  34606. * Get the friendly name associated with the input class.
  34607. * @returns the input's friendly name.
  34608. */
  34609. getSimpleName(): string;
  34610. private _pointerInput;
  34611. private _onMouseMove;
  34612. /**
  34613. * Rotate camera by mouse offset.
  34614. */
  34615. private rotateCamera;
  34616. }
  34617. }
  34618. declare module BABYLON {
  34619. /**
  34620. * Default Inputs manager for the FlyCamera.
  34621. * It groups all the default supported inputs for ease of use.
  34622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34623. */
  34624. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  34625. /**
  34626. * Instantiates a new FlyCameraInputsManager.
  34627. * @param camera Defines the camera the inputs belong to.
  34628. */
  34629. constructor(camera: FlyCamera);
  34630. /**
  34631. * Add keyboard input support to the input manager.
  34632. * @returns the new FlyCameraKeyboardMoveInput().
  34633. */
  34634. addKeyboard(): FlyCameraInputsManager;
  34635. /**
  34636. * Add mouse input support to the input manager.
  34637. * @param touchEnabled Enable touch screen support.
  34638. * @returns the new FlyCameraMouseInput().
  34639. */
  34640. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  34641. }
  34642. }
  34643. declare module BABYLON {
  34644. /**
  34645. * This is a flying camera, designed for 3D movement and rotation in all directions,
  34646. * such as in a 3D Space Shooter or a Flight Simulator.
  34647. */
  34648. export class FlyCamera extends TargetCamera {
  34649. /**
  34650. * Define the collision ellipsoid of the camera.
  34651. * This is helpful for simulating a camera body, like a player's body.
  34652. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34653. */
  34654. ellipsoid: Vector3;
  34655. /**
  34656. * Define an offset for the position of the ellipsoid around the camera.
  34657. * This can be helpful if the camera is attached away from the player's body center,
  34658. * such as at its head.
  34659. */
  34660. ellipsoidOffset: Vector3;
  34661. /**
  34662. * Enable or disable collisions of the camera with the rest of the scene objects.
  34663. */
  34664. checkCollisions: boolean;
  34665. /**
  34666. * Enable or disable gravity on the camera.
  34667. */
  34668. applyGravity: boolean;
  34669. /**
  34670. * Define the current direction the camera is moving to.
  34671. */
  34672. cameraDirection: Vector3;
  34673. /**
  34674. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  34675. * This overrides and empties cameraRotation.
  34676. */
  34677. rotationQuaternion: Quaternion;
  34678. /**
  34679. * Track Roll to maintain the wanted Rolling when looking around.
  34680. */ trackRoll: number;
  34681. /**
  34682. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  34683. */
  34684. rollCorrect: number;
  34685. /**
  34686. * Mimic a banked turn, Rolling the camera when Yawing.
  34687. * It's recommended to use rollCorrect = 10 for faster banking correction.
  34688. */
  34689. bankedTurn: boolean;
  34690. /**
  34691. * Limit in radians for how much Roll banking will add. (Default: 90°)
  34692. */
  34693. bankedTurnLimit: number;
  34694. /**
  34695. * Value of 0 disables the banked Roll.
  34696. * Value of 1 is equal to the Yaw angle in radians.
  34697. */
  34698. bankedTurnMultiplier: number;
  34699. /**
  34700. * The inputs manager loads all the input sources, such as keyboard and mouse.
  34701. */
  34702. inputs: FlyCameraInputsManager;
  34703. /**
  34704. * Gets the input sensibility for mouse input.
  34705. * Higher values reduce sensitivity.
  34706. */
  34707. /**
  34708. * Sets the input sensibility for a mouse input.
  34709. * Higher values reduce sensitivity.
  34710. */
  34711. angularSensibility: number;
  34712. /**
  34713. * Get the keys for camera movement forward.
  34714. */
  34715. /**
  34716. * Set the keys for camera movement forward.
  34717. */
  34718. keysForward: number[];
  34719. /**
  34720. * Get the keys for camera movement backward.
  34721. */
  34722. keysBackward: number[];
  34723. /**
  34724. * Get the keys for camera movement up.
  34725. */
  34726. /**
  34727. * Set the keys for camera movement up.
  34728. */
  34729. keysUp: number[];
  34730. /**
  34731. * Get the keys for camera movement down.
  34732. */
  34733. /**
  34734. * Set the keys for camera movement down.
  34735. */
  34736. keysDown: number[];
  34737. /**
  34738. * Get the keys for camera movement left.
  34739. */
  34740. /**
  34741. * Set the keys for camera movement left.
  34742. */
  34743. keysLeft: number[];
  34744. /**
  34745. * Set the keys for camera movement right.
  34746. */
  34747. /**
  34748. * Set the keys for camera movement right.
  34749. */
  34750. keysRight: number[];
  34751. /**
  34752. * Event raised when the camera collides with a mesh in the scene.
  34753. */
  34754. onCollide: (collidedMesh: AbstractMesh) => void;
  34755. private _collider;
  34756. private _needMoveForGravity;
  34757. private _oldPosition;
  34758. private _diffPosition;
  34759. private _newPosition;
  34760. /** @hidden */ localDirection: Vector3;
  34761. /** @hidden */ transformedDirection: Vector3;
  34762. /**
  34763. * Instantiates a FlyCamera.
  34764. * This is a flying camera, designed for 3D movement and rotation in all directions,
  34765. * such as in a 3D Space Shooter or a Flight Simulator.
  34766. * @param name Define the name of the camera in the scene.
  34767. * @param position Define the starting position of the camera in the scene.
  34768. * @param scene Define the scene the camera belongs to.
  34769. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  34770. */
  34771. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34772. /**
  34773. * Attach a control to the HTML DOM element.
  34774. * @param element Defines the element that listens to the input events.
  34775. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  34776. */
  34777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34778. /**
  34779. * Detach a control from the HTML DOM element.
  34780. * The camera will stop reacting to that input.
  34781. * @param element Defines the element that listens to the input events.
  34782. */
  34783. detachControl(element: HTMLElement): void;
  34784. private _collisionMask;
  34785. /**
  34786. * Get the mask that the camera ignores in collision events.
  34787. */
  34788. /**
  34789. * Set the mask that the camera ignores in collision events.
  34790. */
  34791. collisionMask: number;
  34792. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  34793. /** @hidden */
  34794. private _onCollisionPositionChange;
  34795. /** @hidden */ checkInputs(): void;
  34796. /** @hidden */ decideIfNeedsToMove(): boolean;
  34797. /** @hidden */ updatePosition(): void;
  34798. /**
  34799. * Restore the Roll to its target value at the rate specified.
  34800. * @param rate - Higher means slower restoring.
  34801. * @hidden
  34802. */
  34803. restoreRoll(rate: number): void;
  34804. /**
  34805. * Destroy the camera and release the current resources held by it.
  34806. */
  34807. dispose(): void;
  34808. /**
  34809. * Get the current object class name.
  34810. * @returns the class name.
  34811. */
  34812. getClassName(): string;
  34813. }
  34814. }
  34815. declare module BABYLON {
  34816. /**
  34817. * Listen to keyboard events to control the camera.
  34818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34819. */
  34820. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  34821. /**
  34822. * Defines the camera the input is attached to.
  34823. */
  34824. camera: FlyCamera;
  34825. /**
  34826. * The list of keyboard keys used to control the forward move of the camera.
  34827. */
  34828. keysForward: number[];
  34829. /**
  34830. * The list of keyboard keys used to control the backward move of the camera.
  34831. */
  34832. keysBackward: number[];
  34833. /**
  34834. * The list of keyboard keys used to control the forward move of the camera.
  34835. */
  34836. keysUp: number[];
  34837. /**
  34838. * The list of keyboard keys used to control the backward move of the camera.
  34839. */
  34840. keysDown: number[];
  34841. /**
  34842. * The list of keyboard keys used to control the right strafe move of the camera.
  34843. */
  34844. keysRight: number[];
  34845. /**
  34846. * The list of keyboard keys used to control the left strafe move of the camera.
  34847. */
  34848. keysLeft: number[];
  34849. private _keys;
  34850. private _onCanvasBlurObserver;
  34851. private _onKeyboardObserver;
  34852. private _engine;
  34853. private _scene;
  34854. /**
  34855. * Attach the input controls to a specific dom element to get the input from.
  34856. * @param element Defines the element the controls should be listened from
  34857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34858. */
  34859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34860. /**
  34861. * Detach the current controls from the specified dom element.
  34862. * @param element Defines the element to stop listening the inputs from
  34863. */
  34864. detachControl(element: Nullable<HTMLElement>): void;
  34865. /**
  34866. * Gets the class name of the current intput.
  34867. * @returns the class name
  34868. */
  34869. getClassName(): string;
  34870. /** @hidden */ onLostFocus(e: FocusEvent): void;
  34871. /**
  34872. * Get the friendly name associated with the input class.
  34873. * @returns the input friendly name
  34874. */
  34875. getSimpleName(): string;
  34876. /**
  34877. * Update the current camera state depending on the inputs that have been used this frame.
  34878. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34879. */
  34880. checkInputs(): void;
  34881. }
  34882. }
  34883. declare module BABYLON {
  34884. interface FreeCameraInputsManager {
  34885. /**
  34886. * Add orientation input support to the input manager.
  34887. * @returns the current input manager
  34888. */
  34889. addDeviceOrientation(): FreeCameraInputsManager;
  34890. }
  34891. /**
  34892. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  34893. * Screen rotation is taken into account.
  34894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34895. */
  34896. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  34897. private _camera;
  34898. private _screenOrientationAngle;
  34899. private _constantTranform;
  34900. private _screenQuaternion;
  34901. private _alpha;
  34902. private _beta;
  34903. private _gamma;
  34904. /**
  34905. * Instantiates a new input
  34906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34907. */
  34908. constructor();
  34909. /**
  34910. * Define the camera controlled by the input.
  34911. */
  34912. camera: FreeCamera;
  34913. /**
  34914. * Attach the input controls to a specific dom element to get the input from.
  34915. * @param element Defines the element the controls should be listened from
  34916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34917. */
  34918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34919. private _orientationChanged;
  34920. private _deviceOrientation;
  34921. /**
  34922. * Detach the current controls from the specified dom element.
  34923. * @param element Defines the element to stop listening the inputs from
  34924. */
  34925. detachControl(element: Nullable<HTMLElement>): void;
  34926. /**
  34927. * Update the current camera state depending on the inputs that have been used this frame.
  34928. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34929. */
  34930. checkInputs(): void;
  34931. /**
  34932. * Gets the class name of the current intput.
  34933. * @returns the class name
  34934. */
  34935. getClassName(): string;
  34936. /**
  34937. * Get the friendly name associated with the input class.
  34938. * @returns the input friendly name
  34939. */
  34940. getSimpleName(): string;
  34941. }
  34942. }
  34943. declare module BABYLON {
  34944. /**
  34945. * Manage the gamepad inputs to control a free camera.
  34946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34947. */
  34948. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  34949. /**
  34950. * Define the camera the input is attached to.
  34951. */
  34952. camera: FreeCamera;
  34953. /**
  34954. * Define the Gamepad controlling the input
  34955. */
  34956. gamepad: Nullable<Gamepad>;
  34957. /**
  34958. * Defines the gamepad rotation sensiblity.
  34959. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  34960. */
  34961. gamepadAngularSensibility: number;
  34962. /**
  34963. * Defines the gamepad move sensiblity.
  34964. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  34965. */
  34966. gamepadMoveSensibility: number;
  34967. private _onGamepadConnectedObserver;
  34968. private _onGamepadDisconnectedObserver;
  34969. private _cameraTransform;
  34970. private _deltaTransform;
  34971. private _vector3;
  34972. private _vector2;
  34973. /**
  34974. * Attach the input controls to a specific dom element to get the input from.
  34975. * @param element Defines the element the controls should be listened from
  34976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34977. */
  34978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34979. /**
  34980. * Detach the current controls from the specified dom element.
  34981. * @param element Defines the element to stop listening the inputs from
  34982. */
  34983. detachControl(element: Nullable<HTMLElement>): void;
  34984. /**
  34985. * Update the current camera state depending on the inputs that have been used this frame.
  34986. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34987. */
  34988. checkInputs(): void;
  34989. /**
  34990. * Gets the class name of the current intput.
  34991. * @returns the class name
  34992. */
  34993. getClassName(): string;
  34994. /**
  34995. * Get the friendly name associated with the input class.
  34996. * @returns the input friendly name
  34997. */
  34998. getSimpleName(): string;
  34999. }
  35000. }
  35001. declare module BABYLON {
  35002. /**
  35003. * Defines the potential axis of a Joystick
  35004. */
  35005. export enum JoystickAxis {
  35006. /** X axis */
  35007. X = 0,
  35008. /** Y axis */
  35009. Y = 1,
  35010. /** Z axis */
  35011. Z = 2
  35012. }
  35013. /**
  35014. * Class used to define virtual joystick (used in touch mode)
  35015. */
  35016. export class VirtualJoystick {
  35017. /**
  35018. * Gets or sets a boolean indicating that left and right values must be inverted
  35019. */
  35020. reverseLeftRight: boolean;
  35021. /**
  35022. * Gets or sets a boolean indicating that up and down values must be inverted
  35023. */
  35024. reverseUpDown: boolean;
  35025. /**
  35026. * Gets the offset value for the position (ie. the change of the position value)
  35027. */
  35028. deltaPosition: Vector3;
  35029. /**
  35030. * Gets a boolean indicating if the virtual joystick was pressed
  35031. */
  35032. pressed: boolean;
  35033. /**
  35034. * Canvas the virtual joystick will render onto, default z-index of this is 5
  35035. */
  35036. static Canvas: Nullable<HTMLCanvasElement>;
  35037. private static _globalJoystickIndex;
  35038. private static vjCanvasContext;
  35039. private static vjCanvasWidth;
  35040. private static vjCanvasHeight;
  35041. private static halfWidth;
  35042. private _action;
  35043. private _axisTargetedByLeftAndRight;
  35044. private _axisTargetedByUpAndDown;
  35045. private _joystickSensibility;
  35046. private _inversedSensibility;
  35047. private _joystickPointerID;
  35048. private _joystickColor;
  35049. private _joystickPointerPos;
  35050. private _joystickPreviousPointerPos;
  35051. private _joystickPointerStartPos;
  35052. private _deltaJoystickVector;
  35053. private _leftJoystick;
  35054. private _touches;
  35055. private _onPointerDownHandlerRef;
  35056. private _onPointerMoveHandlerRef;
  35057. private _onPointerUpHandlerRef;
  35058. private _onResize;
  35059. /**
  35060. * Creates a new virtual joystick
  35061. * @param leftJoystick defines that the joystick is for left hand (false by default)
  35062. */
  35063. constructor(leftJoystick?: boolean);
  35064. /**
  35065. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  35066. * @param newJoystickSensibility defines the new sensibility
  35067. */
  35068. setJoystickSensibility(newJoystickSensibility: number): void;
  35069. private _onPointerDown;
  35070. private _onPointerMove;
  35071. private _onPointerUp;
  35072. /**
  35073. * Change the color of the virtual joystick
  35074. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  35075. */
  35076. setJoystickColor(newColor: string): void;
  35077. /**
  35078. * Defines a callback to call when the joystick is touched
  35079. * @param action defines the callback
  35080. */
  35081. setActionOnTouch(action: () => any): void;
  35082. /**
  35083. * Defines which axis you'd like to control for left & right
  35084. * @param axis defines the axis to use
  35085. */
  35086. setAxisForLeftRight(axis: JoystickAxis): void;
  35087. /**
  35088. * Defines which axis you'd like to control for up & down
  35089. * @param axis defines the axis to use
  35090. */
  35091. setAxisForUpDown(axis: JoystickAxis): void;
  35092. private _drawVirtualJoystick;
  35093. /**
  35094. * Release internal HTML canvas
  35095. */
  35096. releaseCanvas(): void;
  35097. }
  35098. }
  35099. declare module BABYLON {
  35100. interface FreeCameraInputsManager {
  35101. /**
  35102. * Add virtual joystick input support to the input manager.
  35103. * @returns the current input manager
  35104. */
  35105. addVirtualJoystick(): FreeCameraInputsManager;
  35106. }
  35107. /**
  35108. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  35109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35110. */
  35111. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  35112. /**
  35113. * Defines the camera the input is attached to.
  35114. */
  35115. camera: FreeCamera;
  35116. private _leftjoystick;
  35117. private _rightjoystick;
  35118. /**
  35119. * Gets the left stick of the virtual joystick.
  35120. * @returns The virtual Joystick
  35121. */
  35122. getLeftJoystick(): VirtualJoystick;
  35123. /**
  35124. * Gets the right stick of the virtual joystick.
  35125. * @returns The virtual Joystick
  35126. */
  35127. getRightJoystick(): VirtualJoystick;
  35128. /**
  35129. * Update the current camera state depending on the inputs that have been used this frame.
  35130. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35131. */
  35132. checkInputs(): void;
  35133. /**
  35134. * Attach the input controls to a specific dom element to get the input from.
  35135. * @param element Defines the element the controls should be listened from
  35136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35137. */
  35138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35139. /**
  35140. * Detach the current controls from the specified dom element.
  35141. * @param element Defines the element to stop listening the inputs from
  35142. */
  35143. detachControl(element: Nullable<HTMLElement>): void;
  35144. /**
  35145. * Gets the class name of the current intput.
  35146. * @returns the class name
  35147. */
  35148. getClassName(): string;
  35149. /**
  35150. * Get the friendly name associated with the input class.
  35151. * @returns the input friendly name
  35152. */
  35153. getSimpleName(): string;
  35154. }
  35155. }
  35156. declare module BABYLON {
  35157. /**
  35158. * This represents a FPS type of camera controlled by touch.
  35159. * This is like a universal camera minus the Gamepad controls.
  35160. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35161. */
  35162. export class TouchCamera extends FreeCamera {
  35163. /**
  35164. * Defines the touch sensibility for rotation.
  35165. * The higher the faster.
  35166. */
  35167. touchAngularSensibility: number;
  35168. /**
  35169. * Defines the touch sensibility for move.
  35170. * The higher the faster.
  35171. */
  35172. touchMoveSensibility: number;
  35173. /**
  35174. * Instantiates a new touch camera.
  35175. * This represents a FPS type of camera controlled by touch.
  35176. * This is like a universal camera minus the Gamepad controls.
  35177. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35178. * @param name Define the name of the camera in the scene
  35179. * @param position Define the start position of the camera in the scene
  35180. * @param scene Define the scene the camera belongs to
  35181. */
  35182. constructor(name: string, position: Vector3, scene: Scene);
  35183. /**
  35184. * Gets the current object class name.
  35185. * @return the class name
  35186. */
  35187. getClassName(): string;
  35188. /** @hidden */ setupInputs(): void;
  35189. }
  35190. }
  35191. declare module BABYLON {
  35192. /**
  35193. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  35194. * being tilted forward or back and left or right.
  35195. */
  35196. export class DeviceOrientationCamera extends FreeCamera {
  35197. private _initialQuaternion;
  35198. private _quaternionCache;
  35199. /**
  35200. * Creates a new device orientation camera
  35201. * @param name The name of the camera
  35202. * @param position The start position camera
  35203. * @param scene The scene the camera belongs to
  35204. */
  35205. constructor(name: string, position: Vector3, scene: Scene);
  35206. /**
  35207. * Gets the current instance class name ("DeviceOrientationCamera").
  35208. * This helps avoiding instanceof at run time.
  35209. * @returns the class name
  35210. */
  35211. getClassName(): string;
  35212. /**
  35213. * @hidden
  35214. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  35215. */ checkInputs(): void;
  35216. /**
  35217. * Reset the camera to its default orientation on the specified axis only.
  35218. * @param axis The axis to reset
  35219. */
  35220. resetToCurrentRotation(axis?: Axis): void;
  35221. }
  35222. }
  35223. declare module BABYLON {
  35224. /**
  35225. * Manage the keyboard inputs to control the movement of a follow camera.
  35226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35227. */
  35228. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  35229. /**
  35230. * Defines the camera the input is attached to.
  35231. */
  35232. camera: FollowCamera;
  35233. /**
  35234. * Defines the list of key codes associated with the up action (increase heightOffset)
  35235. */
  35236. keysHeightOffsetIncr: number[];
  35237. /**
  35238. * Defines the list of key codes associated with the down action (decrease heightOffset)
  35239. */
  35240. keysHeightOffsetDecr: number[];
  35241. /**
  35242. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  35243. */
  35244. keysHeightOffsetModifierAlt: boolean;
  35245. /**
  35246. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  35247. */
  35248. keysHeightOffsetModifierCtrl: boolean;
  35249. /**
  35250. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  35251. */
  35252. keysHeightOffsetModifierShift: boolean;
  35253. /**
  35254. * Defines the list of key codes associated with the left action (increase rotationOffset)
  35255. */
  35256. keysRotationOffsetIncr: number[];
  35257. /**
  35258. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  35259. */
  35260. keysRotationOffsetDecr: number[];
  35261. /**
  35262. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  35263. */
  35264. keysRotationOffsetModifierAlt: boolean;
  35265. /**
  35266. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  35267. */
  35268. keysRotationOffsetModifierCtrl: boolean;
  35269. /**
  35270. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  35271. */
  35272. keysRotationOffsetModifierShift: boolean;
  35273. /**
  35274. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  35275. */
  35276. keysRadiusIncr: number[];
  35277. /**
  35278. * Defines the list of key codes associated with the zoom-out action (increase radius)
  35279. */
  35280. keysRadiusDecr: number[];
  35281. /**
  35282. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  35283. */
  35284. keysRadiusModifierAlt: boolean;
  35285. /**
  35286. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  35287. */
  35288. keysRadiusModifierCtrl: boolean;
  35289. /**
  35290. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  35291. */
  35292. keysRadiusModifierShift: boolean;
  35293. /**
  35294. * Defines the rate of change of heightOffset.
  35295. */
  35296. heightSensibility: number;
  35297. /**
  35298. * Defines the rate of change of rotationOffset.
  35299. */
  35300. rotationSensibility: number;
  35301. /**
  35302. * Defines the rate of change of radius.
  35303. */
  35304. radiusSensibility: number;
  35305. private _keys;
  35306. private _ctrlPressed;
  35307. private _altPressed;
  35308. private _shiftPressed;
  35309. private _onCanvasBlurObserver;
  35310. private _onKeyboardObserver;
  35311. private _engine;
  35312. private _scene;
  35313. /**
  35314. * Attach the input controls to a specific dom element to get the input from.
  35315. * @param element Defines the element the controls should be listened from
  35316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35317. */
  35318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35319. /**
  35320. * Detach the current controls from the specified dom element.
  35321. * @param element Defines the element to stop listening the inputs from
  35322. */
  35323. detachControl(element: Nullable<HTMLElement>): void;
  35324. /**
  35325. * Update the current camera state depending on the inputs that have been used this frame.
  35326. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35327. */
  35328. checkInputs(): void;
  35329. /**
  35330. * Gets the class name of the current input.
  35331. * @returns the class name
  35332. */
  35333. getClassName(): string;
  35334. /**
  35335. * Get the friendly name associated with the input class.
  35336. * @returns the input friendly name
  35337. */
  35338. getSimpleName(): string;
  35339. /**
  35340. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35341. * allow modification of the heightOffset value.
  35342. */
  35343. private _modifierHeightOffset;
  35344. /**
  35345. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35346. * allow modification of the rotationOffset value.
  35347. */
  35348. private _modifierRotationOffset;
  35349. /**
  35350. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35351. * allow modification of the radius value.
  35352. */
  35353. private _modifierRadius;
  35354. }
  35355. }
  35356. declare module BABYLON {
  35357. /**
  35358. * Manage the mouse wheel inputs to control a follow camera.
  35359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35360. */
  35361. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35362. /**
  35363. * Defines the camera the input is attached to.
  35364. */
  35365. camera: FollowCamera;
  35366. /**
  35367. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  35368. */
  35369. axisControlRadius: boolean;
  35370. /**
  35371. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  35372. */
  35373. axisControlHeight: boolean;
  35374. /**
  35375. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  35376. */
  35377. axisControlRotation: boolean;
  35378. /**
  35379. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35380. * relation to mouseWheel events.
  35381. */
  35382. wheelPrecision: number;
  35383. /**
  35384. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35385. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35386. */
  35387. wheelDeltaPercentage: number;
  35388. private _wheel;
  35389. private _observer;
  35390. /**
  35391. * Attach the input controls to a specific dom element to get the input from.
  35392. * @param element Defines the element the controls should be listened from
  35393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35394. */
  35395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35396. /**
  35397. * Detach the current controls from the specified dom element.
  35398. * @param element Defines the element to stop listening the inputs from
  35399. */
  35400. detachControl(element: Nullable<HTMLElement>): void;
  35401. /**
  35402. * Gets the class name of the current intput.
  35403. * @returns the class name
  35404. */
  35405. getClassName(): string;
  35406. /**
  35407. * Get the friendly name associated with the input class.
  35408. * @returns the input friendly name
  35409. */
  35410. getSimpleName(): string;
  35411. }
  35412. }
  35413. declare module BABYLON {
  35414. /**
  35415. * Default Inputs manager for the FollowCamera.
  35416. * It groups all the default supported inputs for ease of use.
  35417. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35418. */
  35419. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  35420. /**
  35421. * Instantiates a new FollowCameraInputsManager.
  35422. * @param camera Defines the camera the inputs belong to
  35423. */
  35424. constructor(camera: FollowCamera);
  35425. /**
  35426. * Add keyboard input support to the input manager.
  35427. * @returns the current input manager
  35428. */
  35429. addKeyboard(): FollowCameraInputsManager;
  35430. /**
  35431. * Add mouse wheel input support to the input manager.
  35432. * @returns the current input manager
  35433. */
  35434. addMouseWheel(): FollowCameraInputsManager;
  35435. /**
  35436. * Add pointers input support to the input manager.
  35437. * @returns the current input manager
  35438. */
  35439. addPointers(): FollowCameraInputsManager;
  35440. /**
  35441. * Add orientation input support to the input manager.
  35442. * @returns the current input manager
  35443. */
  35444. addVRDeviceOrientation(): FollowCameraInputsManager;
  35445. }
  35446. }
  35447. declare module BABYLON {
  35448. /**
  35449. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  35450. * an arc rotate version arcFollowCamera are available.
  35451. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35452. */
  35453. export class FollowCamera extends TargetCamera {
  35454. /**
  35455. * Distance the follow camera should follow an object at
  35456. */
  35457. radius: number;
  35458. /**
  35459. * Minimum allowed distance of the camera to the axis of rotation
  35460. * (The camera can not get closer).
  35461. * This can help limiting how the Camera is able to move in the scene.
  35462. */
  35463. lowerRadiusLimit: Nullable<number>;
  35464. /**
  35465. * Maximum allowed distance of the camera to the axis of rotation
  35466. * (The camera can not get further).
  35467. * This can help limiting how the Camera is able to move in the scene.
  35468. */
  35469. upperRadiusLimit: Nullable<number>;
  35470. /**
  35471. * Define a rotation offset between the camera and the object it follows
  35472. */
  35473. rotationOffset: number;
  35474. /**
  35475. * Minimum allowed angle to camera position relative to target object.
  35476. * This can help limiting how the Camera is able to move in the scene.
  35477. */
  35478. lowerRotationOffsetLimit: Nullable<number>;
  35479. /**
  35480. * Maximum allowed angle to camera position relative to target object.
  35481. * This can help limiting how the Camera is able to move in the scene.
  35482. */
  35483. upperRotationOffsetLimit: Nullable<number>;
  35484. /**
  35485. * Define a height offset between the camera and the object it follows.
  35486. * It can help following an object from the top (like a car chaing a plane)
  35487. */
  35488. heightOffset: number;
  35489. /**
  35490. * Minimum allowed height of camera position relative to target object.
  35491. * This can help limiting how the Camera is able to move in the scene.
  35492. */
  35493. lowerHeightOffsetLimit: Nullable<number>;
  35494. /**
  35495. * Maximum allowed height of camera position relative to target object.
  35496. * This can help limiting how the Camera is able to move in the scene.
  35497. */
  35498. upperHeightOffsetLimit: Nullable<number>;
  35499. /**
  35500. * Define how fast the camera can accelerate to follow it s target.
  35501. */
  35502. cameraAcceleration: number;
  35503. /**
  35504. * Define the speed limit of the camera following an object.
  35505. */
  35506. maxCameraSpeed: number;
  35507. /**
  35508. * Define the target of the camera.
  35509. */
  35510. lockedTarget: Nullable<AbstractMesh>;
  35511. /**
  35512. * Defines the input associated with the camera.
  35513. */
  35514. inputs: FollowCameraInputsManager;
  35515. /**
  35516. * Instantiates the follow camera.
  35517. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35518. * @param name Define the name of the camera in the scene
  35519. * @param position Define the position of the camera
  35520. * @param scene Define the scene the camera belong to
  35521. * @param lockedTarget Define the target of the camera
  35522. */
  35523. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  35524. private _follow;
  35525. /**
  35526. * Attached controls to the current camera.
  35527. * @param element Defines the element the controls should be listened from
  35528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35529. */
  35530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35531. /**
  35532. * Detach the current controls from the camera.
  35533. * The camera will stop reacting to inputs.
  35534. * @param element Defines the element to stop listening the inputs from
  35535. */
  35536. detachControl(element: HTMLElement): void;
  35537. /** @hidden */ checkInputs(): void;
  35538. private _checkLimits;
  35539. /**
  35540. * Gets the camera class name.
  35541. * @returns the class name
  35542. */
  35543. getClassName(): string;
  35544. }
  35545. /**
  35546. * Arc Rotate version of the follow camera.
  35547. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  35548. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35549. */
  35550. export class ArcFollowCamera extends TargetCamera {
  35551. /** The longitudinal angle of the camera */
  35552. alpha: number;
  35553. /** The latitudinal angle of the camera */
  35554. beta: number;
  35555. /** The radius of the camera from its target */
  35556. radius: number;
  35557. /** Define the camera target (the messh it should follow) */
  35558. target: Nullable<AbstractMesh>;
  35559. private _cartesianCoordinates;
  35560. /**
  35561. * Instantiates a new ArcFollowCamera
  35562. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35563. * @param name Define the name of the camera
  35564. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  35565. * @param beta Define the rotation angle of the camera around the elevation axis
  35566. * @param radius Define the radius of the camera from its target point
  35567. * @param target Define the target of the camera
  35568. * @param scene Define the scene the camera belongs to
  35569. */
  35570. constructor(name: string,
  35571. /** The longitudinal angle of the camera */
  35572. alpha: number,
  35573. /** The latitudinal angle of the camera */
  35574. beta: number,
  35575. /** The radius of the camera from its target */
  35576. radius: number,
  35577. /** Define the camera target (the messh it should follow) */
  35578. target: Nullable<AbstractMesh>, scene: Scene);
  35579. private _follow;
  35580. /** @hidden */ checkInputs(): void;
  35581. /**
  35582. * Returns the class name of the object.
  35583. * It is mostly used internally for serialization purposes.
  35584. */
  35585. getClassName(): string;
  35586. }
  35587. }
  35588. declare module BABYLON {
  35589. /**
  35590. * 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,
  35591. * which still works and will still be found in many Playgrounds.
  35592. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35593. */
  35594. export class UniversalCamera extends TouchCamera {
  35595. /**
  35596. * Defines the gamepad rotation sensiblity.
  35597. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35598. */
  35599. gamepadAngularSensibility: number;
  35600. /**
  35601. * Defines the gamepad move sensiblity.
  35602. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35603. */
  35604. gamepadMoveSensibility: number;
  35605. /**
  35606. * 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,
  35607. * which still works and will still be found in many Playgrounds.
  35608. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35609. * @param name Define the name of the camera in the scene
  35610. * @param position Define the start position of the camera in the scene
  35611. * @param scene Define the scene the camera belongs to
  35612. */
  35613. constructor(name: string, position: Vector3, scene: Scene);
  35614. /**
  35615. * Gets the current object class name.
  35616. * @return the class name
  35617. */
  35618. getClassName(): string;
  35619. }
  35620. }
  35621. declare module BABYLON {
  35622. /**
  35623. * This represents a FPS type of camera. This is only here for back compat purpose.
  35624. * Please use the UniversalCamera instead as both are identical.
  35625. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35626. */
  35627. export class GamepadCamera extends UniversalCamera {
  35628. /**
  35629. * Instantiates a new Gamepad Camera
  35630. * This represents a FPS type of camera. This is only here for back compat purpose.
  35631. * Please use the UniversalCamera instead as both are identical.
  35632. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35633. * @param name Define the name of the camera in the scene
  35634. * @param position Define the start position of the camera in the scene
  35635. * @param scene Define the scene the camera belongs to
  35636. */
  35637. constructor(name: string, position: Vector3, scene: Scene);
  35638. /**
  35639. * Gets the current object class name.
  35640. * @return the class name
  35641. */
  35642. getClassName(): string;
  35643. }
  35644. }
  35645. declare module BABYLON {
  35646. /** @hidden */
  35647. export var passPixelShader: {
  35648. name: string;
  35649. shader: string;
  35650. };
  35651. }
  35652. declare module BABYLON {
  35653. /** @hidden */
  35654. export var passCubePixelShader: {
  35655. name: string;
  35656. shader: string;
  35657. };
  35658. }
  35659. declare module BABYLON {
  35660. /**
  35661. * PassPostProcess which produces an output the same as it's input
  35662. */
  35663. export class PassPostProcess extends PostProcess {
  35664. /**
  35665. * Creates the PassPostProcess
  35666. * @param name The name of the effect.
  35667. * @param options The required width/height ratio to downsize to before computing the render pass.
  35668. * @param camera The camera to apply the render pass to.
  35669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35670. * @param engine The engine which the post process will be applied. (default: current engine)
  35671. * @param reusable If the post process can be reused on the same frame. (default: false)
  35672. * @param textureType The type of texture to be used when performing the post processing.
  35673. * @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)
  35674. */
  35675. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35676. }
  35677. /**
  35678. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  35679. */
  35680. export class PassCubePostProcess extends PostProcess {
  35681. private _face;
  35682. /**
  35683. * Gets or sets the cube face to display.
  35684. * * 0 is +X
  35685. * * 1 is -X
  35686. * * 2 is +Y
  35687. * * 3 is -Y
  35688. * * 4 is +Z
  35689. * * 5 is -Z
  35690. */
  35691. face: number;
  35692. /**
  35693. * Creates the PassCubePostProcess
  35694. * @param name The name of the effect.
  35695. * @param options The required width/height ratio to downsize to before computing the render pass.
  35696. * @param camera The camera to apply the render pass to.
  35697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35698. * @param engine The engine which the post process will be applied. (default: current engine)
  35699. * @param reusable If the post process can be reused on the same frame. (default: false)
  35700. * @param textureType The type of texture to be used when performing the post processing.
  35701. * @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)
  35702. */
  35703. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35704. }
  35705. }
  35706. declare module BABYLON {
  35707. /** @hidden */
  35708. export var anaglyphPixelShader: {
  35709. name: string;
  35710. shader: string;
  35711. };
  35712. }
  35713. declare module BABYLON {
  35714. /**
  35715. * Postprocess used to generate anaglyphic rendering
  35716. */
  35717. export class AnaglyphPostProcess extends PostProcess {
  35718. private _passedProcess;
  35719. /**
  35720. * Creates a new AnaglyphPostProcess
  35721. * @param name defines postprocess name
  35722. * @param options defines creation options or target ratio scale
  35723. * @param rigCameras defines cameras using this postprocess
  35724. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  35725. * @param engine defines hosting engine
  35726. * @param reusable defines if the postprocess will be reused multiple times per frame
  35727. */
  35728. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  35729. }
  35730. }
  35731. declare module BABYLON {
  35732. /**
  35733. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  35734. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  35735. */
  35736. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  35737. /**
  35738. * Creates a new AnaglyphArcRotateCamera
  35739. * @param name defines camera name
  35740. * @param alpha defines alpha angle (in radians)
  35741. * @param beta defines beta angle (in radians)
  35742. * @param radius defines radius
  35743. * @param target defines camera target
  35744. * @param interaxialDistance defines distance between each color axis
  35745. * @param scene defines the hosting scene
  35746. */
  35747. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  35748. /**
  35749. * Gets camera class name
  35750. * @returns AnaglyphArcRotateCamera
  35751. */
  35752. getClassName(): string;
  35753. }
  35754. }
  35755. declare module BABYLON {
  35756. /**
  35757. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  35758. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  35759. */
  35760. export class AnaglyphFreeCamera extends FreeCamera {
  35761. /**
  35762. * Creates a new AnaglyphFreeCamera
  35763. * @param name defines camera name
  35764. * @param position defines initial position
  35765. * @param interaxialDistance defines distance between each color axis
  35766. * @param scene defines the hosting scene
  35767. */
  35768. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  35769. /**
  35770. * Gets camera class name
  35771. * @returns AnaglyphFreeCamera
  35772. */
  35773. getClassName(): string;
  35774. }
  35775. }
  35776. declare module BABYLON {
  35777. /**
  35778. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  35779. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  35780. */
  35781. export class AnaglyphGamepadCamera extends GamepadCamera {
  35782. /**
  35783. * Creates a new AnaglyphGamepadCamera
  35784. * @param name defines camera name
  35785. * @param position defines initial position
  35786. * @param interaxialDistance defines distance between each color axis
  35787. * @param scene defines the hosting scene
  35788. */
  35789. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  35790. /**
  35791. * Gets camera class name
  35792. * @returns AnaglyphGamepadCamera
  35793. */
  35794. getClassName(): string;
  35795. }
  35796. }
  35797. declare module BABYLON {
  35798. /**
  35799. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  35800. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  35801. */
  35802. export class AnaglyphUniversalCamera extends UniversalCamera {
  35803. /**
  35804. * Creates a new AnaglyphUniversalCamera
  35805. * @param name defines camera name
  35806. * @param position defines initial position
  35807. * @param interaxialDistance defines distance between each color axis
  35808. * @param scene defines the hosting scene
  35809. */
  35810. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  35811. /**
  35812. * Gets camera class name
  35813. * @returns AnaglyphUniversalCamera
  35814. */
  35815. getClassName(): string;
  35816. }
  35817. }
  35818. declare module BABYLON {
  35819. /** @hidden */
  35820. export var stereoscopicInterlacePixelShader: {
  35821. name: string;
  35822. shader: string;
  35823. };
  35824. }
  35825. declare module BABYLON {
  35826. /**
  35827. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35828. */
  35829. export class StereoscopicInterlacePostProcess extends PostProcess {
  35830. private _stepSize;
  35831. private _passedProcess;
  35832. /**
  35833. * Initializes a StereoscopicInterlacePostProcess
  35834. * @param name The name of the effect.
  35835. * @param rigCameras The rig cameras to be appled to the post process
  35836. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35838. * @param engine The engine which the post process will be applied. (default: current engine)
  35839. * @param reusable If the post process can be reused on the same frame. (default: false)
  35840. */
  35841. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35842. }
  35843. }
  35844. declare module BABYLON {
  35845. /**
  35846. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  35847. * @see http://doc.babylonjs.com/features/cameras
  35848. */
  35849. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  35850. /**
  35851. * Creates a new StereoscopicArcRotateCamera
  35852. * @param name defines camera name
  35853. * @param alpha defines alpha angle (in radians)
  35854. * @param beta defines beta angle (in radians)
  35855. * @param radius defines radius
  35856. * @param target defines camera target
  35857. * @param interaxialDistance defines distance between each color axis
  35858. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  35859. * @param scene defines the hosting scene
  35860. */
  35861. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  35862. /**
  35863. * Gets camera class name
  35864. * @returns StereoscopicArcRotateCamera
  35865. */
  35866. getClassName(): string;
  35867. }
  35868. }
  35869. declare module BABYLON {
  35870. /**
  35871. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  35872. * @see http://doc.babylonjs.com/features/cameras
  35873. */
  35874. export class StereoscopicFreeCamera extends FreeCamera {
  35875. /**
  35876. * Creates a new StereoscopicFreeCamera
  35877. * @param name defines camera name
  35878. * @param position defines initial position
  35879. * @param interaxialDistance defines distance between each color axis
  35880. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  35881. * @param scene defines the hosting scene
  35882. */
  35883. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  35884. /**
  35885. * Gets camera class name
  35886. * @returns StereoscopicFreeCamera
  35887. */
  35888. getClassName(): string;
  35889. }
  35890. }
  35891. declare module BABYLON {
  35892. /**
  35893. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  35894. * @see http://doc.babylonjs.com/features/cameras
  35895. */
  35896. export class StereoscopicGamepadCamera extends GamepadCamera {
  35897. /**
  35898. * Creates a new StereoscopicGamepadCamera
  35899. * @param name defines camera name
  35900. * @param position defines initial position
  35901. * @param interaxialDistance defines distance between each color axis
  35902. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  35903. * @param scene defines the hosting scene
  35904. */
  35905. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  35906. /**
  35907. * Gets camera class name
  35908. * @returns StereoscopicGamepadCamera
  35909. */
  35910. getClassName(): string;
  35911. }
  35912. }
  35913. declare module BABYLON {
  35914. /**
  35915. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  35916. * @see http://doc.babylonjs.com/features/cameras
  35917. */
  35918. export class StereoscopicUniversalCamera extends UniversalCamera {
  35919. /**
  35920. * Creates a new StereoscopicUniversalCamera
  35921. * @param name defines camera name
  35922. * @param position defines initial position
  35923. * @param interaxialDistance defines distance between each color axis
  35924. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  35925. * @param scene defines the hosting scene
  35926. */
  35927. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  35928. /**
  35929. * Gets camera class name
  35930. * @returns StereoscopicUniversalCamera
  35931. */
  35932. getClassName(): string;
  35933. }
  35934. }
  35935. declare module BABYLON {
  35936. /**
  35937. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  35938. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  35939. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  35940. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  35941. */
  35942. export class VirtualJoysticksCamera extends FreeCamera {
  35943. /**
  35944. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  35945. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  35946. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  35947. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  35948. * @param name Define the name of the camera in the scene
  35949. * @param position Define the start position of the camera in the scene
  35950. * @param scene Define the scene the camera belongs to
  35951. */
  35952. constructor(name: string, position: Vector3, scene: Scene);
  35953. /**
  35954. * Gets the current object class name.
  35955. * @return the class name
  35956. */
  35957. getClassName(): string;
  35958. }
  35959. }
  35960. declare module BABYLON {
  35961. /**
  35962. * This represents all the required metrics to create a VR camera.
  35963. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  35964. */
  35965. export class VRCameraMetrics {
  35966. /**
  35967. * Define the horizontal resolution off the screen.
  35968. */
  35969. hResolution: number;
  35970. /**
  35971. * Define the vertical resolution off the screen.
  35972. */
  35973. vResolution: number;
  35974. /**
  35975. * Define the horizontal screen size.
  35976. */
  35977. hScreenSize: number;
  35978. /**
  35979. * Define the vertical screen size.
  35980. */
  35981. vScreenSize: number;
  35982. /**
  35983. * Define the vertical screen center position.
  35984. */
  35985. vScreenCenter: number;
  35986. /**
  35987. * Define the distance of the eyes to the screen.
  35988. */
  35989. eyeToScreenDistance: number;
  35990. /**
  35991. * Define the distance between both lenses
  35992. */
  35993. lensSeparationDistance: number;
  35994. /**
  35995. * Define the distance between both viewer's eyes.
  35996. */
  35997. interpupillaryDistance: number;
  35998. /**
  35999. * Define the distortion factor of the VR postprocess.
  36000. * Please, touch with care.
  36001. */
  36002. distortionK: number[];
  36003. /**
  36004. * Define the chromatic aberration correction factors for the VR post process.
  36005. */
  36006. chromaAbCorrection: number[];
  36007. /**
  36008. * Define the scale factor of the post process.
  36009. * The smaller the better but the slower.
  36010. */
  36011. postProcessScaleFactor: number;
  36012. /**
  36013. * Define an offset for the lens center.
  36014. */
  36015. lensCenterOffset: number;
  36016. /**
  36017. * Define if the current vr camera should compensate the distortion of the lense or not.
  36018. */
  36019. compensateDistortion: boolean;
  36020. /**
  36021. * Gets the rendering aspect ratio based on the provided resolutions.
  36022. */
  36023. readonly aspectRatio: number;
  36024. /**
  36025. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  36026. */
  36027. readonly aspectRatioFov: number;
  36028. /**
  36029. * @hidden
  36030. */
  36031. readonly leftHMatrix: Matrix;
  36032. /**
  36033. * @hidden
  36034. */
  36035. readonly rightHMatrix: Matrix;
  36036. /**
  36037. * @hidden
  36038. */
  36039. readonly leftPreViewMatrix: Matrix;
  36040. /**
  36041. * @hidden
  36042. */
  36043. readonly rightPreViewMatrix: Matrix;
  36044. /**
  36045. * Get the default VRMetrics based on the most generic setup.
  36046. * @returns the default vr metrics
  36047. */
  36048. static GetDefault(): VRCameraMetrics;
  36049. }
  36050. }
  36051. declare module BABYLON {
  36052. /** @hidden */
  36053. export var vrDistortionCorrectionPixelShader: {
  36054. name: string;
  36055. shader: string;
  36056. };
  36057. }
  36058. declare module BABYLON {
  36059. /**
  36060. * VRDistortionCorrectionPostProcess used for mobile VR
  36061. */
  36062. export class VRDistortionCorrectionPostProcess extends PostProcess {
  36063. private _isRightEye;
  36064. private _distortionFactors;
  36065. private _postProcessScaleFactor;
  36066. private _lensCenterOffset;
  36067. private _scaleIn;
  36068. private _scaleFactor;
  36069. private _lensCenter;
  36070. /**
  36071. * Initializes the VRDistortionCorrectionPostProcess
  36072. * @param name The name of the effect.
  36073. * @param camera The camera to apply the render pass to.
  36074. * @param isRightEye If this is for the right eye distortion
  36075. * @param vrMetrics All the required metrics for the VR camera
  36076. */
  36077. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36078. }
  36079. }
  36080. declare module BABYLON {
  36081. /**
  36082. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  36083. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36084. */
  36085. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  36086. /**
  36087. * Creates a new VRDeviceOrientationArcRotateCamera
  36088. * @param name defines camera name
  36089. * @param alpha defines the camera rotation along the logitudinal axis
  36090. * @param beta defines the camera rotation along the latitudinal axis
  36091. * @param radius defines the camera distance from its target
  36092. * @param target defines the camera target
  36093. * @param scene defines the scene the camera belongs to
  36094. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36095. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36096. */
  36097. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36098. /**
  36099. * Gets camera class name
  36100. * @returns VRDeviceOrientationArcRotateCamera
  36101. */
  36102. getClassName(): string;
  36103. }
  36104. }
  36105. declare module BABYLON {
  36106. /**
  36107. * Camera used to simulate VR rendering (based on FreeCamera)
  36108. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36109. */
  36110. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  36111. /**
  36112. * Creates a new VRDeviceOrientationFreeCamera
  36113. * @param name defines camera name
  36114. * @param position defines the start position of the camera
  36115. * @param scene defines the scene the camera belongs to
  36116. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36117. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36118. */
  36119. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36120. /**
  36121. * Gets camera class name
  36122. * @returns VRDeviceOrientationFreeCamera
  36123. */
  36124. getClassName(): string;
  36125. }
  36126. }
  36127. declare module BABYLON {
  36128. /**
  36129. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  36130. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36131. */
  36132. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  36133. /**
  36134. * Creates a new VRDeviceOrientationGamepadCamera
  36135. * @param name defines camera name
  36136. * @param position defines the start position of the camera
  36137. * @param scene defines the scene the camera belongs to
  36138. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36139. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36140. */
  36141. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36142. /**
  36143. * Gets camera class name
  36144. * @returns VRDeviceOrientationGamepadCamera
  36145. */
  36146. getClassName(): string;
  36147. }
  36148. }
  36149. declare module BABYLON {
  36150. /**
  36151. * Defines supported buttons for XBox360 compatible gamepads
  36152. */
  36153. export enum Xbox360Button {
  36154. /** A */
  36155. A = 0,
  36156. /** B */
  36157. B = 1,
  36158. /** X */
  36159. X = 2,
  36160. /** Y */
  36161. Y = 3,
  36162. /** Start */
  36163. Start = 4,
  36164. /** Back */
  36165. Back = 5,
  36166. /** Left button */
  36167. LB = 6,
  36168. /** Right button */
  36169. RB = 7,
  36170. /** Left stick */
  36171. LeftStick = 8,
  36172. /** Right stick */
  36173. RightStick = 9
  36174. }
  36175. /** Defines values for XBox360 DPad */
  36176. export enum Xbox360Dpad {
  36177. /** Up */
  36178. Up = 0,
  36179. /** Down */
  36180. Down = 1,
  36181. /** Left */
  36182. Left = 2,
  36183. /** Right */
  36184. Right = 3
  36185. }
  36186. /**
  36187. * Defines a XBox360 gamepad
  36188. */
  36189. export class Xbox360Pad extends Gamepad {
  36190. private _leftTrigger;
  36191. private _rightTrigger;
  36192. private _onlefttriggerchanged;
  36193. private _onrighttriggerchanged;
  36194. private _onbuttondown;
  36195. private _onbuttonup;
  36196. private _ondpaddown;
  36197. private _ondpadup;
  36198. /** Observable raised when a button is pressed */
  36199. onButtonDownObservable: Observable<Xbox360Button>;
  36200. /** Observable raised when a button is released */
  36201. onButtonUpObservable: Observable<Xbox360Button>;
  36202. /** Observable raised when a pad is pressed */
  36203. onPadDownObservable: Observable<Xbox360Dpad>;
  36204. /** Observable raised when a pad is released */
  36205. onPadUpObservable: Observable<Xbox360Dpad>;
  36206. private _buttonA;
  36207. private _buttonB;
  36208. private _buttonX;
  36209. private _buttonY;
  36210. private _buttonBack;
  36211. private _buttonStart;
  36212. private _buttonLB;
  36213. private _buttonRB;
  36214. private _buttonLeftStick;
  36215. private _buttonRightStick;
  36216. private _dPadUp;
  36217. private _dPadDown;
  36218. private _dPadLeft;
  36219. private _dPadRight;
  36220. private _isXboxOnePad;
  36221. /**
  36222. * Creates a new XBox360 gamepad object
  36223. * @param id defines the id of this gamepad
  36224. * @param index defines its index
  36225. * @param gamepad defines the internal HTML gamepad object
  36226. * @param xboxOne defines if it is a XBox One gamepad
  36227. */
  36228. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  36229. /**
  36230. * Defines the callback to call when left trigger is pressed
  36231. * @param callback defines the callback to use
  36232. */
  36233. onlefttriggerchanged(callback: (value: number) => void): void;
  36234. /**
  36235. * Defines the callback to call when right trigger is pressed
  36236. * @param callback defines the callback to use
  36237. */
  36238. onrighttriggerchanged(callback: (value: number) => void): void;
  36239. /**
  36240. * Gets the left trigger value
  36241. */
  36242. /**
  36243. * Sets the left trigger value
  36244. */
  36245. leftTrigger: number;
  36246. /**
  36247. * Gets the right trigger value
  36248. */
  36249. /**
  36250. * Sets the right trigger value
  36251. */
  36252. rightTrigger: number;
  36253. /**
  36254. * Defines the callback to call when a button is pressed
  36255. * @param callback defines the callback to use
  36256. */
  36257. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  36258. /**
  36259. * Defines the callback to call when a button is released
  36260. * @param callback defines the callback to use
  36261. */
  36262. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  36263. /**
  36264. * Defines the callback to call when a pad is pressed
  36265. * @param callback defines the callback to use
  36266. */
  36267. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  36268. /**
  36269. * Defines the callback to call when a pad is released
  36270. * @param callback defines the callback to use
  36271. */
  36272. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  36273. private _setButtonValue;
  36274. private _setDPadValue;
  36275. /**
  36276. * Gets the value of the `A` button
  36277. */
  36278. /**
  36279. * Sets the value of the `A` button
  36280. */
  36281. buttonA: number;
  36282. /**
  36283. * Gets the value of the `B` button
  36284. */
  36285. /**
  36286. * Sets the value of the `B` button
  36287. */
  36288. buttonB: number;
  36289. /**
  36290. * Gets the value of the `X` button
  36291. */
  36292. /**
  36293. * Sets the value of the `X` button
  36294. */
  36295. buttonX: number;
  36296. /**
  36297. * Gets the value of the `Y` button
  36298. */
  36299. /**
  36300. * Sets the value of the `Y` button
  36301. */
  36302. buttonY: number;
  36303. /**
  36304. * Gets the value of the `Start` button
  36305. */
  36306. /**
  36307. * Sets the value of the `Start` button
  36308. */
  36309. buttonStart: number;
  36310. /**
  36311. * Gets the value of the `Back` button
  36312. */
  36313. /**
  36314. * Sets the value of the `Back` button
  36315. */
  36316. buttonBack: number;
  36317. /**
  36318. * Gets the value of the `Left` button
  36319. */
  36320. /**
  36321. * Sets the value of the `Left` button
  36322. */
  36323. buttonLB: number;
  36324. /**
  36325. * Gets the value of the `Right` button
  36326. */
  36327. /**
  36328. * Sets the value of the `Right` button
  36329. */
  36330. buttonRB: number;
  36331. /**
  36332. * Gets the value of the Left joystick
  36333. */
  36334. /**
  36335. * Sets the value of the Left joystick
  36336. */
  36337. buttonLeftStick: number;
  36338. /**
  36339. * Gets the value of the Right joystick
  36340. */
  36341. /**
  36342. * Sets the value of the Right joystick
  36343. */
  36344. buttonRightStick: number;
  36345. /**
  36346. * Gets the value of D-pad up
  36347. */
  36348. /**
  36349. * Sets the value of D-pad up
  36350. */
  36351. dPadUp: number;
  36352. /**
  36353. * Gets the value of D-pad down
  36354. */
  36355. /**
  36356. * Sets the value of D-pad down
  36357. */
  36358. dPadDown: number;
  36359. /**
  36360. * Gets the value of D-pad left
  36361. */
  36362. /**
  36363. * Sets the value of D-pad left
  36364. */
  36365. dPadLeft: number;
  36366. /**
  36367. * Gets the value of D-pad right
  36368. */
  36369. /**
  36370. * Sets the value of D-pad right
  36371. */
  36372. dPadRight: number;
  36373. /**
  36374. * Force the gamepad to synchronize with device values
  36375. */
  36376. update(): void;
  36377. /**
  36378. * Disposes the gamepad
  36379. */
  36380. dispose(): void;
  36381. }
  36382. }
  36383. declare module BABYLON {
  36384. /**
  36385. * Base class of materials working in push mode in babylon JS
  36386. * @hidden
  36387. */
  36388. export class PushMaterial extends Material {
  36389. protected _activeEffect: Effect;
  36390. protected _normalMatrix: Matrix;
  36391. /**
  36392. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  36393. * This means that the material can keep using a previous shader while a new one is being compiled.
  36394. * This is mostly used when shader parallel compilation is supported (true by default)
  36395. */
  36396. allowShaderHotSwapping: boolean;
  36397. constructor(name: string, scene: Scene);
  36398. getEffect(): Effect;
  36399. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  36400. /**
  36401. * Binds the given world matrix to the active effect
  36402. *
  36403. * @param world the matrix to bind
  36404. */
  36405. bindOnlyWorldMatrix(world: Matrix): void;
  36406. /**
  36407. * Binds the given normal matrix to the active effect
  36408. *
  36409. * @param normalMatrix the matrix to bind
  36410. */
  36411. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  36412. bind(world: Matrix, mesh?: Mesh): void;
  36413. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  36414. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  36415. }
  36416. }
  36417. declare module BABYLON {
  36418. /**
  36419. * This groups all the flags used to control the materials channel.
  36420. */
  36421. export class MaterialFlags {
  36422. private static _DiffuseTextureEnabled;
  36423. /**
  36424. * Are diffuse textures enabled in the application.
  36425. */
  36426. static DiffuseTextureEnabled: boolean;
  36427. private static _AmbientTextureEnabled;
  36428. /**
  36429. * Are ambient textures enabled in the application.
  36430. */
  36431. static AmbientTextureEnabled: boolean;
  36432. private static _OpacityTextureEnabled;
  36433. /**
  36434. * Are opacity textures enabled in the application.
  36435. */
  36436. static OpacityTextureEnabled: boolean;
  36437. private static _ReflectionTextureEnabled;
  36438. /**
  36439. * Are reflection textures enabled in the application.
  36440. */
  36441. static ReflectionTextureEnabled: boolean;
  36442. private static _EmissiveTextureEnabled;
  36443. /**
  36444. * Are emissive textures enabled in the application.
  36445. */
  36446. static EmissiveTextureEnabled: boolean;
  36447. private static _SpecularTextureEnabled;
  36448. /**
  36449. * Are specular textures enabled in the application.
  36450. */
  36451. static SpecularTextureEnabled: boolean;
  36452. private static _BumpTextureEnabled;
  36453. /**
  36454. * Are bump textures enabled in the application.
  36455. */
  36456. static BumpTextureEnabled: boolean;
  36457. private static _LightmapTextureEnabled;
  36458. /**
  36459. * Are lightmap textures enabled in the application.
  36460. */
  36461. static LightmapTextureEnabled: boolean;
  36462. private static _RefractionTextureEnabled;
  36463. /**
  36464. * Are refraction textures enabled in the application.
  36465. */
  36466. static RefractionTextureEnabled: boolean;
  36467. private static _ColorGradingTextureEnabled;
  36468. /**
  36469. * Are color grading textures enabled in the application.
  36470. */
  36471. static ColorGradingTextureEnabled: boolean;
  36472. private static _FresnelEnabled;
  36473. /**
  36474. * Are fresnels enabled in the application.
  36475. */
  36476. static FresnelEnabled: boolean;
  36477. }
  36478. }
  36479. declare module BABYLON {
  36480. /** @hidden */
  36481. export var defaultFragmentDeclaration: {
  36482. name: string;
  36483. shader: string;
  36484. };
  36485. }
  36486. declare module BABYLON {
  36487. /** @hidden */
  36488. export var defaultUboDeclaration: {
  36489. name: string;
  36490. shader: string;
  36491. };
  36492. }
  36493. declare module BABYLON {
  36494. /** @hidden */
  36495. export var lightFragmentDeclaration: {
  36496. name: string;
  36497. shader: string;
  36498. };
  36499. }
  36500. declare module BABYLON {
  36501. /** @hidden */
  36502. export var lightUboDeclaration: {
  36503. name: string;
  36504. shader: string;
  36505. };
  36506. }
  36507. declare module BABYLON {
  36508. /** @hidden */
  36509. export var lightsFragmentFunctions: {
  36510. name: string;
  36511. shader: string;
  36512. };
  36513. }
  36514. declare module BABYLON {
  36515. /** @hidden */
  36516. export var shadowsFragmentFunctions: {
  36517. name: string;
  36518. shader: string;
  36519. };
  36520. }
  36521. declare module BABYLON {
  36522. /** @hidden */
  36523. export var fresnelFunction: {
  36524. name: string;
  36525. shader: string;
  36526. };
  36527. }
  36528. declare module BABYLON {
  36529. /** @hidden */
  36530. export var reflectionFunction: {
  36531. name: string;
  36532. shader: string;
  36533. };
  36534. }
  36535. declare module BABYLON {
  36536. /** @hidden */
  36537. export var bumpFragmentFunctions: {
  36538. name: string;
  36539. shader: string;
  36540. };
  36541. }
  36542. declare module BABYLON {
  36543. /** @hidden */
  36544. export var logDepthDeclaration: {
  36545. name: string;
  36546. shader: string;
  36547. };
  36548. }
  36549. declare module BABYLON {
  36550. /** @hidden */
  36551. export var bumpFragment: {
  36552. name: string;
  36553. shader: string;
  36554. };
  36555. }
  36556. declare module BABYLON {
  36557. /** @hidden */
  36558. export var depthPrePass: {
  36559. name: string;
  36560. shader: string;
  36561. };
  36562. }
  36563. declare module BABYLON {
  36564. /** @hidden */
  36565. export var lightFragment: {
  36566. name: string;
  36567. shader: string;
  36568. };
  36569. }
  36570. declare module BABYLON {
  36571. /** @hidden */
  36572. export var logDepthFragment: {
  36573. name: string;
  36574. shader: string;
  36575. };
  36576. }
  36577. declare module BABYLON {
  36578. /** @hidden */
  36579. export var defaultPixelShader: {
  36580. name: string;
  36581. shader: string;
  36582. };
  36583. }
  36584. declare module BABYLON {
  36585. /** @hidden */
  36586. export var defaultVertexDeclaration: {
  36587. name: string;
  36588. shader: string;
  36589. };
  36590. }
  36591. declare module BABYLON {
  36592. /** @hidden */
  36593. export var bumpVertexDeclaration: {
  36594. name: string;
  36595. shader: string;
  36596. };
  36597. }
  36598. declare module BABYLON {
  36599. /** @hidden */
  36600. export var bumpVertex: {
  36601. name: string;
  36602. shader: string;
  36603. };
  36604. }
  36605. declare module BABYLON {
  36606. /** @hidden */
  36607. export var fogVertex: {
  36608. name: string;
  36609. shader: string;
  36610. };
  36611. }
  36612. declare module BABYLON {
  36613. /** @hidden */
  36614. export var shadowsVertex: {
  36615. name: string;
  36616. shader: string;
  36617. };
  36618. }
  36619. declare module BABYLON {
  36620. /** @hidden */
  36621. export var pointCloudVertex: {
  36622. name: string;
  36623. shader: string;
  36624. };
  36625. }
  36626. declare module BABYLON {
  36627. /** @hidden */
  36628. export var logDepthVertex: {
  36629. name: string;
  36630. shader: string;
  36631. };
  36632. }
  36633. declare module BABYLON {
  36634. /** @hidden */
  36635. export var defaultVertexShader: {
  36636. name: string;
  36637. shader: string;
  36638. };
  36639. }
  36640. declare module BABYLON {
  36641. /** @hidden */
  36642. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  36643. MAINUV1: boolean;
  36644. MAINUV2: boolean;
  36645. DIFFUSE: boolean;
  36646. DIFFUSEDIRECTUV: number;
  36647. AMBIENT: boolean;
  36648. AMBIENTDIRECTUV: number;
  36649. OPACITY: boolean;
  36650. OPACITYDIRECTUV: number;
  36651. OPACITYRGB: boolean;
  36652. REFLECTION: boolean;
  36653. EMISSIVE: boolean;
  36654. EMISSIVEDIRECTUV: number;
  36655. SPECULAR: boolean;
  36656. SPECULARDIRECTUV: number;
  36657. BUMP: boolean;
  36658. BUMPDIRECTUV: number;
  36659. PARALLAX: boolean;
  36660. PARALLAXOCCLUSION: boolean;
  36661. SPECULAROVERALPHA: boolean;
  36662. CLIPPLANE: boolean;
  36663. CLIPPLANE2: boolean;
  36664. CLIPPLANE3: boolean;
  36665. CLIPPLANE4: boolean;
  36666. ALPHATEST: boolean;
  36667. DEPTHPREPASS: boolean;
  36668. ALPHAFROMDIFFUSE: boolean;
  36669. POINTSIZE: boolean;
  36670. FOG: boolean;
  36671. SPECULARTERM: boolean;
  36672. DIFFUSEFRESNEL: boolean;
  36673. OPACITYFRESNEL: boolean;
  36674. REFLECTIONFRESNEL: boolean;
  36675. REFRACTIONFRESNEL: boolean;
  36676. EMISSIVEFRESNEL: boolean;
  36677. FRESNEL: boolean;
  36678. NORMAL: boolean;
  36679. UV1: boolean;
  36680. UV2: boolean;
  36681. VERTEXCOLOR: boolean;
  36682. VERTEXALPHA: boolean;
  36683. NUM_BONE_INFLUENCERS: number;
  36684. BonesPerMesh: number;
  36685. BONETEXTURE: boolean;
  36686. INSTANCES: boolean;
  36687. GLOSSINESS: boolean;
  36688. ROUGHNESS: boolean;
  36689. EMISSIVEASILLUMINATION: boolean;
  36690. LINKEMISSIVEWITHDIFFUSE: boolean;
  36691. REFLECTIONFRESNELFROMSPECULAR: boolean;
  36692. LIGHTMAP: boolean;
  36693. LIGHTMAPDIRECTUV: number;
  36694. OBJECTSPACE_NORMALMAP: boolean;
  36695. USELIGHTMAPASSHADOWMAP: boolean;
  36696. REFLECTIONMAP_3D: boolean;
  36697. REFLECTIONMAP_SPHERICAL: boolean;
  36698. REFLECTIONMAP_PLANAR: boolean;
  36699. REFLECTIONMAP_CUBIC: boolean;
  36700. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  36701. REFLECTIONMAP_PROJECTION: boolean;
  36702. REFLECTIONMAP_SKYBOX: boolean;
  36703. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  36704. REFLECTIONMAP_EXPLICIT: boolean;
  36705. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  36706. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  36707. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  36708. INVERTCUBICMAP: boolean;
  36709. LOGARITHMICDEPTH: boolean;
  36710. REFRACTION: boolean;
  36711. REFRACTIONMAP_3D: boolean;
  36712. REFLECTIONOVERALPHA: boolean;
  36713. TWOSIDEDLIGHTING: boolean;
  36714. SHADOWFLOAT: boolean;
  36715. MORPHTARGETS: boolean;
  36716. MORPHTARGETS_NORMAL: boolean;
  36717. MORPHTARGETS_TANGENT: boolean;
  36718. NUM_MORPH_INFLUENCERS: number;
  36719. NONUNIFORMSCALING: boolean;
  36720. PREMULTIPLYALPHA: boolean;
  36721. IMAGEPROCESSING: boolean;
  36722. VIGNETTE: boolean;
  36723. VIGNETTEBLENDMODEMULTIPLY: boolean;
  36724. VIGNETTEBLENDMODEOPAQUE: boolean;
  36725. TONEMAPPING: boolean;
  36726. TONEMAPPING_ACES: boolean;
  36727. CONTRAST: boolean;
  36728. COLORCURVES: boolean;
  36729. COLORGRADING: boolean;
  36730. COLORGRADING3D: boolean;
  36731. SAMPLER3DGREENDEPTH: boolean;
  36732. SAMPLER3DBGRMAP: boolean;
  36733. IMAGEPROCESSINGPOSTPROCESS: boolean;
  36734. /**
  36735. * If the reflection texture on this material is in linear color space
  36736. * @hidden
  36737. */
  36738. IS_REFLECTION_LINEAR: boolean;
  36739. /**
  36740. * If the refraction texture on this material is in linear color space
  36741. * @hidden
  36742. */
  36743. IS_REFRACTION_LINEAR: boolean;
  36744. EXPOSURE: boolean;
  36745. constructor();
  36746. setReflectionMode(modeToEnable: string): void;
  36747. }
  36748. /**
  36749. * This is the default material used in Babylon. It is the best trade off between quality
  36750. * and performances.
  36751. * @see http://doc.babylonjs.com/babylon101/materials
  36752. */
  36753. export class StandardMaterial extends PushMaterial {
  36754. private _diffuseTexture;
  36755. /**
  36756. * The basic texture of the material as viewed under a light.
  36757. */
  36758. diffuseTexture: Nullable<BaseTexture>;
  36759. private _ambientTexture;
  36760. /**
  36761. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  36762. */
  36763. ambientTexture: Nullable<BaseTexture>;
  36764. private _opacityTexture;
  36765. /**
  36766. * Define the transparency of the material from a texture.
  36767. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  36768. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  36769. */
  36770. opacityTexture: Nullable<BaseTexture>;
  36771. private _reflectionTexture;
  36772. /**
  36773. * Define the texture used to display the reflection.
  36774. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  36775. */
  36776. reflectionTexture: Nullable<BaseTexture>;
  36777. private _emissiveTexture;
  36778. /**
  36779. * Define texture of the material as if self lit.
  36780. * This will be mixed in the final result even in the absence of light.
  36781. */
  36782. emissiveTexture: Nullable<BaseTexture>;
  36783. private _specularTexture;
  36784. /**
  36785. * Define how the color and intensity of the highlight given by the light in the material.
  36786. */
  36787. specularTexture: Nullable<BaseTexture>;
  36788. private _bumpTexture;
  36789. /**
  36790. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  36791. * 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.
  36792. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  36793. */
  36794. bumpTexture: Nullable<BaseTexture>;
  36795. private _lightmapTexture;
  36796. /**
  36797. * Complex lighting can be computationally expensive to compute at runtime.
  36798. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  36799. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  36800. */
  36801. lightmapTexture: Nullable<BaseTexture>;
  36802. private _refractionTexture;
  36803. /**
  36804. * Define the texture used to display the refraction.
  36805. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  36806. */
  36807. refractionTexture: Nullable<BaseTexture>;
  36808. /**
  36809. * The color of the material lit by the environmental background lighting.
  36810. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  36811. */
  36812. ambientColor: Color3;
  36813. /**
  36814. * The basic color of the material as viewed under a light.
  36815. */
  36816. diffuseColor: Color3;
  36817. /**
  36818. * Define how the color and intensity of the highlight given by the light in the material.
  36819. */
  36820. specularColor: Color3;
  36821. /**
  36822. * Define the color of the material as if self lit.
  36823. * This will be mixed in the final result even in the absence of light.
  36824. */
  36825. emissiveColor: Color3;
  36826. /**
  36827. * Defines how sharp are the highlights in the material.
  36828. * The bigger the value the sharper giving a more glossy feeling to the result.
  36829. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  36830. */
  36831. specularPower: number;
  36832. private _useAlphaFromDiffuseTexture;
  36833. /**
  36834. * Does the transparency come from the diffuse texture alpha channel.
  36835. */
  36836. useAlphaFromDiffuseTexture: boolean;
  36837. private _useEmissiveAsIllumination;
  36838. /**
  36839. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  36840. */
  36841. useEmissiveAsIllumination: boolean;
  36842. private _linkEmissiveWithDiffuse;
  36843. /**
  36844. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  36845. * the emissive level when the final color is close to one.
  36846. */
  36847. linkEmissiveWithDiffuse: boolean;
  36848. private _useSpecularOverAlpha;
  36849. /**
  36850. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  36851. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  36852. */
  36853. useSpecularOverAlpha: boolean;
  36854. private _useReflectionOverAlpha;
  36855. /**
  36856. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  36857. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  36858. */
  36859. useReflectionOverAlpha: boolean;
  36860. private _disableLighting;
  36861. /**
  36862. * Does lights from the scene impacts this material.
  36863. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  36864. */
  36865. disableLighting: boolean;
  36866. private _useObjectSpaceNormalMap;
  36867. /**
  36868. * Allows using an object space normal map (instead of tangent space).
  36869. */
  36870. useObjectSpaceNormalMap: boolean;
  36871. private _useParallax;
  36872. /**
  36873. * Is parallax enabled or not.
  36874. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  36875. */
  36876. useParallax: boolean;
  36877. private _useParallaxOcclusion;
  36878. /**
  36879. * Is parallax occlusion enabled or not.
  36880. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  36881. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  36882. */
  36883. useParallaxOcclusion: boolean;
  36884. /**
  36885. * 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.
  36886. */
  36887. parallaxScaleBias: number;
  36888. private _roughness;
  36889. /**
  36890. * Helps to define how blurry the reflections should appears in the material.
  36891. */
  36892. roughness: number;
  36893. /**
  36894. * In case of refraction, define the value of the indice of refraction.
  36895. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  36896. */
  36897. indexOfRefraction: number;
  36898. /**
  36899. * Invert the refraction texture alongside the y axis.
  36900. * It can be useful with procedural textures or probe for instance.
  36901. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  36902. */
  36903. invertRefractionY: boolean;
  36904. /**
  36905. * Defines the alpha limits in alpha test mode.
  36906. */
  36907. alphaCutOff: number;
  36908. private _useLightmapAsShadowmap;
  36909. /**
  36910. * In case of light mapping, define whether the map contains light or shadow informations.
  36911. */
  36912. useLightmapAsShadowmap: boolean;
  36913. private _diffuseFresnelParameters;
  36914. /**
  36915. * Define the diffuse fresnel parameters of the material.
  36916. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36917. */
  36918. diffuseFresnelParameters: FresnelParameters;
  36919. private _opacityFresnelParameters;
  36920. /**
  36921. * Define the opacity fresnel parameters of the material.
  36922. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36923. */
  36924. opacityFresnelParameters: FresnelParameters;
  36925. private _reflectionFresnelParameters;
  36926. /**
  36927. * Define the reflection fresnel parameters of the material.
  36928. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36929. */
  36930. reflectionFresnelParameters: FresnelParameters;
  36931. private _refractionFresnelParameters;
  36932. /**
  36933. * Define the refraction fresnel parameters of the material.
  36934. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36935. */
  36936. refractionFresnelParameters: FresnelParameters;
  36937. private _emissiveFresnelParameters;
  36938. /**
  36939. * Define the emissive fresnel parameters of the material.
  36940. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36941. */
  36942. emissiveFresnelParameters: FresnelParameters;
  36943. private _useReflectionFresnelFromSpecular;
  36944. /**
  36945. * If true automatically deducts the fresnels values from the material specularity.
  36946. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36947. */
  36948. useReflectionFresnelFromSpecular: boolean;
  36949. private _useGlossinessFromSpecularMapAlpha;
  36950. /**
  36951. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  36952. */
  36953. useGlossinessFromSpecularMapAlpha: boolean;
  36954. private _maxSimultaneousLights;
  36955. /**
  36956. * Defines the maximum number of lights that can be used in the material
  36957. */
  36958. maxSimultaneousLights: number;
  36959. private _invertNormalMapX;
  36960. /**
  36961. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  36962. */
  36963. invertNormalMapX: boolean;
  36964. private _invertNormalMapY;
  36965. /**
  36966. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  36967. */
  36968. invertNormalMapY: boolean;
  36969. private _twoSidedLighting;
  36970. /**
  36971. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  36972. */
  36973. twoSidedLighting: boolean;
  36974. /**
  36975. * Default configuration related to image processing available in the standard Material.
  36976. */
  36977. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36978. /**
  36979. * Gets the image processing configuration used either in this material.
  36980. */
  36981. /**
  36982. * Sets the Default image processing configuration used either in the this material.
  36983. *
  36984. * If sets to null, the scene one is in use.
  36985. */
  36986. imageProcessingConfiguration: ImageProcessingConfiguration;
  36987. /**
  36988. * Keep track of the image processing observer to allow dispose and replace.
  36989. */
  36990. private _imageProcessingObserver;
  36991. /**
  36992. * Attaches a new image processing configuration to the Standard Material.
  36993. * @param configuration
  36994. */
  36995. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  36996. /**
  36997. * Gets wether the color curves effect is enabled.
  36998. */
  36999. /**
  37000. * Sets wether the color curves effect is enabled.
  37001. */
  37002. cameraColorCurvesEnabled: boolean;
  37003. /**
  37004. * Gets wether the color grading effect is enabled.
  37005. */
  37006. /**
  37007. * Gets wether the color grading effect is enabled.
  37008. */
  37009. cameraColorGradingEnabled: boolean;
  37010. /**
  37011. * Gets wether tonemapping is enabled or not.
  37012. */
  37013. /**
  37014. * Sets wether tonemapping is enabled or not
  37015. */
  37016. cameraToneMappingEnabled: boolean;
  37017. /**
  37018. * The camera exposure used on this material.
  37019. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37020. * This corresponds to a photographic exposure.
  37021. */
  37022. /**
  37023. * The camera exposure used on this material.
  37024. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37025. * This corresponds to a photographic exposure.
  37026. */
  37027. cameraExposure: number;
  37028. /**
  37029. * Gets The camera contrast used on this material.
  37030. */
  37031. /**
  37032. * Sets The camera contrast used on this material.
  37033. */
  37034. cameraContrast: number;
  37035. /**
  37036. * Gets the Color Grading 2D Lookup Texture.
  37037. */
  37038. /**
  37039. * Sets the Color Grading 2D Lookup Texture.
  37040. */
  37041. cameraColorGradingTexture: Nullable<BaseTexture>;
  37042. /**
  37043. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37044. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37045. * 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;
  37046. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37047. */
  37048. /**
  37049. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37050. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37051. * 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;
  37052. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37053. */
  37054. cameraColorCurves: Nullable<ColorCurves>;
  37055. /**
  37056. * Custom callback helping to override the default shader used in the material.
  37057. */
  37058. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  37059. protected _renderTargets: SmartArray<RenderTargetTexture>;
  37060. protected _worldViewProjectionMatrix: Matrix;
  37061. protected _globalAmbientColor: Color3;
  37062. protected _useLogarithmicDepth: boolean;
  37063. /**
  37064. * Instantiates a new standard material.
  37065. * This is the default material used in Babylon. It is the best trade off between quality
  37066. * and performances.
  37067. * @see http://doc.babylonjs.com/babylon101/materials
  37068. * @param name Define the name of the material in the scene
  37069. * @param scene Define the scene the material belong to
  37070. */
  37071. constructor(name: string, scene: Scene);
  37072. /**
  37073. * Gets a boolean indicating that current material needs to register RTT
  37074. */
  37075. readonly hasRenderTargetTextures: boolean;
  37076. /**
  37077. * Gets the current class name of the material e.g. "StandardMaterial"
  37078. * Mainly use in serialization.
  37079. * @returns the class name
  37080. */
  37081. getClassName(): string;
  37082. /**
  37083. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  37084. * You can try switching to logarithmic depth.
  37085. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  37086. */
  37087. useLogarithmicDepth: boolean;
  37088. /**
  37089. * Specifies if the material will require alpha blending
  37090. * @returns a boolean specifying if alpha blending is needed
  37091. */
  37092. needAlphaBlending(): boolean;
  37093. /**
  37094. * Specifies if this material should be rendered in alpha test mode
  37095. * @returns a boolean specifying if an alpha test is needed.
  37096. */
  37097. needAlphaTesting(): boolean;
  37098. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  37099. /**
  37100. * Get the texture used for alpha test purpose.
  37101. * @returns the diffuse texture in case of the standard material.
  37102. */
  37103. getAlphaTestTexture(): Nullable<BaseTexture>;
  37104. /**
  37105. * Get if the submesh is ready to be used and all its information available.
  37106. * Child classes can use it to update shaders
  37107. * @param mesh defines the mesh to check
  37108. * @param subMesh defines which submesh to check
  37109. * @param useInstances specifies that instances should be used
  37110. * @returns a boolean indicating that the submesh is ready or not
  37111. */
  37112. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  37113. /**
  37114. * Builds the material UBO layouts.
  37115. * Used internally during the effect preparation.
  37116. */
  37117. buildUniformLayout(): void;
  37118. /**
  37119. * Unbinds the material from the mesh
  37120. */
  37121. unbind(): void;
  37122. /**
  37123. * Binds the submesh to this material by preparing the effect and shader to draw
  37124. * @param world defines the world transformation matrix
  37125. * @param mesh defines the mesh containing the submesh
  37126. * @param subMesh defines the submesh to bind the material to
  37127. */
  37128. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  37129. /**
  37130. * Get the list of animatables in the material.
  37131. * @returns the list of animatables object used in the material
  37132. */
  37133. getAnimatables(): IAnimatable[];
  37134. /**
  37135. * Gets the active textures from the material
  37136. * @returns an array of textures
  37137. */
  37138. getActiveTextures(): BaseTexture[];
  37139. /**
  37140. * Specifies if the material uses a texture
  37141. * @param texture defines the texture to check against the material
  37142. * @returns a boolean specifying if the material uses the texture
  37143. */
  37144. hasTexture(texture: BaseTexture): boolean;
  37145. /**
  37146. * Disposes the material
  37147. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  37148. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  37149. */
  37150. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  37151. /**
  37152. * Makes a duplicate of the material, and gives it a new name
  37153. * @param name defines the new name for the duplicated material
  37154. * @returns the cloned material
  37155. */
  37156. clone(name: string): StandardMaterial;
  37157. /**
  37158. * Serializes this material in a JSON representation
  37159. * @returns the serialized material object
  37160. */
  37161. serialize(): any;
  37162. /**
  37163. * Creates a standard material from parsed material data
  37164. * @param source defines the JSON representation of the material
  37165. * @param scene defines the hosting scene
  37166. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  37167. * @returns a new standard material
  37168. */
  37169. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  37170. /**
  37171. * Are diffuse textures enabled in the application.
  37172. */
  37173. static DiffuseTextureEnabled: boolean;
  37174. /**
  37175. * Are ambient textures enabled in the application.
  37176. */
  37177. static AmbientTextureEnabled: boolean;
  37178. /**
  37179. * Are opacity textures enabled in the application.
  37180. */
  37181. static OpacityTextureEnabled: boolean;
  37182. /**
  37183. * Are reflection textures enabled in the application.
  37184. */
  37185. static ReflectionTextureEnabled: boolean;
  37186. /**
  37187. * Are emissive textures enabled in the application.
  37188. */
  37189. static EmissiveTextureEnabled: boolean;
  37190. /**
  37191. * Are specular textures enabled in the application.
  37192. */
  37193. static SpecularTextureEnabled: boolean;
  37194. /**
  37195. * Are bump textures enabled in the application.
  37196. */
  37197. static BumpTextureEnabled: boolean;
  37198. /**
  37199. * Are lightmap textures enabled in the application.
  37200. */
  37201. static LightmapTextureEnabled: boolean;
  37202. /**
  37203. * Are refraction textures enabled in the application.
  37204. */
  37205. static RefractionTextureEnabled: boolean;
  37206. /**
  37207. * Are color grading textures enabled in the application.
  37208. */
  37209. static ColorGradingTextureEnabled: boolean;
  37210. /**
  37211. * Are fresnels enabled in the application.
  37212. */
  37213. static FresnelEnabled: boolean;
  37214. }
  37215. }
  37216. declare module BABYLON {
  37217. /**
  37218. * A class extending Texture allowing drawing on a texture
  37219. * @see http://doc.babylonjs.com/how_to/dynamictexture
  37220. */
  37221. export class DynamicTexture extends Texture {
  37222. private _generateMipMaps;
  37223. private _canvas;
  37224. private _context;
  37225. private _engine;
  37226. /**
  37227. * Creates a DynamicTexture
  37228. * @param name defines the name of the texture
  37229. * @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
  37230. * @param scene defines the scene where you want the texture
  37231. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  37232. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  37233. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  37234. */
  37235. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  37236. /**
  37237. * Get the current class name of the texture useful for serialization or dynamic coding.
  37238. * @returns "DynamicTexture"
  37239. */
  37240. getClassName(): string;
  37241. /**
  37242. * Gets the current state of canRescale
  37243. */
  37244. readonly canRescale: boolean;
  37245. private _recreate;
  37246. /**
  37247. * Scales the texture
  37248. * @param ratio the scale factor to apply to both width and height
  37249. */
  37250. scale(ratio: number): void;
  37251. /**
  37252. * Resizes the texture
  37253. * @param width the new width
  37254. * @param height the new height
  37255. */
  37256. scaleTo(width: number, height: number): void;
  37257. /**
  37258. * Gets the context of the canvas used by the texture
  37259. * @returns the canvas context of the dynamic texture
  37260. */
  37261. getContext(): CanvasRenderingContext2D;
  37262. /**
  37263. * Clears the texture
  37264. */
  37265. clear(): void;
  37266. /**
  37267. * Updates the texture
  37268. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37269. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  37270. */
  37271. update(invertY?: boolean, premulAlpha?: boolean): void;
  37272. /**
  37273. * Draws text onto the texture
  37274. * @param text defines the text to be drawn
  37275. * @param x defines the placement of the text from the left
  37276. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  37277. * @param font defines the font to be used with font-style, font-size, font-name
  37278. * @param color defines the color used for the text
  37279. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  37280. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37281. * @param update defines whether texture is immediately update (default is true)
  37282. */
  37283. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  37284. /**
  37285. * Clones the texture
  37286. * @returns the clone of the texture.
  37287. */
  37288. clone(): DynamicTexture;
  37289. /**
  37290. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  37291. * @returns a serialized dynamic texture object
  37292. */
  37293. serialize(): any;
  37294. /** @hidden */ rebuild(): void;
  37295. }
  37296. }
  37297. declare module BABYLON {
  37298. /** @hidden */
  37299. export var imageProcessingPixelShader: {
  37300. name: string;
  37301. shader: string;
  37302. };
  37303. }
  37304. declare module BABYLON {
  37305. /**
  37306. * ImageProcessingPostProcess
  37307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  37308. */
  37309. export class ImageProcessingPostProcess extends PostProcess {
  37310. /**
  37311. * Default configuration related to image processing available in the PBR Material.
  37312. */
  37313. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37314. /**
  37315. * Gets the image processing configuration used either in this material.
  37316. */
  37317. /**
  37318. * Sets the Default image processing configuration used either in the this material.
  37319. *
  37320. * If sets to null, the scene one is in use.
  37321. */
  37322. imageProcessingConfiguration: ImageProcessingConfiguration;
  37323. /**
  37324. * Keep track of the image processing observer to allow dispose and replace.
  37325. */
  37326. private _imageProcessingObserver;
  37327. /**
  37328. * Attaches a new image processing configuration to the PBR Material.
  37329. * @param configuration
  37330. */
  37331. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  37332. /**
  37333. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  37334. */
  37335. /**
  37336. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  37337. */
  37338. colorCurves: Nullable<ColorCurves>;
  37339. /**
  37340. * Gets wether the color curves effect is enabled.
  37341. */
  37342. /**
  37343. * Sets wether the color curves effect is enabled.
  37344. */
  37345. colorCurvesEnabled: boolean;
  37346. /**
  37347. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  37348. */
  37349. /**
  37350. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  37351. */
  37352. colorGradingTexture: Nullable<BaseTexture>;
  37353. /**
  37354. * Gets wether the color grading effect is enabled.
  37355. */
  37356. /**
  37357. * Gets wether the color grading effect is enabled.
  37358. */
  37359. colorGradingEnabled: boolean;
  37360. /**
  37361. * Gets exposure used in the effect.
  37362. */
  37363. /**
  37364. * Sets exposure used in the effect.
  37365. */
  37366. exposure: number;
  37367. /**
  37368. * Gets wether tonemapping is enabled or not.
  37369. */
  37370. /**
  37371. * Sets wether tonemapping is enabled or not
  37372. */
  37373. toneMappingEnabled: boolean;
  37374. /**
  37375. * Gets contrast used in the effect.
  37376. */
  37377. /**
  37378. * Sets contrast used in the effect.
  37379. */
  37380. contrast: number;
  37381. /**
  37382. * Gets Vignette stretch size.
  37383. */
  37384. /**
  37385. * Sets Vignette stretch size.
  37386. */
  37387. vignetteStretch: number;
  37388. /**
  37389. * Gets Vignette centre X Offset.
  37390. */
  37391. /**
  37392. * Sets Vignette centre X Offset.
  37393. */
  37394. vignetteCentreX: number;
  37395. /**
  37396. * Gets Vignette centre Y Offset.
  37397. */
  37398. /**
  37399. * Sets Vignette centre Y Offset.
  37400. */
  37401. vignetteCentreY: number;
  37402. /**
  37403. * Gets Vignette weight or intensity of the vignette effect.
  37404. */
  37405. /**
  37406. * Sets Vignette weight or intensity of the vignette effect.
  37407. */
  37408. vignetteWeight: number;
  37409. /**
  37410. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  37411. * if vignetteEnabled is set to true.
  37412. */
  37413. /**
  37414. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  37415. * if vignetteEnabled is set to true.
  37416. */
  37417. vignetteColor: Color4;
  37418. /**
  37419. * Gets Camera field of view used by the Vignette effect.
  37420. */
  37421. /**
  37422. * Sets Camera field of view used by the Vignette effect.
  37423. */
  37424. vignetteCameraFov: number;
  37425. /**
  37426. * Gets the vignette blend mode allowing different kind of effect.
  37427. */
  37428. /**
  37429. * Sets the vignette blend mode allowing different kind of effect.
  37430. */
  37431. vignetteBlendMode: number;
  37432. /**
  37433. * Gets wether the vignette effect is enabled.
  37434. */
  37435. /**
  37436. * Sets wether the vignette effect is enabled.
  37437. */
  37438. vignetteEnabled: boolean;
  37439. private _fromLinearSpace;
  37440. /**
  37441. * Gets wether the input of the processing is in Gamma or Linear Space.
  37442. */
  37443. /**
  37444. * Sets wether the input of the processing is in Gamma or Linear Space.
  37445. */
  37446. fromLinearSpace: boolean;
  37447. /**
  37448. * Defines cache preventing GC.
  37449. */
  37450. private _defines;
  37451. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  37452. /**
  37453. * "ImageProcessingPostProcess"
  37454. * @returns "ImageProcessingPostProcess"
  37455. */
  37456. getClassName(): string;
  37457. protected _updateParameters(): void;
  37458. dispose(camera?: Camera): void;
  37459. }
  37460. }
  37461. declare module BABYLON {
  37462. /**
  37463. * Class containing static functions to help procedurally build meshes
  37464. */
  37465. export class GroundBuilder {
  37466. /**
  37467. * Creates a ground mesh
  37468. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  37469. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  37470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37471. * @param name defines the name of the mesh
  37472. * @param options defines the options used to create the mesh
  37473. * @param scene defines the hosting scene
  37474. * @returns the ground mesh
  37475. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  37476. */
  37477. static CreateGround(name: string, options: {
  37478. width?: number;
  37479. height?: number;
  37480. subdivisions?: number;
  37481. subdivisionsX?: number;
  37482. subdivisionsY?: number;
  37483. updatable?: boolean;
  37484. }, scene: any): Mesh;
  37485. /**
  37486. * Creates a tiled ground mesh
  37487. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  37488. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  37489. * * 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
  37490. * * 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
  37491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  37492. * @param name defines the name of the mesh
  37493. * @param options defines the options used to create the mesh
  37494. * @param scene defines the hosting scene
  37495. * @returns the tiled ground mesh
  37496. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  37497. */
  37498. static CreateTiledGround(name: string, options: {
  37499. xmin: number;
  37500. zmin: number;
  37501. xmax: number;
  37502. zmax: number;
  37503. subdivisions?: {
  37504. w: number;
  37505. h: number;
  37506. };
  37507. precision?: {
  37508. w: number;
  37509. h: number;
  37510. };
  37511. updatable?: boolean;
  37512. }, scene: Scene): Mesh;
  37513. /**
  37514. * Creates a ground mesh from a height map
  37515. * * The parameter `url` sets the URL of the height map image resource.
  37516. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  37517. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  37518. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  37519. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  37520. * * 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.
  37521. * * 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).
  37522. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  37523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  37524. * @param name defines the name of the mesh
  37525. * @param url defines the url to the height map
  37526. * @param options defines the options used to create the mesh
  37527. * @param scene defines the hosting scene
  37528. * @returns the ground mesh
  37529. * @see https://doc.babylonjs.com/babylon101/height_map
  37530. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  37531. */
  37532. static CreateGroundFromHeightMap(name: string, url: string, options: {
  37533. width?: number;
  37534. height?: number;
  37535. subdivisions?: number;
  37536. minHeight?: number;
  37537. maxHeight?: number;
  37538. colorFilter?: Color3;
  37539. alphaFilter?: number;
  37540. updatable?: boolean;
  37541. onReady?: (mesh: GroundMesh) => void;
  37542. }, scene: Scene): GroundMesh;
  37543. }
  37544. }
  37545. declare module BABYLON {
  37546. /**
  37547. * Class containing static functions to help procedurally build meshes
  37548. */
  37549. export class TorusBuilder {
  37550. /**
  37551. * Creates a torus mesh
  37552. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  37553. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  37554. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  37555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37556. * * 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
  37557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  37558. * @param name defines the name of the mesh
  37559. * @param options defines the options used to create the mesh
  37560. * @param scene defines the hosting scene
  37561. * @returns the torus mesh
  37562. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  37563. */
  37564. static CreateTorus(name: string, options: {
  37565. diameter?: number;
  37566. thickness?: number;
  37567. tessellation?: number;
  37568. updatable?: boolean;
  37569. sideOrientation?: number;
  37570. frontUVs?: Vector4;
  37571. backUVs?: Vector4;
  37572. }, scene: any): Mesh;
  37573. }
  37574. }
  37575. declare module BABYLON {
  37576. /**
  37577. * Class containing static functions to help procedurally build meshes
  37578. */
  37579. export class CylinderBuilder {
  37580. /**
  37581. * Creates a cylinder or a cone mesh
  37582. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  37583. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  37584. * * 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.
  37585. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  37586. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  37587. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  37588. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  37589. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  37590. * * 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).
  37591. * * 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
  37592. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  37593. * * 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
  37594. * * 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.
  37595. * * If `enclose` is false, a ring surface is one element.
  37596. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  37597. * * 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
  37598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37599. * * 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
  37600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  37601. * @param name defines the name of the mesh
  37602. * @param options defines the options used to create the mesh
  37603. * @param scene defines the hosting scene
  37604. * @returns the cylinder mesh
  37605. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  37606. */
  37607. static CreateCylinder(name: string, options: {
  37608. height?: number;
  37609. diameterTop?: number;
  37610. diameterBottom?: number;
  37611. diameter?: number;
  37612. tessellation?: number;
  37613. subdivisions?: number;
  37614. arc?: number;
  37615. faceColors?: Color4[];
  37616. faceUV?: Vector4[];
  37617. updatable?: boolean;
  37618. hasRings?: boolean;
  37619. enclose?: boolean;
  37620. sideOrientation?: number;
  37621. frontUVs?: Vector4;
  37622. backUVs?: Vector4;
  37623. }, scene: any): Mesh;
  37624. }
  37625. }
  37626. declare module BABYLON {
  37627. /**
  37628. * Manager for handling gamepads
  37629. */
  37630. export class GamepadManager {
  37631. private _scene?;
  37632. private _babylonGamepads;
  37633. private _oneGamepadConnected;
  37634. /** @hidden */ isMonitoring: boolean;
  37635. private _gamepadEventSupported;
  37636. private _gamepadSupport;
  37637. /**
  37638. * observable to be triggered when the gamepad controller has been connected
  37639. */
  37640. onGamepadConnectedObservable: Observable<Gamepad>;
  37641. /**
  37642. * observable to be triggered when the gamepad controller has been disconnected
  37643. */
  37644. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37645. private _onGamepadConnectedEvent;
  37646. private _onGamepadDisconnectedEvent;
  37647. /**
  37648. * Initializes the gamepad manager
  37649. * @param _scene BabylonJS scene
  37650. */
  37651. constructor(_scene?: Scene | undefined);
  37652. /**
  37653. * The gamepads in the game pad manager
  37654. */
  37655. readonly gamepads: Gamepad[];
  37656. /**
  37657. * Get the gamepad controllers based on type
  37658. * @param type The type of gamepad controller
  37659. * @returns Nullable gamepad
  37660. */
  37661. getGamepadByType(type?: number): Nullable<Gamepad>;
  37662. /**
  37663. * Disposes the gamepad manager
  37664. */
  37665. dispose(): void;
  37666. private _addNewGamepad;
  37667. private _startMonitoringGamepads;
  37668. private _stopMonitoringGamepads;
  37669. /** @hidden */ checkGamepadsStatus(): void;
  37670. private _updateGamepadObjects;
  37671. }
  37672. }
  37673. declare module BABYLON {
  37674. interface Scene {
  37675. /** @hidden */ gamepadManager: Nullable<GamepadManager>;
  37676. /**
  37677. * Gets the gamepad manager associated with the scene
  37678. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37679. */
  37680. gamepadManager: GamepadManager;
  37681. }
  37682. /**
  37683. * Interface representing a free camera inputs manager
  37684. */
  37685. interface FreeCameraInputsManager {
  37686. /**
  37687. * Adds gamepad input support to the FreeCameraInputsManager.
  37688. * @returns the FreeCameraInputsManager
  37689. */
  37690. addGamepad(): FreeCameraInputsManager;
  37691. }
  37692. /**
  37693. * Interface representing an arc rotate camera inputs manager
  37694. */
  37695. interface ArcRotateCameraInputsManager {
  37696. /**
  37697. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37698. * @returns the camera inputs manager
  37699. */
  37700. addGamepad(): ArcRotateCameraInputsManager;
  37701. }
  37702. /**
  37703. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37704. */
  37705. export class GamepadSystemSceneComponent implements ISceneComponent {
  37706. /**
  37707. * The component name helpfull to identify the component in the list of scene components.
  37708. */
  37709. readonly name: string;
  37710. /**
  37711. * The scene the component belongs to.
  37712. */
  37713. scene: Scene;
  37714. /**
  37715. * Creates a new instance of the component for the given scene
  37716. * @param scene Defines the scene to register the component in
  37717. */
  37718. constructor(scene: Scene);
  37719. /**
  37720. * Registers the component in a given scene
  37721. */
  37722. register(): void;
  37723. /**
  37724. * Rebuilds the elements related to this component in case of
  37725. * context lost for instance.
  37726. */
  37727. rebuild(): void;
  37728. /**
  37729. * Disposes the component and the associated ressources
  37730. */
  37731. dispose(): void;
  37732. private _beforeCameraUpdate;
  37733. }
  37734. }
  37735. declare module BABYLON {
  37736. /**
  37737. * Options to modify the vr teleportation behavior.
  37738. */
  37739. export interface VRTeleportationOptions {
  37740. /**
  37741. * The name of the mesh which should be used as the teleportation floor. (default: null)
  37742. */
  37743. floorMeshName?: string;
  37744. /**
  37745. * A list of meshes to be used as the teleportation floor. (default: empty)
  37746. */
  37747. floorMeshes?: Mesh[];
  37748. }
  37749. /**
  37750. * Options to modify the vr experience helper's behavior.
  37751. */
  37752. export interface VRExperienceHelperOptions extends WebVROptions {
  37753. /**
  37754. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  37755. */
  37756. createDeviceOrientationCamera?: boolean;
  37757. /**
  37758. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  37759. */
  37760. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  37761. /**
  37762. * Uses the main button on the controller to toggle the laser casted. (default: true)
  37763. */
  37764. laserToggle?: boolean;
  37765. /**
  37766. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  37767. */
  37768. floorMeshes?: Mesh[];
  37769. /**
  37770. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  37771. */
  37772. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  37773. }
  37774. /**
  37775. * Helps to quickly add VR support to an existing scene.
  37776. * See http://doc.babylonjs.com/how_to/webvr_helper
  37777. */
  37778. export class VRExperienceHelper {
  37779. /** Options to modify the vr experience helper's behavior. */
  37780. webVROptions: VRExperienceHelperOptions;
  37781. private _scene;
  37782. private _position;
  37783. private _btnVR;
  37784. private _btnVRDisplayed;
  37785. private _webVRsupported;
  37786. private _webVRready;
  37787. private _webVRrequesting;
  37788. private _webVRpresenting;
  37789. private _hasEnteredVR;
  37790. private _fullscreenVRpresenting;
  37791. private _canvas;
  37792. private _webVRCamera;
  37793. private _vrDeviceOrientationCamera;
  37794. private _deviceOrientationCamera;
  37795. private _existingCamera;
  37796. private _onKeyDown;
  37797. private _onVrDisplayPresentChange;
  37798. private _onVRDisplayChanged;
  37799. private _onVRRequestPresentStart;
  37800. private _onVRRequestPresentComplete;
  37801. /**
  37802. * Observable raised when entering VR.
  37803. */
  37804. onEnteringVRObservable: Observable<VRExperienceHelper>;
  37805. /**
  37806. * Observable raised when exiting VR.
  37807. */
  37808. onExitingVRObservable: Observable<VRExperienceHelper>;
  37809. /**
  37810. * Observable raised when controller mesh is loaded.
  37811. */
  37812. onControllerMeshLoadedObservable: Observable<WebVRController>;
  37813. /** Return this.onEnteringVRObservable
  37814. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  37815. */
  37816. readonly onEnteringVR: Observable<VRExperienceHelper>;
  37817. /** Return this.onExitingVRObservable
  37818. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  37819. */
  37820. readonly onExitingVR: Observable<VRExperienceHelper>;
  37821. /** Return this.onControllerMeshLoadedObservable
  37822. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  37823. */
  37824. readonly onControllerMeshLoaded: Observable<WebVRController>;
  37825. private _rayLength;
  37826. private _useCustomVRButton;
  37827. private _teleportationRequested;
  37828. private _teleportActive;
  37829. private _floorMeshName;
  37830. private _floorMeshesCollection;
  37831. private _rotationAllowed;
  37832. private _teleportBackwardsVector;
  37833. private _teleportationTarget;
  37834. private _isDefaultTeleportationTarget;
  37835. private _postProcessMove;
  37836. private _teleportationFillColor;
  37837. private _teleportationBorderColor;
  37838. private _rotationAngle;
  37839. private _haloCenter;
  37840. private _cameraGazer;
  37841. private _padSensibilityUp;
  37842. private _padSensibilityDown;
  37843. private _leftController;
  37844. private _rightController;
  37845. /**
  37846. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  37847. */
  37848. onNewMeshSelected: Observable<AbstractMesh>;
  37849. /**
  37850. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  37851. */
  37852. onNewMeshPicked: Observable<PickingInfo>;
  37853. private _circleEase;
  37854. /**
  37855. * Observable raised before camera teleportation
  37856. */
  37857. onBeforeCameraTeleport: Observable<Vector3>;
  37858. /**
  37859. * Observable raised after camera teleportation
  37860. */
  37861. onAfterCameraTeleport: Observable<Vector3>;
  37862. /**
  37863. * Observable raised when current selected mesh gets unselected
  37864. */
  37865. onSelectedMeshUnselected: Observable<AbstractMesh>;
  37866. private _raySelectionPredicate;
  37867. /**
  37868. * To be optionaly changed by user to define custom ray selection
  37869. */
  37870. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  37871. /**
  37872. * To be optionaly changed by user to define custom selection logic (after ray selection)
  37873. */
  37874. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  37875. /**
  37876. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  37877. */
  37878. teleportationEnabled: boolean;
  37879. private _defaultHeight;
  37880. private _teleportationInitialized;
  37881. private _interactionsEnabled;
  37882. private _interactionsRequested;
  37883. private _displayGaze;
  37884. private _displayLaserPointer;
  37885. /**
  37886. * The mesh used to display where the user is going to teleport.
  37887. */
  37888. /**
  37889. * Sets the mesh to be used to display where the user is going to teleport.
  37890. */
  37891. teleportationTarget: Mesh;
  37892. /**
  37893. * 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
  37894. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  37895. * See http://doc.babylonjs.com/resources/baking_transformations
  37896. */
  37897. gazeTrackerMesh: Mesh;
  37898. /**
  37899. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  37900. */
  37901. updateGazeTrackerScale: boolean;
  37902. /**
  37903. * If the gaze trackers color should be updated when selecting meshes
  37904. */
  37905. updateGazeTrackerColor: boolean;
  37906. /**
  37907. * The gaze tracking mesh corresponding to the left controller
  37908. */
  37909. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  37910. /**
  37911. * The gaze tracking mesh corresponding to the right controller
  37912. */
  37913. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  37914. /**
  37915. * If the ray of the gaze should be displayed.
  37916. */
  37917. /**
  37918. * Sets if the ray of the gaze should be displayed.
  37919. */
  37920. displayGaze: boolean;
  37921. /**
  37922. * If the ray of the LaserPointer should be displayed.
  37923. */
  37924. /**
  37925. * Sets if the ray of the LaserPointer should be displayed.
  37926. */
  37927. displayLaserPointer: boolean;
  37928. /**
  37929. * The deviceOrientationCamera used as the camera when not in VR.
  37930. */
  37931. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  37932. /**
  37933. * Based on the current WebVR support, returns the current VR camera used.
  37934. */
  37935. readonly currentVRCamera: Nullable<Camera>;
  37936. /**
  37937. * The webVRCamera which is used when in VR.
  37938. */
  37939. readonly webVRCamera: WebVRFreeCamera;
  37940. /**
  37941. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  37942. */
  37943. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  37944. private readonly _teleportationRequestInitiated;
  37945. /**
  37946. * Defines wether or not Pointer lock should be requested when switching to
  37947. * full screen.
  37948. */
  37949. requestPointerLockOnFullScreen: boolean;
  37950. /**
  37951. * Instantiates a VRExperienceHelper.
  37952. * Helps to quickly add VR support to an existing scene.
  37953. * @param scene The scene the VRExperienceHelper belongs to.
  37954. * @param webVROptions Options to modify the vr experience helper's behavior.
  37955. */
  37956. constructor(scene: Scene,
  37957. /** Options to modify the vr experience helper's behavior. */
  37958. webVROptions?: VRExperienceHelperOptions);
  37959. private _onDefaultMeshLoaded;
  37960. private _onResize;
  37961. private _onFullscreenChange;
  37962. /**
  37963. * Gets a value indicating if we are currently in VR mode.
  37964. */
  37965. readonly isInVRMode: boolean;
  37966. private onVrDisplayPresentChange;
  37967. private onVRDisplayChanged;
  37968. private moveButtonToBottomRight;
  37969. private displayVRButton;
  37970. private updateButtonVisibility;
  37971. private _cachedAngularSensibility;
  37972. /**
  37973. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  37974. * Otherwise, will use the fullscreen API.
  37975. */
  37976. enterVR(): void;
  37977. /**
  37978. * Attempt to exit VR, or fullscreen.
  37979. */
  37980. exitVR(): void;
  37981. /**
  37982. * The position of the vr experience helper.
  37983. */
  37984. /**
  37985. * Sets the position of the vr experience helper.
  37986. */
  37987. position: Vector3;
  37988. /**
  37989. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  37990. */
  37991. enableInteractions(): void;
  37992. private readonly _noControllerIsActive;
  37993. private beforeRender;
  37994. private _isTeleportationFloor;
  37995. /**
  37996. * Adds a floor mesh to be used for teleportation.
  37997. * @param floorMesh the mesh to be used for teleportation.
  37998. */
  37999. addFloorMesh(floorMesh: Mesh): void;
  38000. /**
  38001. * Removes a floor mesh from being used for teleportation.
  38002. * @param floorMesh the mesh to be removed.
  38003. */
  38004. removeFloorMesh(floorMesh: Mesh): void;
  38005. /**
  38006. * Enables interactions and teleportation using the VR controllers and gaze.
  38007. * @param vrTeleportationOptions options to modify teleportation behavior.
  38008. */
  38009. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  38010. private _onNewGamepadConnected;
  38011. private _tryEnableInteractionOnController;
  38012. private _onNewGamepadDisconnected;
  38013. private _enableInteractionOnController;
  38014. private _checkTeleportWithRay;
  38015. private _checkRotate;
  38016. private _checkTeleportBackwards;
  38017. private _enableTeleportationOnController;
  38018. private _createTeleportationCircles;
  38019. private _displayTeleportationTarget;
  38020. private _hideTeleportationTarget;
  38021. private _rotateCamera;
  38022. private _moveTeleportationSelectorTo;
  38023. private _workingVector;
  38024. private _workingQuaternion;
  38025. private _workingMatrix;
  38026. /**
  38027. * Teleports the users feet to the desired location
  38028. * @param location The location where the user's feet should be placed
  38029. */
  38030. teleportCamera(location: Vector3): void;
  38031. private _convertNormalToDirectionOfRay;
  38032. private _castRayAndSelectObject;
  38033. private _notifySelectedMeshUnselected;
  38034. /**
  38035. * Sets the color of the laser ray from the vr controllers.
  38036. * @param color new color for the ray.
  38037. */
  38038. changeLaserColor(color: Color3): void;
  38039. /**
  38040. * Sets the color of the ray from the vr headsets gaze.
  38041. * @param color new color for the ray.
  38042. */
  38043. changeGazeColor(color: Color3): void;
  38044. /**
  38045. * Exits VR and disposes of the vr experience helper
  38046. */
  38047. dispose(): void;
  38048. /**
  38049. * Gets the name of the VRExperienceHelper class
  38050. * @returns "VRExperienceHelper"
  38051. */
  38052. getClassName(): string;
  38053. }
  38054. }
  38055. declare module BABYLON {
  38056. /**
  38057. * Manages an XRSession
  38058. * @see https://doc.babylonjs.com/how_to/webxr
  38059. */
  38060. export class WebXRSessionManager implements IDisposable {
  38061. private scene;
  38062. /**
  38063. * Fires every time a new xrFrame arrives which can be used to update the camera
  38064. */
  38065. onXRFrameObservable: Observable<any>;
  38066. /**
  38067. * Fires when the xr session is ended either by the device or manually done
  38068. */
  38069. onXRSessionEnded: Observable<any>;
  38070. /** @hidden */ xrSession: XRSession;
  38071. /** @hidden */ frameOfReference: XRFrameOfReference;
  38072. /** @hidden */ sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  38073. /** @hidden */ currentXRFrame: Nullable<XRFrame>;
  38074. private _xrNavigator;
  38075. private _xrDevice;
  38076. private _tmpMatrix;
  38077. /**
  38078. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  38079. * @param scene The scene which the session should be created for
  38080. */
  38081. constructor(scene: Scene);
  38082. /**
  38083. * Initializes the manager
  38084. * After initialization enterXR can be called to start an XR session
  38085. * @returns Promise which resolves after it is initialized
  38086. */
  38087. initializeAsync(): Promise<void>;
  38088. /**
  38089. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  38090. * @param sessionCreationOptions xr options to create the session with
  38091. * @param frameOfReferenceType option to configure how the xr pose is expressed
  38092. * @returns Promise which resolves after it enters XR
  38093. */
  38094. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  38095. /**
  38096. * Stops the xrSession and restores the renderloop
  38097. * @returns Promise which resolves after it exits XR
  38098. */
  38099. exitXRAsync(): Promise<void>;
  38100. /**
  38101. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38102. * @param ray ray to cast into the environment
  38103. * @returns Promise which resolves with a collision point in the environment if it exists
  38104. */
  38105. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38106. /**
  38107. * Checks if a session would be supported for the creation options specified
  38108. * @param options creation options to check if they are supported
  38109. * @returns true if supported
  38110. */
  38111. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38112. /**
  38113. * @hidden
  38114. * Converts the render layer of xrSession to a render target
  38115. * @param session session to create render target for
  38116. * @param scene scene the new render target should be created for
  38117. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  38118. /**
  38119. * Disposes of the session manager
  38120. */
  38121. dispose(): void;
  38122. }
  38123. }
  38124. declare module BABYLON {
  38125. /**
  38126. * WebXR Camera which holds the views for the xrSession
  38127. * @see https://doc.babylonjs.com/how_to/webxr
  38128. */
  38129. export class WebXRCamera extends FreeCamera {
  38130. private static _TmpMatrix;
  38131. /**
  38132. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  38133. * @param name the name of the camera
  38134. * @param scene the scene to add the camera to
  38135. */
  38136. constructor(name: string, scene: Scene);
  38137. private _updateNumberOfRigCameras;
  38138. /** @hidden */ updateForDualEyeDebugging(pupilDistance?: number): void;
  38139. /**
  38140. * Updates the cameras position from the current pose information of the XR session
  38141. * @param xrSessionManager the session containing pose information
  38142. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  38143. */
  38144. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  38145. }
  38146. }
  38147. declare module BABYLON {
  38148. /**
  38149. * States of the webXR experience
  38150. */
  38151. export enum WebXRState {
  38152. /**
  38153. * Transitioning to being in XR mode
  38154. */
  38155. ENTERING_XR = 0,
  38156. /**
  38157. * Transitioning to non XR mode
  38158. */
  38159. EXITING_XR = 1,
  38160. /**
  38161. * In XR mode and presenting
  38162. */
  38163. IN_XR = 2,
  38164. /**
  38165. * Not entered XR mode
  38166. */
  38167. NOT_IN_XR = 3
  38168. }
  38169. /**
  38170. * Helper class used to enable XR
  38171. * @see https://doc.babylonjs.com/how_to/webxr
  38172. */
  38173. export class WebXRExperienceHelper implements IDisposable {
  38174. private scene;
  38175. /**
  38176. * 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
  38177. */
  38178. container: AbstractMesh;
  38179. /**
  38180. * Camera used to render xr content
  38181. */
  38182. camera: WebXRCamera;
  38183. /**
  38184. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  38185. */
  38186. state: WebXRState;
  38187. private _setState;
  38188. private static _TmpVector;
  38189. /**
  38190. * Fires when the state of the experience helper has changed
  38191. */
  38192. onStateChangedObservable: Observable<WebXRState>;
  38193. /** @hidden */ sessionManager: WebXRSessionManager;
  38194. private _nonVRCamera;
  38195. private _originalSceneAutoClear;
  38196. private _supported;
  38197. /**
  38198. * Creates the experience helper
  38199. * @param scene the scene to attach the experience helper to
  38200. * @returns a promise for the experience helper
  38201. */
  38202. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  38203. /**
  38204. * Creates a WebXRExperienceHelper
  38205. * @param scene The scene the helper should be created in
  38206. */
  38207. private constructor();
  38208. /**
  38209. * Exits XR mode and returns the scene to its original state
  38210. * @returns promise that resolves after xr mode has exited
  38211. */
  38212. exitXRAsync(): Promise<void>;
  38213. /**
  38214. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  38215. * @param sessionCreationOptions options for the XR session
  38216. * @param frameOfReference frame of reference of the XR session
  38217. * @returns promise that resolves after xr mode has entered
  38218. */
  38219. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  38220. /**
  38221. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38222. * @param ray ray to cast into the environment
  38223. * @returns Promise which resolves with a collision point in the environment if it exists
  38224. */
  38225. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38226. /**
  38227. * Updates the global position of the camera by moving the camera's container
  38228. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  38229. * @param position The desired global position of the camera
  38230. */
  38231. setPositionOfCameraUsingContainer(position: Vector3): void;
  38232. /**
  38233. * Rotates the xr camera by rotating the camera's container around the camera's position
  38234. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  38235. * @param rotation the desired quaternion rotation to apply to the camera
  38236. */
  38237. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  38238. /**
  38239. * Checks if the creation options are supported by the xr session
  38240. * @param options creation options
  38241. * @returns true if supported
  38242. */
  38243. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38244. /**
  38245. * Disposes of the experience helper
  38246. */
  38247. dispose(): void;
  38248. }
  38249. }
  38250. declare module BABYLON {
  38251. /**
  38252. * Button which can be used to enter a different mode of XR
  38253. */
  38254. export class WebXREnterExitUIButton {
  38255. /** button element */
  38256. element: HTMLElement;
  38257. /** XR initialization options for the button */
  38258. initializationOptions: XRSessionCreationOptions;
  38259. /**
  38260. * Creates a WebXREnterExitUIButton
  38261. * @param element button element
  38262. * @param initializationOptions XR initialization options for the button
  38263. */
  38264. constructor(
  38265. /** button element */
  38266. element: HTMLElement,
  38267. /** XR initialization options for the button */
  38268. initializationOptions: XRSessionCreationOptions);
  38269. /**
  38270. * Overwritable function which can be used to update the button's visuals when the state changes
  38271. * @param activeButton the current active button in the UI
  38272. */
  38273. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  38274. }
  38275. /**
  38276. * Options to create the webXR UI
  38277. */
  38278. export class WebXREnterExitUIOptions {
  38279. /**
  38280. * Context to enter xr with
  38281. */
  38282. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  38283. /**
  38284. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  38285. */
  38286. customButtons?: Array<WebXREnterExitUIButton>;
  38287. }
  38288. /**
  38289. * UI to allow the user to enter/exit XR mode
  38290. */
  38291. export class WebXREnterExitUI implements IDisposable {
  38292. private scene;
  38293. private _overlay;
  38294. private _buttons;
  38295. private _activeButton;
  38296. /**
  38297. * Fired every time the active button is changed.
  38298. *
  38299. * When xr is entered via a button that launches xr that button will be the callback parameter
  38300. *
  38301. * When exiting xr the callback parameter will be null)
  38302. */
  38303. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  38304. /**
  38305. * Creates UI to allow the user to enter/exit XR mode
  38306. * @param scene the scene to add the ui to
  38307. * @param helper the xr experience helper to enter/exit xr with
  38308. * @param options options to configure the UI
  38309. * @returns the created ui
  38310. */
  38311. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  38312. private constructor();
  38313. private _updateButtons;
  38314. /**
  38315. * Disposes of the object
  38316. */
  38317. dispose(): void;
  38318. }
  38319. }
  38320. declare module BABYLON {
  38321. /**
  38322. * Represents an XR input
  38323. */
  38324. export class WebXRController {
  38325. /**
  38326. * 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
  38327. */
  38328. grip?: AbstractMesh;
  38329. /**
  38330. * Pointer which can be used to select objects or attach a visible laser to
  38331. */
  38332. pointer: AbstractMesh;
  38333. /**
  38334. * Creates the controller
  38335. * @see https://doc.babylonjs.com/how_to/webxr
  38336. * @param scene the scene which the controller should be associated to
  38337. */
  38338. constructor(scene: Scene);
  38339. /**
  38340. * Disposes of the object
  38341. */
  38342. dispose(): void;
  38343. }
  38344. /**
  38345. * XR input used to track XR inputs such as controllers/rays
  38346. */
  38347. export class WebXRInput implements IDisposable {
  38348. private helper;
  38349. /**
  38350. * XR controllers being tracked
  38351. */
  38352. controllers: Array<WebXRController>;
  38353. private _tmpMatrix;
  38354. private _frameObserver;
  38355. /**
  38356. * Initializes the WebXRInput
  38357. * @param helper experience helper which the input should be created for
  38358. */
  38359. constructor(helper: WebXRExperienceHelper);
  38360. /**
  38361. * Disposes of the object
  38362. */
  38363. dispose(): void;
  38364. }
  38365. }
  38366. declare module BABYLON {
  38367. /**
  38368. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  38369. */
  38370. export class WebXRManagedOutputCanvas implements IDisposable {
  38371. private _canvas;
  38372. /**
  38373. * xrpresent context of the canvas which can be used to display/mirror xr content
  38374. */
  38375. canvasContext: Nullable<WebGLRenderingContext>;
  38376. /**
  38377. * Initializes the canvas to be added/removed upon entering/exiting xr
  38378. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  38379. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  38380. */
  38381. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  38382. /**
  38383. * Disposes of the object
  38384. */
  38385. dispose(): void;
  38386. private _setManagedOutputCanvas;
  38387. private _addCanvas;
  38388. private _removeCanvas;
  38389. }
  38390. }
  38391. declare module BABYLON {
  38392. /**
  38393. * Contains an array of blocks representing the octree
  38394. */
  38395. export interface IOctreeContainer<T> {
  38396. /**
  38397. * Blocks within the octree
  38398. */
  38399. blocks: Array<OctreeBlock<T>>;
  38400. }
  38401. /**
  38402. * Class used to store a cell in an octree
  38403. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38404. */
  38405. export class OctreeBlock<T> {
  38406. /**
  38407. * Gets the content of the current block
  38408. */
  38409. entries: T[];
  38410. /**
  38411. * Gets the list of block children
  38412. */
  38413. blocks: Array<OctreeBlock<T>>;
  38414. private _depth;
  38415. private _maxDepth;
  38416. private _capacity;
  38417. private _minPoint;
  38418. private _maxPoint;
  38419. private _boundingVectors;
  38420. private _creationFunc;
  38421. /**
  38422. * Creates a new block
  38423. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  38424. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  38425. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  38426. * @param depth defines the current depth of this block in the octree
  38427. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  38428. * @param creationFunc defines a callback to call when an element is added to the block
  38429. */
  38430. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  38431. /**
  38432. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  38433. */
  38434. readonly capacity: number;
  38435. /**
  38436. * Gets the minimum vector (in world space) of the block's bounding box
  38437. */
  38438. readonly minPoint: Vector3;
  38439. /**
  38440. * Gets the maximum vector (in world space) of the block's bounding box
  38441. */
  38442. readonly maxPoint: Vector3;
  38443. /**
  38444. * Add a new element to this block
  38445. * @param entry defines the element to add
  38446. */
  38447. addEntry(entry: T): void;
  38448. /**
  38449. * Remove an element from this block
  38450. * @param entry defines the element to remove
  38451. */
  38452. removeEntry(entry: T): void;
  38453. /**
  38454. * Add an array of elements to this block
  38455. * @param entries defines the array of elements to add
  38456. */
  38457. addEntries(entries: T[]): void;
  38458. /**
  38459. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  38460. * @param frustumPlanes defines the frustum planes to test
  38461. * @param selection defines the array to store current content if selection is positive
  38462. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38463. */
  38464. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  38465. /**
  38466. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  38467. * @param sphereCenter defines the bounding sphere center
  38468. * @param sphereRadius defines the bounding sphere radius
  38469. * @param selection defines the array to store current content if selection is positive
  38470. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38471. */
  38472. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  38473. /**
  38474. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  38475. * @param ray defines the ray to test with
  38476. * @param selection defines the array to store current content if selection is positive
  38477. */
  38478. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  38479. /**
  38480. * Subdivide the content into child blocks (this block will then be empty)
  38481. */
  38482. createInnerBlocks(): void;
  38483. /**
  38484. * @hidden
  38485. */ 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;
  38486. }
  38487. }
  38488. declare module BABYLON {
  38489. /**
  38490. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  38491. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38492. */
  38493. export class Octree<T> {
  38494. /** 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.) */
  38495. maxDepth: number;
  38496. /**
  38497. * Blocks within the octree containing objects
  38498. */
  38499. blocks: Array<OctreeBlock<T>>;
  38500. /**
  38501. * Content stored in the octree
  38502. */
  38503. dynamicContent: T[];
  38504. private _maxBlockCapacity;
  38505. private _selectionContent;
  38506. private _creationFunc;
  38507. /**
  38508. * Creates a octree
  38509. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38510. * @param creationFunc function to be used to instatiate the octree
  38511. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  38512. * @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.)
  38513. */
  38514. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  38515. /** 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.) */
  38516. maxDepth?: number);
  38517. /**
  38518. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  38519. * @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);
  38520. * @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);
  38521. * @param entries meshes to be added to the octree blocks
  38522. */
  38523. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  38524. /**
  38525. * Adds a mesh to the octree
  38526. * @param entry Mesh to add to the octree
  38527. */
  38528. addMesh(entry: T): void;
  38529. /**
  38530. * Remove an element from the octree
  38531. * @param entry defines the element to remove
  38532. */
  38533. removeMesh(entry: T): void;
  38534. /**
  38535. * Selects an array of meshes within the frustum
  38536. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  38537. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  38538. * @returns array of meshes within the frustum
  38539. */
  38540. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  38541. /**
  38542. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  38543. * @param sphereCenter defines the bounding sphere center
  38544. * @param sphereRadius defines the bounding sphere radius
  38545. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38546. * @returns an array of objects that intersect the sphere
  38547. */
  38548. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  38549. /**
  38550. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  38551. * @param ray defines the ray to test with
  38552. * @returns array of intersected objects
  38553. */
  38554. intersectsRay(ray: Ray): SmartArray<T>;
  38555. /**
  38556. * Adds a mesh into the octree block if it intersects the block
  38557. */
  38558. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  38559. /**
  38560. * Adds a submesh into the octree block if it intersects the block
  38561. */
  38562. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  38563. }
  38564. }
  38565. declare module BABYLON {
  38566. interface Scene {
  38567. /**
  38568. * @hidden
  38569. * Backing Filed
  38570. */ selectionOctree: Octree<AbstractMesh>;
  38571. /**
  38572. * Gets the octree used to boost mesh selection (picking)
  38573. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38574. */
  38575. selectionOctree: Octree<AbstractMesh>;
  38576. /**
  38577. * Creates or updates the octree used to boost selection (picking)
  38578. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38579. * @param maxCapacity defines the maximum capacity per leaf
  38580. * @param maxDepth defines the maximum depth of the octree
  38581. * @returns an octree of AbstractMesh
  38582. */
  38583. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  38584. }
  38585. interface AbstractMesh {
  38586. /**
  38587. * @hidden
  38588. * Backing Field
  38589. */ submeshesOctree: Octree<SubMesh>;
  38590. /**
  38591. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  38592. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  38593. * @param maxCapacity defines the maximum size of each block (64 by default)
  38594. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  38595. * @returns the new octree
  38596. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  38597. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38598. */
  38599. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  38600. }
  38601. /**
  38602. * Defines the octree scene component responsible to manage any octrees
  38603. * in a given scene.
  38604. */
  38605. export class OctreeSceneComponent {
  38606. /**
  38607. * The component name helpfull to identify the component in the list of scene components.
  38608. */
  38609. readonly name: string;
  38610. /**
  38611. * The scene the component belongs to.
  38612. */
  38613. scene: Scene;
  38614. /**
  38615. * Indicates if the meshes have been checked to make sure they are isEnabled()
  38616. */
  38617. readonly checksIsEnabled: boolean;
  38618. /**
  38619. * Creates a new instance of the component for the given scene
  38620. * @param scene Defines the scene to register the component in
  38621. */
  38622. constructor(scene: Scene);
  38623. /**
  38624. * Registers the component in a given scene
  38625. */
  38626. register(): void;
  38627. /**
  38628. * Return the list of active meshes
  38629. * @returns the list of active meshes
  38630. */
  38631. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  38632. /**
  38633. * Return the list of active sub meshes
  38634. * @param mesh The mesh to get the candidates sub meshes from
  38635. * @returns the list of active sub meshes
  38636. */
  38637. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  38638. private _tempRay;
  38639. /**
  38640. * Return the list of sub meshes intersecting with a given local ray
  38641. * @param mesh defines the mesh to find the submesh for
  38642. * @param localRay defines the ray in local space
  38643. * @returns the list of intersecting sub meshes
  38644. */
  38645. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  38646. /**
  38647. * Return the list of sub meshes colliding with a collider
  38648. * @param mesh defines the mesh to find the submesh for
  38649. * @param collider defines the collider to evaluate the collision against
  38650. * @returns the list of colliding sub meshes
  38651. */
  38652. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  38653. /**
  38654. * Rebuilds the elements related to this component in case of
  38655. * context lost for instance.
  38656. */
  38657. rebuild(): void;
  38658. /**
  38659. * Disposes the component and the associated ressources.
  38660. */
  38661. dispose(): void;
  38662. }
  38663. }
  38664. declare module BABYLON {
  38665. /**
  38666. * Class containing static functions to help procedurally build meshes
  38667. */
  38668. export class LinesBuilder {
  38669. /**
  38670. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  38671. * * 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
  38672. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  38673. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  38674. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  38675. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  38676. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  38677. * * 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
  38678. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  38679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38680. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  38681. * @param name defines the name of the new line system
  38682. * @param options defines the options used to create the line system
  38683. * @param scene defines the hosting scene
  38684. * @returns a new line system mesh
  38685. */
  38686. static CreateLineSystem(name: string, options: {
  38687. lines: Vector3[][];
  38688. updatable?: boolean;
  38689. instance?: Nullable<LinesMesh>;
  38690. colors?: Nullable<Color4[][]>;
  38691. useVertexAlpha?: boolean;
  38692. }, scene: Nullable<Scene>): LinesMesh;
  38693. /**
  38694. * Creates a line mesh
  38695. * 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
  38696. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  38697. * * The parameter `points` is an array successive Vector3
  38698. * * 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
  38699. * * The optional parameter `colors` is an array of successive Color4, one per line point
  38700. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  38701. * * When updating an instance, remember that only point positions can change, not the number of points
  38702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  38704. * @param name defines the name of the new line system
  38705. * @param options defines the options used to create the line system
  38706. * @param scene defines the hosting scene
  38707. * @returns a new line mesh
  38708. */
  38709. static CreateLines(name: string, options: {
  38710. points: Vector3[];
  38711. updatable?: boolean;
  38712. instance?: Nullable<LinesMesh>;
  38713. colors?: Color4[];
  38714. useVertexAlpha?: boolean;
  38715. }, scene?: Nullable<Scene>): LinesMesh;
  38716. /**
  38717. * Creates a dashed line mesh
  38718. * * 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
  38719. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  38720. * * The parameter `points` is an array successive Vector3
  38721. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  38722. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  38723. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  38724. * * 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
  38725. * * When updating an instance, remember that only point positions can change, not the number of points
  38726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38727. * @param name defines the name of the mesh
  38728. * @param options defines the options used to create the mesh
  38729. * @param scene defines the hosting scene
  38730. * @returns the dashed line mesh
  38731. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  38732. */
  38733. static CreateDashedLines(name: string, options: {
  38734. points: Vector3[];
  38735. dashSize?: number;
  38736. gapSize?: number;
  38737. dashNb?: number;
  38738. updatable?: boolean;
  38739. instance?: LinesMesh;
  38740. }, scene?: Nullable<Scene>): LinesMesh;
  38741. }
  38742. }
  38743. declare module BABYLON {
  38744. /**
  38745. * Renders a layer on top of an existing scene
  38746. */
  38747. export class UtilityLayerRenderer implements IDisposable {
  38748. /** the original scene that will be rendered on top of */
  38749. originalScene: Scene;
  38750. private _pointerCaptures;
  38751. private _lastPointerEvents;
  38752. private static _DefaultUtilityLayer;
  38753. private static _DefaultKeepDepthUtilityLayer;
  38754. /**
  38755. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  38756. */
  38757. pickUtilitySceneFirst: boolean;
  38758. /**
  38759. * 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)
  38760. */
  38761. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  38762. /**
  38763. * 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)
  38764. */
  38765. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  38766. /**
  38767. * The scene that is rendered on top of the original scene
  38768. */
  38769. utilityLayerScene: Scene;
  38770. /**
  38771. * If the utility layer should automatically be rendered on top of existing scene
  38772. */
  38773. shouldRender: boolean;
  38774. /**
  38775. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  38776. */
  38777. onlyCheckPointerDownEvents: boolean;
  38778. /**
  38779. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  38780. */
  38781. processAllEvents: boolean;
  38782. /**
  38783. * Observable raised when the pointer move from the utility layer scene to the main scene
  38784. */
  38785. onPointerOutObservable: Observable<number>;
  38786. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  38787. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  38788. private _afterRenderObserver;
  38789. private _sceneDisposeObserver;
  38790. private _originalPointerObserver;
  38791. /**
  38792. * Instantiates a UtilityLayerRenderer
  38793. * @param originalScene the original scene that will be rendered on top of
  38794. * @param handleEvents boolean indicating if the utility layer should handle events
  38795. */
  38796. constructor(
  38797. /** the original scene that will be rendered on top of */
  38798. originalScene: Scene, handleEvents?: boolean);
  38799. private _notifyObservers;
  38800. /**
  38801. * Renders the utility layers scene on top of the original scene
  38802. */
  38803. render(): void;
  38804. /**
  38805. * Disposes of the renderer
  38806. */
  38807. dispose(): void;
  38808. private _updateCamera;
  38809. }
  38810. }
  38811. declare module BABYLON {
  38812. /**
  38813. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  38814. */
  38815. export class Gizmo implements IDisposable {
  38816. /** The utility layer the gizmo will be added to */
  38817. gizmoLayer: UtilityLayerRenderer;
  38818. /**
  38819. * The root mesh of the gizmo
  38820. */ rootMesh: Mesh;
  38821. private _attachedMesh;
  38822. /**
  38823. * Ratio for the scale of the gizmo (Default: 1)
  38824. */
  38825. scaleRatio: number;
  38826. private _tmpMatrix;
  38827. /**
  38828. * If a custom mesh has been set (Default: false)
  38829. */
  38830. protected _customMeshSet: boolean;
  38831. /**
  38832. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  38833. * * When set, interactions will be enabled
  38834. */
  38835. attachedMesh: Nullable<AbstractMesh>;
  38836. /**
  38837. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38838. * @param mesh The mesh to replace the default mesh of the gizmo
  38839. */
  38840. setCustomMesh(mesh: Mesh): void;
  38841. /**
  38842. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  38843. */
  38844. updateGizmoRotationToMatchAttachedMesh: boolean;
  38845. /**
  38846. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  38847. */
  38848. updateGizmoPositionToMatchAttachedMesh: boolean;
  38849. /**
  38850. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  38851. */
  38852. protected _updateScale: boolean;
  38853. protected _interactionsEnabled: boolean;
  38854. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  38855. private _beforeRenderObserver;
  38856. /**
  38857. * Creates a gizmo
  38858. * @param gizmoLayer The utility layer the gizmo will be added to
  38859. */
  38860. constructor(
  38861. /** The utility layer the gizmo will be added to */
  38862. gizmoLayer?: UtilityLayerRenderer);
  38863. private _tempVector;
  38864. /**
  38865. * @hidden
  38866. * Updates the gizmo to match the attached mesh's position/rotation
  38867. */
  38868. protected _update(): void;
  38869. /**
  38870. * Disposes of the gizmo
  38871. */
  38872. dispose(): void;
  38873. }
  38874. }
  38875. declare module BABYLON {
  38876. /**
  38877. * Single axis drag gizmo
  38878. */
  38879. export class AxisDragGizmo extends Gizmo {
  38880. /**
  38881. * Drag behavior responsible for the gizmos dragging interactions
  38882. */
  38883. dragBehavior: PointerDragBehavior;
  38884. private _pointerObserver;
  38885. /**
  38886. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38887. */
  38888. snapDistance: number;
  38889. /**
  38890. * Event that fires each time the gizmo snaps to a new location.
  38891. * * snapDistance is the the change in distance
  38892. */
  38893. onSnapObservable: Observable<{
  38894. snapDistance: number;
  38895. }>;
  38896. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  38897. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  38898. /**
  38899. * Creates an AxisDragGizmo
  38900. * @param gizmoLayer The utility layer the gizmo will be added to
  38901. * @param dragAxis The axis which the gizmo will be able to drag on
  38902. * @param color The color of the gizmo
  38903. */
  38904. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  38905. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  38906. /**
  38907. * Disposes of the gizmo
  38908. */
  38909. dispose(): void;
  38910. }
  38911. }
  38912. declare module BABYLON.Debug {
  38913. /**
  38914. * The Axes viewer will show 3 axes in a specific point in space
  38915. */
  38916. export class AxesViewer {
  38917. private _xAxis;
  38918. private _yAxis;
  38919. private _zAxis;
  38920. private _scaleLinesFactor;
  38921. private _instanced;
  38922. /**
  38923. * Gets the hosting scene
  38924. */
  38925. scene: Scene;
  38926. /**
  38927. * Gets or sets a number used to scale line length
  38928. */
  38929. scaleLines: number;
  38930. /** Gets the node hierarchy used to render x-axis */
  38931. readonly xAxis: TransformNode;
  38932. /** Gets the node hierarchy used to render y-axis */
  38933. readonly yAxis: TransformNode;
  38934. /** Gets the node hierarchy used to render z-axis */
  38935. readonly zAxis: TransformNode;
  38936. /**
  38937. * Creates a new AxesViewer
  38938. * @param scene defines the hosting scene
  38939. * @param scaleLines defines a number used to scale line length (1 by default)
  38940. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  38941. * @param xAxis defines the node hierarchy used to render the x-axis
  38942. * @param yAxis defines the node hierarchy used to render the y-axis
  38943. * @param zAxis defines the node hierarchy used to render the z-axis
  38944. */
  38945. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  38946. /**
  38947. * Force the viewer to update
  38948. * @param position defines the position of the viewer
  38949. * @param xaxis defines the x axis of the viewer
  38950. * @param yaxis defines the y axis of the viewer
  38951. * @param zaxis defines the z axis of the viewer
  38952. */
  38953. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  38954. /**
  38955. * Creates an instance of this axes viewer.
  38956. * @returns a new axes viewer with instanced meshes
  38957. */
  38958. createInstance(): AxesViewer;
  38959. /** Releases resources */
  38960. dispose(): void;
  38961. private static _SetRenderingGroupId;
  38962. }
  38963. }
  38964. declare module BABYLON.Debug {
  38965. /**
  38966. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  38967. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  38968. */
  38969. export class BoneAxesViewer extends AxesViewer {
  38970. /**
  38971. * Gets or sets the target mesh where to display the axes viewer
  38972. */
  38973. mesh: Nullable<Mesh>;
  38974. /**
  38975. * Gets or sets the target bone where to display the axes viewer
  38976. */
  38977. bone: Nullable<Bone>;
  38978. /** Gets current position */
  38979. pos: Vector3;
  38980. /** Gets direction of X axis */
  38981. xaxis: Vector3;
  38982. /** Gets direction of Y axis */
  38983. yaxis: Vector3;
  38984. /** Gets direction of Z axis */
  38985. zaxis: Vector3;
  38986. /**
  38987. * Creates a new BoneAxesViewer
  38988. * @param scene defines the hosting scene
  38989. * @param bone defines the target bone
  38990. * @param mesh defines the target mesh
  38991. * @param scaleLines defines a scaling factor for line length (1 by default)
  38992. */
  38993. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  38994. /**
  38995. * Force the viewer to update
  38996. */
  38997. update(): void;
  38998. /** Releases resources */
  38999. dispose(): void;
  39000. }
  39001. }
  39002. declare module BABYLON {
  39003. /**
  39004. * Interface used to define scene explorer extensibility option
  39005. */
  39006. export interface IExplorerExtensibilityOption {
  39007. /**
  39008. * Define the option label
  39009. */
  39010. label: string;
  39011. /**
  39012. * Defines the action to execute on click
  39013. */
  39014. action: (entity: any) => void;
  39015. }
  39016. /**
  39017. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  39018. */
  39019. export interface IExplorerExtensibilityGroup {
  39020. /**
  39021. * Defines a predicate to test if a given type mut be extended
  39022. */
  39023. predicate: (entity: any) => boolean;
  39024. /**
  39025. * Gets the list of options added to a type
  39026. */
  39027. entries: IExplorerExtensibilityOption[];
  39028. }
  39029. /**
  39030. * Interface used to define the options to use to create the Inspector
  39031. */
  39032. export interface IInspectorOptions {
  39033. /**
  39034. * Display in overlay mode (default: false)
  39035. */
  39036. overlay?: boolean;
  39037. /**
  39038. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  39039. */
  39040. globalRoot?: HTMLElement;
  39041. /**
  39042. * Display the Scene explorer
  39043. */
  39044. showExplorer?: boolean;
  39045. /**
  39046. * Display the property inspector
  39047. */
  39048. showInspector?: boolean;
  39049. /**
  39050. * Display in embed mode (both panes on the right)
  39051. */
  39052. embedMode?: boolean;
  39053. /**
  39054. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  39055. */
  39056. handleResize?: boolean;
  39057. /**
  39058. * Allow the panes to popup (default: true)
  39059. */
  39060. enablePopup?: boolean;
  39061. /**
  39062. * Allow the panes to be closed by users (default: true)
  39063. */
  39064. enableClose?: boolean;
  39065. /**
  39066. * Optional list of extensibility entries
  39067. */
  39068. explorerExtensibility?: IExplorerExtensibilityGroup[];
  39069. }
  39070. interface Scene {
  39071. /**
  39072. * @hidden
  39073. * Backing field
  39074. */ debugLayer: DebugLayer;
  39075. /**
  39076. * Gets the debug layer (aka Inspector) associated with the scene
  39077. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39078. */
  39079. debugLayer: DebugLayer;
  39080. }
  39081. /**
  39082. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39083. * what is happening in your scene
  39084. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39085. */
  39086. export class DebugLayer {
  39087. /**
  39088. * Define the url to get the inspector script from.
  39089. * By default it uses the babylonjs CDN.
  39090. * @ignoreNaming
  39091. */
  39092. static InspectorURL: string;
  39093. private _scene;
  39094. private BJSINSPECTOR;
  39095. /**
  39096. * Observable triggered when a property is changed through the inspector.
  39097. */
  39098. onPropertyChangedObservable: Observable<{
  39099. object: any;
  39100. property: string;
  39101. value: any;
  39102. initialValue: any;
  39103. }>;
  39104. /**
  39105. * Instantiates a new debug layer.
  39106. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39107. * what is happening in your scene
  39108. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39109. * @param scene Defines the scene to inspect
  39110. */
  39111. constructor(scene: Scene);
  39112. /** Creates the inspector window. */
  39113. private _createInspector;
  39114. /** Get the inspector from bundle or global */
  39115. private _getGlobalInspector;
  39116. /**
  39117. * Get if the inspector is visible or not.
  39118. * @returns true if visible otherwise, false
  39119. */
  39120. isVisible(): boolean;
  39121. /**
  39122. * Hide the inspector and close its window.
  39123. */
  39124. hide(): void;
  39125. /**
  39126. * Launch the debugLayer.
  39127. * @param config Define the configuration of the inspector
  39128. */
  39129. show(config?: IInspectorOptions): void;
  39130. }
  39131. }
  39132. declare module BABYLON {
  39133. /**
  39134. * Class containing static functions to help procedurally build meshes
  39135. */
  39136. export class BoxBuilder {
  39137. /**
  39138. * Creates a box mesh
  39139. * * The parameter `size` sets the size (float) of each box side (default 1)
  39140. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  39141. * * 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)
  39142. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  39143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39144. * * 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
  39145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39146. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  39147. * @param name defines the name of the mesh
  39148. * @param options defines the options used to create the mesh
  39149. * @param scene defines the hosting scene
  39150. * @returns the box mesh
  39151. */
  39152. static CreateBox(name: string, options: {
  39153. size?: number;
  39154. width?: number;
  39155. height?: number;
  39156. depth?: number;
  39157. faceUV?: Vector4[];
  39158. faceColors?: Color4[];
  39159. sideOrientation?: number;
  39160. frontUVs?: Vector4;
  39161. backUVs?: Vector4;
  39162. updatable?: boolean;
  39163. }, scene?: Nullable<Scene>): Mesh;
  39164. }
  39165. }
  39166. declare module BABYLON {
  39167. /**
  39168. * Class containing static functions to help procedurally build meshes
  39169. */
  39170. export class SphereBuilder {
  39171. /**
  39172. * Creates a sphere mesh
  39173. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  39174. * * 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`)
  39175. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  39176. * * 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
  39177. * * 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)
  39178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39179. * * 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
  39180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39181. * @param name defines the name of the mesh
  39182. * @param options defines the options used to create the mesh
  39183. * @param scene defines the hosting scene
  39184. * @returns the sphere mesh
  39185. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  39186. */
  39187. static CreateSphere(name: string, options: {
  39188. segments?: number;
  39189. diameter?: number;
  39190. diameterX?: number;
  39191. diameterY?: number;
  39192. diameterZ?: number;
  39193. arc?: number;
  39194. slice?: number;
  39195. sideOrientation?: number;
  39196. frontUVs?: Vector4;
  39197. backUVs?: Vector4;
  39198. updatable?: boolean;
  39199. }, scene: any): Mesh;
  39200. }
  39201. }
  39202. declare module BABYLON.Debug {
  39203. /**
  39204. * Used to show the physics impostor around the specific mesh
  39205. */
  39206. export class PhysicsViewer {
  39207. /** @hidden */
  39208. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  39209. /** @hidden */
  39210. protected _meshes: Array<Nullable<AbstractMesh>>;
  39211. /** @hidden */
  39212. protected _scene: Nullable<Scene>;
  39213. /** @hidden */
  39214. protected _numMeshes: number;
  39215. /** @hidden */
  39216. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  39217. private _renderFunction;
  39218. private _utilityLayer;
  39219. private _debugBoxMesh;
  39220. private _debugSphereMesh;
  39221. private _debugMaterial;
  39222. /**
  39223. * Creates a new PhysicsViewer
  39224. * @param scene defines the hosting scene
  39225. */
  39226. constructor(scene: Scene);
  39227. /** @hidden */
  39228. protected _updateDebugMeshes(): void;
  39229. /**
  39230. * Renders a specified physic impostor
  39231. * @param impostor defines the impostor to render
  39232. * @returns the new debug mesh used to render the impostor
  39233. */
  39234. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  39235. /**
  39236. * Hides a specified physic impostor
  39237. * @param impostor defines the impostor to hide
  39238. */
  39239. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  39240. private _getDebugMaterial;
  39241. private _getDebugBoxMesh;
  39242. private _getDebugSphereMesh;
  39243. private _getDebugMesh;
  39244. /** Releases all resources */
  39245. dispose(): void;
  39246. }
  39247. }
  39248. declare module BABYLON {
  39249. /**
  39250. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  39251. * in order to better appreciate the issue one might have.
  39252. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  39253. */
  39254. export class RayHelper {
  39255. /**
  39256. * Defines the ray we are currently tryin to visualize.
  39257. */
  39258. ray: Nullable<Ray>;
  39259. private _renderPoints;
  39260. private _renderLine;
  39261. private _renderFunction;
  39262. private _scene;
  39263. private _updateToMeshFunction;
  39264. private _attachedToMesh;
  39265. private _meshSpaceDirection;
  39266. private _meshSpaceOrigin;
  39267. /**
  39268. * Helper function to create a colored helper in a scene in one line.
  39269. * @param ray Defines the ray we are currently tryin to visualize
  39270. * @param scene Defines the scene the ray is used in
  39271. * @param color Defines the color we want to see the ray in
  39272. * @returns The newly created ray helper.
  39273. */
  39274. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  39275. /**
  39276. * Instantiate a new ray helper.
  39277. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  39278. * in order to better appreciate the issue one might have.
  39279. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  39280. * @param ray Defines the ray we are currently tryin to visualize
  39281. */
  39282. constructor(ray: Ray);
  39283. /**
  39284. * Shows the ray we are willing to debug.
  39285. * @param scene Defines the scene the ray needs to be rendered in
  39286. * @param color Defines the color the ray needs to be rendered in
  39287. */
  39288. show(scene: Scene, color?: Color3): void;
  39289. /**
  39290. * Hides the ray we are debugging.
  39291. */
  39292. hide(): void;
  39293. private _render;
  39294. /**
  39295. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  39296. * @param mesh Defines the mesh we want the helper attached to
  39297. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  39298. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  39299. * @param length Defines the length of the ray
  39300. */
  39301. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  39302. /**
  39303. * Detach the ray helper from the mesh it has previously been attached to.
  39304. */
  39305. detachFromMesh(): void;
  39306. private _updateToMesh;
  39307. /**
  39308. * Dispose the helper and release its associated resources.
  39309. */
  39310. dispose(): void;
  39311. }
  39312. }
  39313. declare module BABYLON.Debug {
  39314. /**
  39315. * Class used to render a debug view of a given skeleton
  39316. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  39317. */
  39318. export class SkeletonViewer {
  39319. /** defines the skeleton to render */
  39320. skeleton: Skeleton;
  39321. /** defines the mesh attached to the skeleton */
  39322. mesh: AbstractMesh;
  39323. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  39324. autoUpdateBonesMatrices: boolean;
  39325. /** defines the rendering group id to use with the viewer */
  39326. renderingGroupId: number;
  39327. /** Gets or sets the color used to render the skeleton */
  39328. color: Color3;
  39329. private _scene;
  39330. private _debugLines;
  39331. private _debugMesh;
  39332. private _isEnabled;
  39333. private _renderFunction;
  39334. private _utilityLayer;
  39335. /**
  39336. * Returns the mesh used to render the bones
  39337. */
  39338. readonly debugMesh: Nullable<LinesMesh>;
  39339. /**
  39340. * Creates a new SkeletonViewer
  39341. * @param skeleton defines the skeleton to render
  39342. * @param mesh defines the mesh attached to the skeleton
  39343. * @param scene defines the hosting scene
  39344. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  39345. * @param renderingGroupId defines the rendering group id to use with the viewer
  39346. */
  39347. constructor(
  39348. /** defines the skeleton to render */
  39349. skeleton: Skeleton,
  39350. /** defines the mesh attached to the skeleton */
  39351. mesh: AbstractMesh, scene: Scene,
  39352. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  39353. autoUpdateBonesMatrices?: boolean,
  39354. /** defines the rendering group id to use with the viewer */
  39355. renderingGroupId?: number);
  39356. /** Gets or sets a boolean indicating if the viewer is enabled */
  39357. isEnabled: boolean;
  39358. private _getBonePosition;
  39359. private _getLinesForBonesWithLength;
  39360. private _getLinesForBonesNoLength;
  39361. /** Update the viewer to sync with current skeleton state */
  39362. update(): void;
  39363. /** Release associated resources */
  39364. dispose(): void;
  39365. }
  39366. }
  39367. declare module BABYLON {
  39368. /**
  39369. * Options to create the null engine
  39370. */
  39371. export class NullEngineOptions {
  39372. /**
  39373. * Render width (Default: 512)
  39374. */
  39375. renderWidth: number;
  39376. /**
  39377. * Render height (Default: 256)
  39378. */
  39379. renderHeight: number;
  39380. /**
  39381. * Texture size (Default: 512)
  39382. */
  39383. textureSize: number;
  39384. /**
  39385. * If delta time between frames should be constant
  39386. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39387. */
  39388. deterministicLockstep: boolean;
  39389. /**
  39390. * Maximum about of steps between frames (Default: 4)
  39391. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39392. */
  39393. lockstepMaxSteps: number;
  39394. }
  39395. /**
  39396. * The null engine class provides support for headless version of babylon.js.
  39397. * This can be used in server side scenario or for testing purposes
  39398. */
  39399. export class NullEngine extends Engine {
  39400. private _options;
  39401. /**
  39402. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39403. */
  39404. isDeterministicLockStep(): boolean;
  39405. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  39406. getLockstepMaxSteps(): number;
  39407. /**
  39408. * Sets hardware scaling, used to save performance if needed
  39409. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39410. */
  39411. getHardwareScalingLevel(): number;
  39412. constructor(options?: NullEngineOptions);
  39413. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  39414. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  39415. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39416. getRenderWidth(useScreen?: boolean): number;
  39417. getRenderHeight(useScreen?: boolean): number;
  39418. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  39419. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  39420. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  39421. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  39422. bindSamplers(effect: Effect): void;
  39423. enableEffect(effect: Effect): void;
  39424. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39425. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  39426. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  39427. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  39428. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  39429. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  39430. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  39431. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  39432. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  39433. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  39434. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  39435. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  39436. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  39437. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  39438. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  39439. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  39440. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  39441. setFloat(uniform: WebGLUniformLocation, value: number): void;
  39442. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  39443. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  39444. setBool(uniform: WebGLUniformLocation, bool: number): void;
  39445. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  39446. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  39447. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  39448. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  39449. bindBuffers(vertexBuffers: {
  39450. [key: string]: VertexBuffer;
  39451. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  39452. wipeCaches(bruteForce?: boolean): void;
  39453. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39454. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39455. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39456. /** @hidden */ createTexture(): WebGLTexture;
  39457. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  39458. 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;
  39459. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  39460. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  39461. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  39462. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39463. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  39464. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  39465. areAllEffectsReady(): boolean;
  39466. /**
  39467. * @hidden
  39468. * Get the current error code of the webGL context
  39469. * @returns the error code
  39470. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39471. */
  39472. getError(): number;
  39473. /** @hidden */ getUnpackAlignement(): number;
  39474. /** @hidden */ unpackFlipY(value: boolean): void;
  39475. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  39476. /**
  39477. * Updates a dynamic vertex buffer.
  39478. * @param vertexBuffer the vertex buffer to update
  39479. * @param data the data used to update the vertex buffer
  39480. * @param byteOffset the byte offset of the data (optional)
  39481. * @param byteLength the byte length of the data (optional)
  39482. */
  39483. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  39484. /** @hidden */ bindTexture(channel: number, texture: InternalTexture): void;
  39485. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  39486. releaseEffects(): void;
  39487. displayLoadingUI(): void;
  39488. hideLoadingUI(): void;
  39489. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39490. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39491. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39492. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  39493. }
  39494. }
  39495. declare module BABYLON {
  39496. /** @hidden */
  39497. export class _OcclusionDataStorage {
  39498. /** @hidden */
  39499. occlusionInternalRetryCounter: number;
  39500. /** @hidden */
  39501. isOcclusionQueryInProgress: boolean;
  39502. /** @hidden */
  39503. isOccluded: boolean;
  39504. /** @hidden */
  39505. occlusionRetryCount: number;
  39506. /** @hidden */
  39507. occlusionType: number;
  39508. /** @hidden */
  39509. occlusionQueryAlgorithmType: number;
  39510. }
  39511. interface Engine {
  39512. /**
  39513. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  39514. * @return the new query
  39515. */
  39516. createQuery(): WebGLQuery;
  39517. /**
  39518. * Delete and release a webGL query
  39519. * @param query defines the query to delete
  39520. * @return the current engine
  39521. */
  39522. deleteQuery(query: WebGLQuery): Engine;
  39523. /**
  39524. * Check if a given query has resolved and got its value
  39525. * @param query defines the query to check
  39526. * @returns true if the query got its value
  39527. */
  39528. isQueryResultAvailable(query: WebGLQuery): boolean;
  39529. /**
  39530. * Gets the value of a given query
  39531. * @param query defines the query to check
  39532. * @returns the value of the query
  39533. */
  39534. getQueryResult(query: WebGLQuery): number;
  39535. /**
  39536. * Initiates an occlusion query
  39537. * @param algorithmType defines the algorithm to use
  39538. * @param query defines the query to use
  39539. * @returns the current engine
  39540. * @see http://doc.babylonjs.com/features/occlusionquery
  39541. */
  39542. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  39543. /**
  39544. * Ends an occlusion query
  39545. * @see http://doc.babylonjs.com/features/occlusionquery
  39546. * @param algorithmType defines the algorithm to use
  39547. * @returns the current engine
  39548. */
  39549. endOcclusionQuery(algorithmType: number): Engine;
  39550. /**
  39551. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  39552. * Please note that only one query can be issued at a time
  39553. * @returns a time token used to track the time span
  39554. */
  39555. startTimeQuery(): Nullable<_TimeToken>;
  39556. /**
  39557. * Ends a time query
  39558. * @param token defines the token used to measure the time span
  39559. * @returns the time spent (in ns)
  39560. */
  39561. endTimeQuery(token: _TimeToken): int;
  39562. /** @hidden */ currentNonTimestampToken: Nullable<_TimeToken>;
  39563. /** @hidden */ createTimeQuery(): WebGLQuery;
  39564. /** @hidden */ deleteTimeQuery(query: WebGLQuery): void;
  39565. /** @hidden */ getGlAlgorithmType(algorithmType: number): number;
  39566. /** @hidden */ getTimeQueryResult(query: WebGLQuery): any;
  39567. /** @hidden */ getTimeQueryAvailability(query: WebGLQuery): any;
  39568. }
  39569. interface AbstractMesh {
  39570. /**
  39571. * Backing filed
  39572. * @hidden
  39573. */ private _occlusionDataStorage: _OcclusionDataStorage;
  39574. /**
  39575. * Access property
  39576. * @hidden
  39577. */ occlusionDataStorage: _OcclusionDataStorage;
  39578. /**
  39579. * 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.
  39580. * The default value is -1 which means don't break the query and wait till the result
  39581. * @see http://doc.babylonjs.com/features/occlusionquery
  39582. */
  39583. occlusionRetryCount: number;
  39584. /**
  39585. * 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:
  39586. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  39587. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  39588. * * 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.
  39589. * @see http://doc.babylonjs.com/features/occlusionquery
  39590. */
  39591. occlusionType: number;
  39592. /**
  39593. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  39594. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  39595. * * 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.
  39596. * @see http://doc.babylonjs.com/features/occlusionquery
  39597. */
  39598. occlusionQueryAlgorithmType: number;
  39599. /**
  39600. * 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
  39601. * @see http://doc.babylonjs.com/features/occlusionquery
  39602. */
  39603. isOccluded: boolean;
  39604. /**
  39605. * Flag to check the progress status of the query
  39606. * @see http://doc.babylonjs.com/features/occlusionquery
  39607. */
  39608. isOcclusionQueryInProgress: boolean;
  39609. }
  39610. }
  39611. declare module BABYLON {
  39612. /** @hidden */
  39613. export var _forceTransformFeedbackToBundle: boolean;
  39614. interface Engine {
  39615. /**
  39616. * Creates a webGL transform feedback object
  39617. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  39618. * @returns the webGL transform feedback object
  39619. */
  39620. createTransformFeedback(): WebGLTransformFeedback;
  39621. /**
  39622. * Delete a webGL transform feedback object
  39623. * @param value defines the webGL transform feedback object to delete
  39624. */
  39625. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  39626. /**
  39627. * Bind a webGL transform feedback object to the webgl context
  39628. * @param value defines the webGL transform feedback object to bind
  39629. */
  39630. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  39631. /**
  39632. * Begins a transform feedback operation
  39633. * @param usePoints defines if points or triangles must be used
  39634. */
  39635. beginTransformFeedback(usePoints: boolean): void;
  39636. /**
  39637. * Ends a transform feedback operation
  39638. */
  39639. endTransformFeedback(): void;
  39640. /**
  39641. * Specify the varyings to use with transform feedback
  39642. * @param program defines the associated webGL program
  39643. * @param value defines the list of strings representing the varying names
  39644. */
  39645. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  39646. /**
  39647. * Bind a webGL buffer for a transform feedback operation
  39648. * @param value defines the webGL buffer to bind
  39649. */
  39650. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  39651. }
  39652. }
  39653. declare module BABYLON {
  39654. /**
  39655. * Gather the list of clipboard event types as constants.
  39656. */
  39657. export class ClipboardEventTypes {
  39658. /**
  39659. * The clipboard event is fired when a copy command is active (pressed).
  39660. */
  39661. static readonly COPY: number;
  39662. /**
  39663. * The clipboard event is fired when a cut command is active (pressed).
  39664. */
  39665. static readonly CUT: number;
  39666. /**
  39667. * The clipboard event is fired when a paste command is active (pressed).
  39668. */
  39669. static readonly PASTE: number;
  39670. }
  39671. /**
  39672. * This class is used to store clipboard related info for the onClipboardObservable event.
  39673. */
  39674. export class ClipboardInfo {
  39675. /**
  39676. * Defines the type of event (BABYLON.ClipboardEventTypes)
  39677. */
  39678. type: number;
  39679. /**
  39680. * Defines the related dom event
  39681. */
  39682. event: ClipboardEvent;
  39683. /**
  39684. *Creates an instance of ClipboardInfo.
  39685. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  39686. * @param event Defines the related dom event
  39687. */
  39688. constructor(
  39689. /**
  39690. * Defines the type of event (BABYLON.ClipboardEventTypes)
  39691. */
  39692. type: number,
  39693. /**
  39694. * Defines the related dom event
  39695. */
  39696. event: ClipboardEvent);
  39697. /**
  39698. * Get the clipboard event's type from the keycode.
  39699. * @param keyCode Defines the keyCode for the current keyboard event.
  39700. * @return {number}
  39701. */
  39702. static GetTypeFromCharacter(keyCode: number): number;
  39703. }
  39704. }
  39705. declare module BABYLON {
  39706. /**
  39707. * Class used to represent data loading progression
  39708. */
  39709. export class SceneLoaderProgressEvent {
  39710. /** defines if data length to load can be evaluated */
  39711. readonly lengthComputable: boolean;
  39712. /** defines the loaded data length */
  39713. readonly loaded: number;
  39714. /** defines the data length to load */
  39715. readonly total: number;
  39716. /**
  39717. * Create a new progress event
  39718. * @param lengthComputable defines if data length to load can be evaluated
  39719. * @param loaded defines the loaded data length
  39720. * @param total defines the data length to load
  39721. */
  39722. constructor(
  39723. /** defines if data length to load can be evaluated */
  39724. lengthComputable: boolean,
  39725. /** defines the loaded data length */
  39726. loaded: number,
  39727. /** defines the data length to load */
  39728. total: number);
  39729. /**
  39730. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  39731. * @param event defines the source event
  39732. * @returns a new SceneLoaderProgressEvent
  39733. */
  39734. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  39735. }
  39736. /**
  39737. * Interface used by SceneLoader plugins to define supported file extensions
  39738. */
  39739. export interface ISceneLoaderPluginExtensions {
  39740. /**
  39741. * Defines the list of supported extensions
  39742. */
  39743. [extension: string]: {
  39744. isBinary: boolean;
  39745. };
  39746. }
  39747. /**
  39748. * Interface used by SceneLoader plugin factory
  39749. */
  39750. export interface ISceneLoaderPluginFactory {
  39751. /**
  39752. * Defines the name of the factory
  39753. */
  39754. name: string;
  39755. /**
  39756. * Function called to create a new plugin
  39757. * @return the new plugin
  39758. */
  39759. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  39760. /**
  39761. * Boolean indicating if the plugin can direct load specific data
  39762. */
  39763. canDirectLoad?: (data: string) => boolean;
  39764. }
  39765. /**
  39766. * Interface used to define a SceneLoader plugin
  39767. */
  39768. export interface ISceneLoaderPlugin {
  39769. /**
  39770. * The friendly name of this plugin.
  39771. */
  39772. name: string;
  39773. /**
  39774. * The file extensions supported by this plugin.
  39775. */
  39776. extensions: string | ISceneLoaderPluginExtensions;
  39777. /**
  39778. * Import meshes into a scene.
  39779. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  39780. * @param scene The scene to import into
  39781. * @param data The data to import
  39782. * @param rootUrl The root url for scene and resources
  39783. * @param meshes The meshes array to import into
  39784. * @param particleSystems The particle systems array to import into
  39785. * @param skeletons The skeletons array to import into
  39786. * @param onError The callback when import fails
  39787. * @returns True if successful or false otherwise
  39788. */
  39789. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  39790. /**
  39791. * Load into a scene.
  39792. * @param scene The scene to load into
  39793. * @param data The data to import
  39794. * @param rootUrl The root url for scene and resources
  39795. * @param onError The callback when import fails
  39796. * @returns true if successful or false otherwise
  39797. */
  39798. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  39799. /**
  39800. * The callback that returns true if the data can be directly loaded.
  39801. */
  39802. canDirectLoad?: (data: string) => boolean;
  39803. /**
  39804. * The callback that allows custom handling of the root url based on the response url.
  39805. */
  39806. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  39807. /**
  39808. * Load into an asset container.
  39809. * @param scene The scene to load into
  39810. * @param data The data to import
  39811. * @param rootUrl The root url for scene and resources
  39812. * @param onError The callback when import fails
  39813. * @returns The loaded asset container
  39814. */
  39815. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  39816. }
  39817. /**
  39818. * Interface used to define an async SceneLoader plugin
  39819. */
  39820. export interface ISceneLoaderPluginAsync {
  39821. /**
  39822. * The friendly name of this plugin.
  39823. */
  39824. name: string;
  39825. /**
  39826. * The file extensions supported by this plugin.
  39827. */
  39828. extensions: string | ISceneLoaderPluginExtensions;
  39829. /**
  39830. * Import meshes into a scene.
  39831. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  39832. * @param scene The scene to import into
  39833. * @param data The data to import
  39834. * @param rootUrl The root url for scene and resources
  39835. * @param onProgress The callback when the load progresses
  39836. * @param fileName Defines the name of the file to load
  39837. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  39838. */
  39839. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  39840. meshes: AbstractMesh[];
  39841. particleSystems: IParticleSystem[];
  39842. skeletons: Skeleton[];
  39843. animationGroups: AnimationGroup[];
  39844. }>;
  39845. /**
  39846. * Load into a scene.
  39847. * @param scene The scene to load into
  39848. * @param data The data to import
  39849. * @param rootUrl The root url for scene and resources
  39850. * @param onProgress The callback when the load progresses
  39851. * @param fileName Defines the name of the file to load
  39852. * @returns Nothing
  39853. */
  39854. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  39855. /**
  39856. * The callback that returns true if the data can be directly loaded.
  39857. */
  39858. canDirectLoad?: (data: string) => boolean;
  39859. /**
  39860. * The callback that allows custom handling of the root url based on the response url.
  39861. */
  39862. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  39863. /**
  39864. * Load into an asset container.
  39865. * @param scene The scene to load into
  39866. * @param data The data to import
  39867. * @param rootUrl The root url for scene and resources
  39868. * @param onProgress The callback when the load progresses
  39869. * @param fileName Defines the name of the file to load
  39870. * @returns The loaded asset container
  39871. */
  39872. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  39873. }
  39874. /**
  39875. * Class used to load scene from various file formats using registered plugins
  39876. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  39877. */
  39878. export class SceneLoader {
  39879. /**
  39880. * No logging while loading
  39881. */
  39882. static readonly NO_LOGGING: number;
  39883. /**
  39884. * Minimal logging while loading
  39885. */
  39886. static readonly MINIMAL_LOGGING: number;
  39887. /**
  39888. * Summary logging while loading
  39889. */
  39890. static readonly SUMMARY_LOGGING: number;
  39891. /**
  39892. * Detailled logging while loading
  39893. */
  39894. static readonly DETAILED_LOGGING: number;
  39895. /**
  39896. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  39897. */
  39898. static ForceFullSceneLoadingForIncremental: boolean;
  39899. /**
  39900. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  39901. */
  39902. static ShowLoadingScreen: boolean;
  39903. /**
  39904. * Defines the current logging level (while loading the scene)
  39905. * @ignorenaming
  39906. */
  39907. static loggingLevel: number;
  39908. /**
  39909. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  39910. */
  39911. static CleanBoneMatrixWeights: boolean;
  39912. /**
  39913. * Event raised when a plugin is used to load a scene
  39914. */
  39915. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  39916. private static _registeredPlugins;
  39917. private static _getDefaultPlugin;
  39918. private static _getPluginForExtension;
  39919. private static _getPluginForDirectLoad;
  39920. private static _getPluginForFilename;
  39921. private static _getDirectLoad;
  39922. private static _loadData;
  39923. private static _getFileInfo;
  39924. /**
  39925. * Gets a plugin that can load the given extension
  39926. * @param extension defines the extension to load
  39927. * @returns a plugin or null if none works
  39928. */
  39929. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  39930. /**
  39931. * Gets a boolean indicating that the given extension can be loaded
  39932. * @param extension defines the extension to load
  39933. * @returns true if the extension is supported
  39934. */
  39935. static IsPluginForExtensionAvailable(extension: string): boolean;
  39936. /**
  39937. * Adds a new plugin to the list of registered plugins
  39938. * @param plugin defines the plugin to add
  39939. */
  39940. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  39941. /**
  39942. * Import meshes into a scene
  39943. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  39944. * @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)
  39945. * @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)
  39946. * @param scene the instance of BABYLON.Scene to append to
  39947. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  39948. * @param onProgress a callback with a progress event for each file being loaded
  39949. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  39950. * @param pluginExtension the extension used to determine the plugin
  39951. * @returns The loaded plugin
  39952. */
  39953. 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>;
  39954. /**
  39955. * Import meshes into a scene
  39956. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  39957. * @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)
  39958. * @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)
  39959. * @param scene the instance of BABYLON.Scene to append to
  39960. * @param onProgress a callback with a progress event for each file being loaded
  39961. * @param pluginExtension the extension used to determine the plugin
  39962. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  39963. */
  39964. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  39965. meshes: AbstractMesh[];
  39966. particleSystems: IParticleSystem[];
  39967. skeletons: Skeleton[];
  39968. animationGroups: AnimationGroup[];
  39969. }>;
  39970. /**
  39971. * Load a scene
  39972. * @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)
  39973. * @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)
  39974. * @param engine is the instance of BABYLON.Engine to use to create the scene
  39975. * @param onSuccess a callback with the scene when import succeeds
  39976. * @param onProgress a callback with a progress event for each file being loaded
  39977. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  39978. * @param pluginExtension the extension used to determine the plugin
  39979. * @returns The loaded plugin
  39980. */
  39981. 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>;
  39982. /**
  39983. * Load a scene
  39984. * @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)
  39985. * @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)
  39986. * @param engine is the instance of BABYLON.Engine to use to create the scene
  39987. * @param onProgress a callback with a progress event for each file being loaded
  39988. * @param pluginExtension the extension used to determine the plugin
  39989. * @returns The loaded scene
  39990. */
  39991. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  39992. /**
  39993. * Append a scene
  39994. * @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)
  39995. * @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)
  39996. * @param scene is the instance of BABYLON.Scene to append to
  39997. * @param onSuccess a callback with the scene when import succeeds
  39998. * @param onProgress a callback with a progress event for each file being loaded
  39999. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40000. * @param pluginExtension the extension used to determine the plugin
  40001. * @returns The loaded plugin
  40002. */
  40003. 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>;
  40004. /**
  40005. * Append a scene
  40006. * @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)
  40007. * @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)
  40008. * @param scene is the instance of BABYLON.Scene to append to
  40009. * @param onProgress a callback with a progress event for each file being loaded
  40010. * @param pluginExtension the extension used to determine the plugin
  40011. * @returns The given scene
  40012. */
  40013. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  40014. /**
  40015. * Load a scene into an asset container
  40016. * @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)
  40017. * @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)
  40018. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40019. * @param onSuccess a callback with the scene when import succeeds
  40020. * @param onProgress a callback with a progress event for each file being loaded
  40021. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40022. * @param pluginExtension the extension used to determine the plugin
  40023. * @returns The loaded plugin
  40024. */
  40025. 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>;
  40026. /**
  40027. * Load a scene into an asset container
  40028. * @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)
  40029. * @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)
  40030. * @param scene is the instance of Scene to append to
  40031. * @param onProgress a callback with a progress event for each file being loaded
  40032. * @param pluginExtension the extension used to determine the plugin
  40033. * @returns The loaded asset container
  40034. */
  40035. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  40036. }
  40037. }
  40038. declare module BABYLON {
  40039. /**
  40040. * Google Daydream controller
  40041. */
  40042. export class DaydreamController extends WebVRController {
  40043. /**
  40044. * Base Url for the controller model.
  40045. */
  40046. static MODEL_BASE_URL: string;
  40047. /**
  40048. * File name for the controller model.
  40049. */
  40050. static MODEL_FILENAME: string;
  40051. /**
  40052. * Gamepad Id prefix used to identify Daydream Controller.
  40053. */
  40054. static readonly GAMEPAD_ID_PREFIX: string;
  40055. /**
  40056. * Creates a new DaydreamController from a gamepad
  40057. * @param vrGamepad the gamepad that the controller should be created from
  40058. */
  40059. constructor(vrGamepad: any);
  40060. /**
  40061. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40062. * @param scene scene in which to add meshes
  40063. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40064. */
  40065. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40066. /**
  40067. * Called once for each button that changed state since the last frame
  40068. * @param buttonIdx Which button index changed
  40069. * @param state New state of the button
  40070. * @param changes Which properties on the state changed since last frame
  40071. */
  40072. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40073. }
  40074. }
  40075. declare module BABYLON {
  40076. /**
  40077. * Gear VR Controller
  40078. */
  40079. export class GearVRController extends WebVRController {
  40080. /**
  40081. * Base Url for the controller model.
  40082. */
  40083. static MODEL_BASE_URL: string;
  40084. /**
  40085. * File name for the controller model.
  40086. */
  40087. static MODEL_FILENAME: string;
  40088. /**
  40089. * Gamepad Id prefix used to identify this controller.
  40090. */
  40091. static readonly GAMEPAD_ID_PREFIX: string;
  40092. private readonly _buttonIndexToObservableNameMap;
  40093. /**
  40094. * Creates a new GearVRController from a gamepad
  40095. * @param vrGamepad the gamepad that the controller should be created from
  40096. */
  40097. constructor(vrGamepad: any);
  40098. /**
  40099. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40100. * @param scene scene in which to add meshes
  40101. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40102. */
  40103. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40104. /**
  40105. * Called once for each button that changed state since the last frame
  40106. * @param buttonIdx Which button index changed
  40107. * @param state New state of the button
  40108. * @param changes Which properties on the state changed since last frame
  40109. */
  40110. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40111. }
  40112. }
  40113. declare module BABYLON {
  40114. /**
  40115. * Generic Controller
  40116. */
  40117. export class GenericController extends WebVRController {
  40118. /**
  40119. * Base Url for the controller model.
  40120. */
  40121. static readonly MODEL_BASE_URL: string;
  40122. /**
  40123. * File name for the controller model.
  40124. */
  40125. static readonly MODEL_FILENAME: string;
  40126. /**
  40127. * Creates a new GenericController from a gamepad
  40128. * @param vrGamepad the gamepad that the controller should be created from
  40129. */
  40130. constructor(vrGamepad: any);
  40131. /**
  40132. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40133. * @param scene scene in which to add meshes
  40134. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40135. */
  40136. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40137. /**
  40138. * Called once for each button that changed state since the last frame
  40139. * @param buttonIdx Which button index changed
  40140. * @param state New state of the button
  40141. * @param changes Which properties on the state changed since last frame
  40142. */
  40143. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40144. }
  40145. }
  40146. declare module BABYLON {
  40147. /**
  40148. * Oculus Touch Controller
  40149. */
  40150. export class OculusTouchController extends WebVRController {
  40151. /**
  40152. * Base Url for the controller model.
  40153. */
  40154. static MODEL_BASE_URL: string;
  40155. /**
  40156. * File name for the left controller model.
  40157. */
  40158. static MODEL_LEFT_FILENAME: string;
  40159. /**
  40160. * File name for the right controller model.
  40161. */
  40162. static MODEL_RIGHT_FILENAME: string;
  40163. /**
  40164. * Fired when the secondary trigger on this controller is modified
  40165. */
  40166. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  40167. /**
  40168. * Fired when the thumb rest on this controller is modified
  40169. */
  40170. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  40171. /**
  40172. * Creates a new OculusTouchController from a gamepad
  40173. * @param vrGamepad the gamepad that the controller should be created from
  40174. */
  40175. constructor(vrGamepad: any);
  40176. /**
  40177. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40178. * @param scene scene in which to add meshes
  40179. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40180. */
  40181. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40182. /**
  40183. * Fired when the A button on this controller is modified
  40184. */
  40185. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40186. /**
  40187. * Fired when the B button on this controller is modified
  40188. */
  40189. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40190. /**
  40191. * Fired when the X button on this controller is modified
  40192. */
  40193. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40194. /**
  40195. * Fired when the Y button on this controller is modified
  40196. */
  40197. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40198. /**
  40199. * Called once for each button that changed state since the last frame
  40200. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  40201. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  40202. * 2) secondary trigger (same)
  40203. * 3) A (right) X (left), touch, pressed = value
  40204. * 4) B / Y
  40205. * 5) thumb rest
  40206. * @param buttonIdx Which button index changed
  40207. * @param state New state of the button
  40208. * @param changes Which properties on the state changed since last frame
  40209. */
  40210. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40211. }
  40212. }
  40213. declare module BABYLON {
  40214. /**
  40215. * Vive Controller
  40216. */
  40217. export class ViveController extends WebVRController {
  40218. /**
  40219. * Base Url for the controller model.
  40220. */
  40221. static MODEL_BASE_URL: string;
  40222. /**
  40223. * File name for the controller model.
  40224. */
  40225. static MODEL_FILENAME: string;
  40226. /**
  40227. * Creates a new ViveController from a gamepad
  40228. * @param vrGamepad the gamepad that the controller should be created from
  40229. */
  40230. constructor(vrGamepad: any);
  40231. /**
  40232. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40233. * @param scene scene in which to add meshes
  40234. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40235. */
  40236. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40237. /**
  40238. * Fired when the left button on this controller is modified
  40239. */
  40240. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40241. /**
  40242. * Fired when the right button on this controller is modified
  40243. */
  40244. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40245. /**
  40246. * Fired when the menu button on this controller is modified
  40247. */
  40248. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40249. /**
  40250. * Called once for each button that changed state since the last frame
  40251. * Vive mapping:
  40252. * 0: touchpad
  40253. * 1: trigger
  40254. * 2: left AND right buttons
  40255. * 3: menu button
  40256. * @param buttonIdx Which button index changed
  40257. * @param state New state of the button
  40258. * @param changes Which properties on the state changed since last frame
  40259. */
  40260. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40261. }
  40262. }
  40263. declare module BABYLON {
  40264. /**
  40265. * Defines the WindowsMotionController object that the state of the windows motion controller
  40266. */
  40267. export class WindowsMotionController extends WebVRController {
  40268. /**
  40269. * The base url used to load the left and right controller models
  40270. */
  40271. static MODEL_BASE_URL: string;
  40272. /**
  40273. * The name of the left controller model file
  40274. */
  40275. static MODEL_LEFT_FILENAME: string;
  40276. /**
  40277. * The name of the right controller model file
  40278. */
  40279. static MODEL_RIGHT_FILENAME: string;
  40280. /**
  40281. * The controller name prefix for this controller type
  40282. */
  40283. static readonly GAMEPAD_ID_PREFIX: string;
  40284. /**
  40285. * The controller id pattern for this controller type
  40286. */
  40287. private static readonly GAMEPAD_ID_PATTERN;
  40288. private _loadedMeshInfo;
  40289. private readonly _mapping;
  40290. /**
  40291. * Fired when the trackpad on this controller is clicked
  40292. */
  40293. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  40294. /**
  40295. * Fired when the trackpad on this controller is modified
  40296. */
  40297. onTrackpadValuesChangedObservable: Observable<StickValues>;
  40298. /**
  40299. * The current x and y values of this controller's trackpad
  40300. */
  40301. trackpad: StickValues;
  40302. /**
  40303. * Creates a new WindowsMotionController from a gamepad
  40304. * @param vrGamepad the gamepad that the controller should be created from
  40305. */
  40306. constructor(vrGamepad: any);
  40307. /**
  40308. * Fired when the trigger on this controller is modified
  40309. */
  40310. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40311. /**
  40312. * Fired when the menu button on this controller is modified
  40313. */
  40314. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40315. /**
  40316. * Fired when the grip button on this controller is modified
  40317. */
  40318. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40319. /**
  40320. * Fired when the thumbstick button on this controller is modified
  40321. */
  40322. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40323. /**
  40324. * Fired when the touchpad button on this controller is modified
  40325. */
  40326. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40327. /**
  40328. * Fired when the touchpad values on this controller are modified
  40329. */
  40330. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  40331. private _updateTrackpad;
  40332. /**
  40333. * Called once per frame by the engine.
  40334. */
  40335. update(): void;
  40336. /**
  40337. * Called once for each button that changed state since the last frame
  40338. * @param buttonIdx Which button index changed
  40339. * @param state New state of the button
  40340. * @param changes Which properties on the state changed since last frame
  40341. */
  40342. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40343. /**
  40344. * Moves the buttons on the controller mesh based on their current state
  40345. * @param buttonName the name of the button to move
  40346. * @param buttonValue the value of the button which determines the buttons new position
  40347. */
  40348. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  40349. /**
  40350. * Moves the axis on the controller mesh based on its current state
  40351. * @param axis the index of the axis
  40352. * @param axisValue the value of the axis which determines the meshes new position
  40353. * @hidden
  40354. */
  40355. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  40356. /**
  40357. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40358. * @param scene scene in which to add meshes
  40359. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40360. */
  40361. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  40362. /**
  40363. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  40364. * can be transformed by button presses and axes values, based on this._mapping.
  40365. *
  40366. * @param scene scene in which the meshes exist
  40367. * @param meshes list of meshes that make up the controller model to process
  40368. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  40369. */
  40370. private processModel;
  40371. private createMeshInfo;
  40372. /**
  40373. * Gets the ray of the controller in the direction the controller is pointing
  40374. * @param length the length the resulting ray should be
  40375. * @returns a ray in the direction the controller is pointing
  40376. */
  40377. getForwardRay(length?: number): Ray;
  40378. /**
  40379. * Disposes of the controller
  40380. */
  40381. dispose(): void;
  40382. }
  40383. }
  40384. declare module BABYLON {
  40385. /**
  40386. * Single axis scale gizmo
  40387. */
  40388. export class AxisScaleGizmo extends Gizmo {
  40389. private _coloredMaterial;
  40390. /**
  40391. * Drag behavior responsible for the gizmos dragging interactions
  40392. */
  40393. dragBehavior: PointerDragBehavior;
  40394. private _pointerObserver;
  40395. /**
  40396. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40397. */
  40398. snapDistance: number;
  40399. /**
  40400. * Event that fires each time the gizmo snaps to a new location.
  40401. * * snapDistance is the the change in distance
  40402. */
  40403. onSnapObservable: Observable<{
  40404. snapDistance: number;
  40405. }>;
  40406. /**
  40407. * If the scaling operation should be done on all axis (default: false)
  40408. */
  40409. uniformScaling: boolean;
  40410. /**
  40411. * Creates an AxisScaleGizmo
  40412. * @param gizmoLayer The utility layer the gizmo will be added to
  40413. * @param dragAxis The axis which the gizmo will be able to scale on
  40414. * @param color The color of the gizmo
  40415. */
  40416. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40417. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40418. /**
  40419. * Disposes of the gizmo
  40420. */
  40421. dispose(): void;
  40422. /**
  40423. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40424. * @param mesh The mesh to replace the default mesh of the gizmo
  40425. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  40426. */
  40427. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  40428. }
  40429. }
  40430. declare module BABYLON {
  40431. /**
  40432. * Bounding box gizmo
  40433. */
  40434. export class BoundingBoxGizmo extends Gizmo {
  40435. private _lineBoundingBox;
  40436. private _rotateSpheresParent;
  40437. private _scaleBoxesParent;
  40438. private _boundingDimensions;
  40439. private _renderObserver;
  40440. private _pointerObserver;
  40441. private _scaleDragSpeed;
  40442. private _tmpQuaternion;
  40443. private _tmpVector;
  40444. private _tmpRotationMatrix;
  40445. /**
  40446. * 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)
  40447. */
  40448. ignoreChildren: boolean;
  40449. /**
  40450. * 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)
  40451. */
  40452. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  40453. /**
  40454. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  40455. */
  40456. rotationSphereSize: number;
  40457. /**
  40458. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  40459. */
  40460. scaleBoxSize: number;
  40461. /**
  40462. * 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)
  40463. */
  40464. fixedDragMeshScreenSize: boolean;
  40465. /**
  40466. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  40467. */
  40468. fixedDragMeshScreenSizeDistanceFactor: number;
  40469. /**
  40470. * Fired when a rotation sphere or scale box is dragged
  40471. */
  40472. onDragStartObservable: Observable<{}>;
  40473. /**
  40474. * Fired when a scale box is dragged
  40475. */
  40476. onScaleBoxDragObservable: Observable<{}>;
  40477. /**
  40478. * Fired when a scale box drag is ended
  40479. */
  40480. onScaleBoxDragEndObservable: Observable<{}>;
  40481. /**
  40482. * Fired when a rotation sphere is dragged
  40483. */
  40484. onRotationSphereDragObservable: Observable<{}>;
  40485. /**
  40486. * Fired when a rotation sphere drag is ended
  40487. */
  40488. onRotationSphereDragEndObservable: Observable<{}>;
  40489. /**
  40490. * 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)
  40491. */
  40492. scalePivot: Nullable<Vector3>;
  40493. private _anchorMesh;
  40494. private _existingMeshScale;
  40495. private _dragMesh;
  40496. private pointerDragBehavior;
  40497. /**
  40498. * Creates an BoundingBoxGizmo
  40499. * @param gizmoLayer The utility layer the gizmo will be added to
  40500. * @param color The color of the gizmo
  40501. */
  40502. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40503. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40504. private _selectNode;
  40505. /**
  40506. * Updates the bounding box information for the Gizmo
  40507. */
  40508. updateBoundingBox(): void;
  40509. private _updateRotationSpheres;
  40510. private _updateScaleBoxes;
  40511. /**
  40512. * Enables rotation on the specified axis and disables rotation on the others
  40513. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  40514. */
  40515. setEnabledRotationAxis(axis: string): void;
  40516. /**
  40517. * Enables/disables scaling
  40518. * @param enable if scaling should be enabled
  40519. */
  40520. setEnabledScaling(enable: boolean): void;
  40521. private _updateDummy;
  40522. /**
  40523. * Enables a pointer drag behavior on the bounding box of the gizmo
  40524. */
  40525. enableDragBehavior(): void;
  40526. /**
  40527. * Disposes of the gizmo
  40528. */
  40529. dispose(): void;
  40530. /**
  40531. * 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)
  40532. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  40533. * @returns the bounding box mesh with the passed in mesh as a child
  40534. */
  40535. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  40536. /**
  40537. * CustomMeshes are not supported by this gizmo
  40538. * @param mesh The mesh to replace the default mesh of the gizmo
  40539. */
  40540. setCustomMesh(mesh: Mesh): void;
  40541. }
  40542. }
  40543. declare module BABYLON {
  40544. /**
  40545. * Single plane rotation gizmo
  40546. */
  40547. export class PlaneRotationGizmo extends Gizmo {
  40548. /**
  40549. * Drag behavior responsible for the gizmos dragging interactions
  40550. */
  40551. dragBehavior: PointerDragBehavior;
  40552. private _pointerObserver;
  40553. /**
  40554. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  40555. */
  40556. snapDistance: number;
  40557. /**
  40558. * Event that fires each time the gizmo snaps to a new location.
  40559. * * snapDistance is the the change in distance
  40560. */
  40561. onSnapObservable: Observable<{
  40562. snapDistance: number;
  40563. }>;
  40564. /**
  40565. * Creates a PlaneRotationGizmo
  40566. * @param gizmoLayer The utility layer the gizmo will be added to
  40567. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  40568. * @param color The color of the gizmo
  40569. * @param tessellation Amount of tessellation to be used when creating rotation circles
  40570. */
  40571. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  40572. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40573. /**
  40574. * Disposes of the gizmo
  40575. */
  40576. dispose(): void;
  40577. }
  40578. }
  40579. declare module BABYLON {
  40580. /**
  40581. * Gizmo that enables rotating a mesh along 3 axis
  40582. */
  40583. export class RotationGizmo extends Gizmo {
  40584. /**
  40585. * Internal gizmo used for interactions on the x axis
  40586. */
  40587. xGizmo: PlaneRotationGizmo;
  40588. /**
  40589. * Internal gizmo used for interactions on the y axis
  40590. */
  40591. yGizmo: PlaneRotationGizmo;
  40592. /**
  40593. * Internal gizmo used for interactions on the z axis
  40594. */
  40595. zGizmo: PlaneRotationGizmo;
  40596. /** Fires an event when any of it's sub gizmos are dragged */
  40597. onDragStartObservable: Observable<{}>;
  40598. /** Fires an event when any of it's sub gizmos are released from dragging */
  40599. onDragEndObservable: Observable<{}>;
  40600. attachedMesh: Nullable<AbstractMesh>;
  40601. /**
  40602. * Creates a RotationGizmo
  40603. * @param gizmoLayer The utility layer the gizmo will be added to
  40604. * @param tessellation Amount of tessellation to be used when creating rotation circles
  40605. */
  40606. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  40607. updateGizmoRotationToMatchAttachedMesh: boolean;
  40608. /**
  40609. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40610. */
  40611. snapDistance: number;
  40612. /**
  40613. * Ratio for the scale of the gizmo (Default: 1)
  40614. */
  40615. scaleRatio: number;
  40616. /**
  40617. * Disposes of the gizmo
  40618. */
  40619. dispose(): void;
  40620. /**
  40621. * CustomMeshes are not supported by this gizmo
  40622. * @param mesh The mesh to replace the default mesh of the gizmo
  40623. */
  40624. setCustomMesh(mesh: Mesh): void;
  40625. }
  40626. }
  40627. declare module BABYLON {
  40628. /**
  40629. * Gizmo that enables dragging a mesh along 3 axis
  40630. */
  40631. export class PositionGizmo extends Gizmo {
  40632. /**
  40633. * Internal gizmo used for interactions on the x axis
  40634. */
  40635. xGizmo: AxisDragGizmo;
  40636. /**
  40637. * Internal gizmo used for interactions on the y axis
  40638. */
  40639. yGizmo: AxisDragGizmo;
  40640. /**
  40641. * Internal gizmo used for interactions on the z axis
  40642. */
  40643. zGizmo: AxisDragGizmo;
  40644. /** Fires an event when any of it's sub gizmos are dragged */
  40645. onDragStartObservable: Observable<{}>;
  40646. /** Fires an event when any of it's sub gizmos are released from dragging */
  40647. onDragEndObservable: Observable<{}>;
  40648. attachedMesh: Nullable<AbstractMesh>;
  40649. /**
  40650. * Creates a PositionGizmo
  40651. * @param gizmoLayer The utility layer the gizmo will be added to
  40652. */
  40653. constructor(gizmoLayer?: UtilityLayerRenderer);
  40654. updateGizmoRotationToMatchAttachedMesh: boolean;
  40655. /**
  40656. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40657. */
  40658. snapDistance: number;
  40659. /**
  40660. * Ratio for the scale of the gizmo (Default: 1)
  40661. */
  40662. scaleRatio: number;
  40663. /**
  40664. * Disposes of the gizmo
  40665. */
  40666. dispose(): void;
  40667. /**
  40668. * CustomMeshes are not supported by this gizmo
  40669. * @param mesh The mesh to replace the default mesh of the gizmo
  40670. */
  40671. setCustomMesh(mesh: Mesh): void;
  40672. }
  40673. }
  40674. declare module BABYLON {
  40675. /**
  40676. * Class containing static functions to help procedurally build meshes
  40677. */
  40678. export class PolyhedronBuilder {
  40679. /**
  40680. * Creates a polyhedron mesh
  40681. * * 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
  40682. * * The parameter `size` (positive float, default 1) sets the polygon size
  40683. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  40684. * * 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`
  40685. * * 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
  40686. * * 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)`)
  40687. * * 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
  40688. * * 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
  40689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40690. * * 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
  40691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40692. * @param name defines the name of the mesh
  40693. * @param options defines the options used to create the mesh
  40694. * @param scene defines the hosting scene
  40695. * @returns the polyhedron mesh
  40696. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  40697. */
  40698. static CreatePolyhedron(name: string, options: {
  40699. type?: number;
  40700. size?: number;
  40701. sizeX?: number;
  40702. sizeY?: number;
  40703. sizeZ?: number;
  40704. custom?: any;
  40705. faceUV?: Vector4[];
  40706. faceColors?: Color4[];
  40707. flat?: boolean;
  40708. updatable?: boolean;
  40709. sideOrientation?: number;
  40710. frontUVs?: Vector4;
  40711. backUVs?: Vector4;
  40712. }, scene: Scene): Mesh;
  40713. }
  40714. }
  40715. declare module BABYLON {
  40716. /**
  40717. * Gizmo that enables scaling a mesh along 3 axis
  40718. */
  40719. export class ScaleGizmo extends Gizmo {
  40720. /**
  40721. * Internal gizmo used for interactions on the x axis
  40722. */
  40723. xGizmo: AxisScaleGizmo;
  40724. /**
  40725. * Internal gizmo used for interactions on the y axis
  40726. */
  40727. yGizmo: AxisScaleGizmo;
  40728. /**
  40729. * Internal gizmo used for interactions on the z axis
  40730. */
  40731. zGizmo: AxisScaleGizmo;
  40732. /**
  40733. * Internal gizmo used to scale all axis equally
  40734. */
  40735. uniformScaleGizmo: AxisScaleGizmo;
  40736. /** Fires an event when any of it's sub gizmos are dragged */
  40737. onDragStartObservable: Observable<{}>;
  40738. /** Fires an event when any of it's sub gizmos are released from dragging */
  40739. onDragEndObservable: Observable<{}>;
  40740. attachedMesh: Nullable<AbstractMesh>;
  40741. /**
  40742. * Creates a ScaleGizmo
  40743. * @param gizmoLayer The utility layer the gizmo will be added to
  40744. */
  40745. constructor(gizmoLayer?: UtilityLayerRenderer);
  40746. updateGizmoRotationToMatchAttachedMesh: boolean;
  40747. /**
  40748. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40749. */
  40750. snapDistance: number;
  40751. /**
  40752. * Ratio for the scale of the gizmo (Default: 1)
  40753. */
  40754. scaleRatio: number;
  40755. /**
  40756. * Disposes of the gizmo
  40757. */
  40758. dispose(): void;
  40759. }
  40760. }
  40761. declare module BABYLON {
  40762. /**
  40763. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  40764. */
  40765. export class GizmoManager implements IDisposable {
  40766. private scene;
  40767. /**
  40768. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  40769. */
  40770. gizmos: {
  40771. positionGizmo: Nullable<PositionGizmo>;
  40772. rotationGizmo: Nullable<RotationGizmo>;
  40773. scaleGizmo: Nullable<ScaleGizmo>;
  40774. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  40775. };
  40776. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  40777. clearGizmoOnEmptyPointerEvent: boolean;
  40778. /** Fires an event when the manager is attached to a mesh */
  40779. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  40780. private _gizmosEnabled;
  40781. private _pointerObserver;
  40782. private _attachedMesh;
  40783. private _boundingBoxColor;
  40784. private _defaultUtilityLayer;
  40785. private _defaultKeepDepthUtilityLayer;
  40786. /**
  40787. * When bounding box gizmo is enabled, this can be used to track drag/end events
  40788. */
  40789. boundingBoxDragBehavior: SixDofDragBehavior;
  40790. /**
  40791. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  40792. */
  40793. attachableMeshes: Nullable<Array<AbstractMesh>>;
  40794. /**
  40795. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  40796. */
  40797. usePointerToAttachGizmos: boolean;
  40798. /**
  40799. * Instatiates a gizmo manager
  40800. * @param scene the scene to overlay the gizmos on top of
  40801. */
  40802. constructor(scene: Scene);
  40803. /**
  40804. * Attaches a set of gizmos to the specified mesh
  40805. * @param mesh The mesh the gizmo's should be attached to
  40806. */
  40807. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  40808. /**
  40809. * If the position gizmo is enabled
  40810. */
  40811. positionGizmoEnabled: boolean;
  40812. /**
  40813. * If the rotation gizmo is enabled
  40814. */
  40815. rotationGizmoEnabled: boolean;
  40816. /**
  40817. * If the scale gizmo is enabled
  40818. */
  40819. scaleGizmoEnabled: boolean;
  40820. /**
  40821. * If the boundingBox gizmo is enabled
  40822. */
  40823. boundingBoxGizmoEnabled: boolean;
  40824. /**
  40825. * Disposes of the gizmo manager
  40826. */
  40827. dispose(): void;
  40828. }
  40829. }
  40830. declare module BABYLON {
  40831. /**
  40832. * Gizmo that enables viewing a light
  40833. */
  40834. export class LightGizmo extends Gizmo {
  40835. private _box;
  40836. /**
  40837. * Creates a LightGizmo
  40838. * @param gizmoLayer The utility layer the gizmo will be added to
  40839. */
  40840. constructor(gizmoLayer?: UtilityLayerRenderer);
  40841. private _light;
  40842. /**
  40843. * The light that the gizmo is attached to
  40844. */
  40845. light: Nullable<Light>;
  40846. /**
  40847. * @hidden
  40848. * Updates the gizmo to match the attached mesh's position/rotation
  40849. */
  40850. protected _update(): void;
  40851. }
  40852. }
  40853. declare module BABYLON {
  40854. /** @hidden */
  40855. export var backgroundFragmentDeclaration: {
  40856. name: string;
  40857. shader: string;
  40858. };
  40859. }
  40860. declare module BABYLON {
  40861. /** @hidden */
  40862. export var backgroundUboDeclaration: {
  40863. name: string;
  40864. shader: string;
  40865. };
  40866. }
  40867. declare module BABYLON {
  40868. /** @hidden */
  40869. export var backgroundPixelShader: {
  40870. name: string;
  40871. shader: string;
  40872. };
  40873. }
  40874. declare module BABYLON {
  40875. /** @hidden */
  40876. export var backgroundVertexDeclaration: {
  40877. name: string;
  40878. shader: string;
  40879. };
  40880. }
  40881. declare module BABYLON {
  40882. /** @hidden */
  40883. export var backgroundVertexShader: {
  40884. name: string;
  40885. shader: string;
  40886. };
  40887. }
  40888. declare module BABYLON {
  40889. /**
  40890. * Background material used to create an efficient environement around your scene.
  40891. */
  40892. export class BackgroundMaterial extends PushMaterial {
  40893. /**
  40894. * Standard reflectance value at parallel view angle.
  40895. */
  40896. static StandardReflectance0: number;
  40897. /**
  40898. * Standard reflectance value at grazing angle.
  40899. */
  40900. static StandardReflectance90: number;
  40901. protected _primaryColor: Color3;
  40902. /**
  40903. * Key light Color (multiply against the environement texture)
  40904. */
  40905. primaryColor: Color3;
  40906. protected __perceptualColor: Nullable<Color3>;
  40907. /**
  40908. * Experimental Internal Use Only.
  40909. *
  40910. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  40911. * This acts as a helper to set the primary color to a more "human friendly" value.
  40912. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  40913. * output color as close as possible from the chosen value.
  40914. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  40915. * part of lighting setup.)
  40916. */ perceptualColor: Nullable<Color3>;
  40917. protected _primaryColorShadowLevel: float;
  40918. /**
  40919. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  40920. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  40921. */
  40922. primaryColorShadowLevel: float;
  40923. protected _primaryColorHighlightLevel: float;
  40924. /**
  40925. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  40926. * The primary color is used at the level chosen to define what the white area would look.
  40927. */
  40928. primaryColorHighlightLevel: float;
  40929. protected _reflectionTexture: Nullable<BaseTexture>;
  40930. /**
  40931. * Reflection Texture used in the material.
  40932. * Should be author in a specific way for the best result (refer to the documentation).
  40933. */
  40934. reflectionTexture: Nullable<BaseTexture>;
  40935. protected _reflectionBlur: float;
  40936. /**
  40937. * Reflection Texture level of blur.
  40938. *
  40939. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  40940. * texture twice.
  40941. */
  40942. reflectionBlur: float;
  40943. protected _diffuseTexture: Nullable<BaseTexture>;
  40944. /**
  40945. * Diffuse Texture used in the material.
  40946. * Should be author in a specific way for the best result (refer to the documentation).
  40947. */
  40948. diffuseTexture: Nullable<BaseTexture>;
  40949. protected _shadowLights: Nullable<IShadowLight[]>;
  40950. /**
  40951. * Specify the list of lights casting shadow on the material.
  40952. * All scene shadow lights will be included if null.
  40953. */
  40954. shadowLights: Nullable<IShadowLight[]>;
  40955. protected _shadowLevel: float;
  40956. /**
  40957. * Helps adjusting the shadow to a softer level if required.
  40958. * 0 means black shadows and 1 means no shadows.
  40959. */
  40960. shadowLevel: float;
  40961. protected _sceneCenter: Vector3;
  40962. /**
  40963. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  40964. * It is usually zero but might be interesting to modify according to your setup.
  40965. */
  40966. sceneCenter: Vector3;
  40967. protected _opacityFresnel: boolean;
  40968. /**
  40969. * This helps specifying that the material is falling off to the sky box at grazing angle.
  40970. * This helps ensuring a nice transition when the camera goes under the ground.
  40971. */
  40972. opacityFresnel: boolean;
  40973. protected _reflectionFresnel: boolean;
  40974. /**
  40975. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  40976. * This helps adding a mirror texture on the ground.
  40977. */
  40978. reflectionFresnel: boolean;
  40979. protected _reflectionFalloffDistance: number;
  40980. /**
  40981. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  40982. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  40983. */
  40984. reflectionFalloffDistance: number;
  40985. protected _reflectionAmount: number;
  40986. /**
  40987. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  40988. */
  40989. reflectionAmount: number;
  40990. protected _reflectionReflectance0: number;
  40991. /**
  40992. * This specifies the weight of the reflection at grazing angle.
  40993. */
  40994. reflectionReflectance0: number;
  40995. protected _reflectionReflectance90: number;
  40996. /**
  40997. * This specifies the weight of the reflection at a perpendicular point of view.
  40998. */
  40999. reflectionReflectance90: number;
  41000. /**
  41001. * Sets the reflection reflectance fresnel values according to the default standard
  41002. * empirically know to work well :-)
  41003. */
  41004. reflectionStandardFresnelWeight: number;
  41005. protected _useRGBColor: boolean;
  41006. /**
  41007. * Helps to directly use the maps channels instead of their level.
  41008. */
  41009. useRGBColor: boolean;
  41010. protected _enableNoise: boolean;
  41011. /**
  41012. * This helps reducing the banding effect that could occur on the background.
  41013. */
  41014. enableNoise: boolean;
  41015. /**
  41016. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41017. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  41018. * Recommended to be keep at 1.0 except for special cases.
  41019. */
  41020. fovMultiplier: number;
  41021. private _fovMultiplier;
  41022. /**
  41023. * Enable the FOV adjustment feature controlled by fovMultiplier.
  41024. */
  41025. useEquirectangularFOV: boolean;
  41026. private _maxSimultaneousLights;
  41027. /**
  41028. * Number of Simultaneous lights allowed on the material.
  41029. */
  41030. maxSimultaneousLights: int;
  41031. /**
  41032. * Default configuration related to image processing available in the Background Material.
  41033. */
  41034. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41035. /**
  41036. * Keep track of the image processing observer to allow dispose and replace.
  41037. */
  41038. private _imageProcessingObserver;
  41039. /**
  41040. * Attaches a new image processing configuration to the PBR Material.
  41041. * @param configuration (if null the scene configuration will be use)
  41042. */
  41043. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41044. /**
  41045. * Gets the image processing configuration used either in this material.
  41046. */
  41047. /**
  41048. * Sets the Default image processing configuration used either in the this material.
  41049. *
  41050. * If sets to null, the scene one is in use.
  41051. */
  41052. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  41053. /**
  41054. * Gets wether the color curves effect is enabled.
  41055. */
  41056. /**
  41057. * Sets wether the color curves effect is enabled.
  41058. */
  41059. cameraColorCurvesEnabled: boolean;
  41060. /**
  41061. * Gets wether the color grading effect is enabled.
  41062. */
  41063. /**
  41064. * Gets wether the color grading effect is enabled.
  41065. */
  41066. cameraColorGradingEnabled: boolean;
  41067. /**
  41068. * Gets wether tonemapping is enabled or not.
  41069. */
  41070. /**
  41071. * Sets wether tonemapping is enabled or not
  41072. */
  41073. cameraToneMappingEnabled: boolean;
  41074. /**
  41075. * The camera exposure used on this material.
  41076. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41077. * This corresponds to a photographic exposure.
  41078. */
  41079. /**
  41080. * The camera exposure used on this material.
  41081. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41082. * This corresponds to a photographic exposure.
  41083. */
  41084. cameraExposure: float;
  41085. /**
  41086. * Gets The camera contrast used on this material.
  41087. */
  41088. /**
  41089. * Sets The camera contrast used on this material.
  41090. */
  41091. cameraContrast: float;
  41092. /**
  41093. * Gets the Color Grading 2D Lookup Texture.
  41094. */
  41095. /**
  41096. * Sets the Color Grading 2D Lookup Texture.
  41097. */
  41098. cameraColorGradingTexture: Nullable<BaseTexture>;
  41099. /**
  41100. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41101. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41102. * 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;
  41103. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41104. */
  41105. /**
  41106. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41107. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41108. * 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;
  41109. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41110. */
  41111. cameraColorCurves: Nullable<ColorCurves>;
  41112. /**
  41113. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  41114. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  41115. */
  41116. switchToBGR: boolean;
  41117. private _renderTargets;
  41118. private _reflectionControls;
  41119. private _white;
  41120. private _primaryShadowColor;
  41121. private _primaryHighlightColor;
  41122. /**
  41123. * Instantiates a Background Material in the given scene
  41124. * @param name The friendly name of the material
  41125. * @param scene The scene to add the material to
  41126. */
  41127. constructor(name: string, scene: Scene);
  41128. /**
  41129. * Gets a boolean indicating that current material needs to register RTT
  41130. */
  41131. readonly hasRenderTargetTextures: boolean;
  41132. /**
  41133. * The entire material has been created in order to prevent overdraw.
  41134. * @returns false
  41135. */
  41136. needAlphaTesting(): boolean;
  41137. /**
  41138. * The entire material has been created in order to prevent overdraw.
  41139. * @returns true if blending is enable
  41140. */
  41141. needAlphaBlending(): boolean;
  41142. /**
  41143. * Checks wether the material is ready to be rendered for a given mesh.
  41144. * @param mesh The mesh to render
  41145. * @param subMesh The submesh to check against
  41146. * @param useInstances Specify wether or not the material is used with instances
  41147. * @returns true if all the dependencies are ready (Textures, Effects...)
  41148. */
  41149. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41150. /**
  41151. * Compute the primary color according to the chosen perceptual color.
  41152. */
  41153. private _computePrimaryColorFromPerceptualColor;
  41154. /**
  41155. * Compute the highlights and shadow colors according to their chosen levels.
  41156. */
  41157. private _computePrimaryColors;
  41158. /**
  41159. * Build the uniform buffer used in the material.
  41160. */
  41161. buildUniformLayout(): void;
  41162. /**
  41163. * Unbind the material.
  41164. */
  41165. unbind(): void;
  41166. /**
  41167. * Bind only the world matrix to the material.
  41168. * @param world The world matrix to bind.
  41169. */
  41170. bindOnlyWorldMatrix(world: Matrix): void;
  41171. /**
  41172. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  41173. * @param world The world matrix to bind.
  41174. * @param subMesh The submesh to bind for.
  41175. */
  41176. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41177. /**
  41178. * Dispose the material.
  41179. * @param forceDisposeEffect Force disposal of the associated effect.
  41180. * @param forceDisposeTextures Force disposal of the associated textures.
  41181. */
  41182. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41183. /**
  41184. * Clones the material.
  41185. * @param name The cloned name.
  41186. * @returns The cloned material.
  41187. */
  41188. clone(name: string): BackgroundMaterial;
  41189. /**
  41190. * Serializes the current material to its JSON representation.
  41191. * @returns The JSON representation.
  41192. */
  41193. serialize(): any;
  41194. /**
  41195. * Gets the class name of the material
  41196. * @returns "BackgroundMaterial"
  41197. */
  41198. getClassName(): string;
  41199. /**
  41200. * Parse a JSON input to create back a background material.
  41201. * @param source The JSON data to parse
  41202. * @param scene The scene to create the parsed material in
  41203. * @param rootUrl The root url of the assets the material depends upon
  41204. * @returns the instantiated BackgroundMaterial.
  41205. */
  41206. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  41207. }
  41208. }
  41209. declare module BABYLON {
  41210. /**
  41211. * Represents the different options available during the creation of
  41212. * a Environment helper.
  41213. *
  41214. * This can control the default ground, skybox and image processing setup of your scene.
  41215. */
  41216. export interface IEnvironmentHelperOptions {
  41217. /**
  41218. * Specifies wether or not to create a ground.
  41219. * True by default.
  41220. */
  41221. createGround: boolean;
  41222. /**
  41223. * Specifies the ground size.
  41224. * 15 by default.
  41225. */
  41226. groundSize: number;
  41227. /**
  41228. * The texture used on the ground for the main color.
  41229. * Comes from the BabylonJS CDN by default.
  41230. *
  41231. * Remarks: Can be either a texture or a url.
  41232. */
  41233. groundTexture: string | BaseTexture;
  41234. /**
  41235. * The color mixed in the ground texture by default.
  41236. * BabylonJS clearColor by default.
  41237. */
  41238. groundColor: Color3;
  41239. /**
  41240. * Specifies the ground opacity.
  41241. * 1 by default.
  41242. */
  41243. groundOpacity: number;
  41244. /**
  41245. * Enables the ground to receive shadows.
  41246. * True by default.
  41247. */
  41248. enableGroundShadow: boolean;
  41249. /**
  41250. * Helps preventing the shadow to be fully black on the ground.
  41251. * 0.5 by default.
  41252. */
  41253. groundShadowLevel: number;
  41254. /**
  41255. * Creates a mirror texture attach to the ground.
  41256. * false by default.
  41257. */
  41258. enableGroundMirror: boolean;
  41259. /**
  41260. * Specifies the ground mirror size ratio.
  41261. * 0.3 by default as the default kernel is 64.
  41262. */
  41263. groundMirrorSizeRatio: number;
  41264. /**
  41265. * Specifies the ground mirror blur kernel size.
  41266. * 64 by default.
  41267. */
  41268. groundMirrorBlurKernel: number;
  41269. /**
  41270. * Specifies the ground mirror visibility amount.
  41271. * 1 by default
  41272. */
  41273. groundMirrorAmount: number;
  41274. /**
  41275. * Specifies the ground mirror reflectance weight.
  41276. * This uses the standard weight of the background material to setup the fresnel effect
  41277. * of the mirror.
  41278. * 1 by default.
  41279. */
  41280. groundMirrorFresnelWeight: number;
  41281. /**
  41282. * Specifies the ground mirror Falloff distance.
  41283. * This can helps reducing the size of the reflection.
  41284. * 0 by Default.
  41285. */
  41286. groundMirrorFallOffDistance: number;
  41287. /**
  41288. * Specifies the ground mirror texture type.
  41289. * Unsigned Int by Default.
  41290. */
  41291. groundMirrorTextureType: number;
  41292. /**
  41293. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  41294. * the shown objects.
  41295. */
  41296. groundYBias: number;
  41297. /**
  41298. * Specifies wether or not to create a skybox.
  41299. * True by default.
  41300. */
  41301. createSkybox: boolean;
  41302. /**
  41303. * Specifies the skybox size.
  41304. * 20 by default.
  41305. */
  41306. skyboxSize: number;
  41307. /**
  41308. * The texture used on the skybox for the main color.
  41309. * Comes from the BabylonJS CDN by default.
  41310. *
  41311. * Remarks: Can be either a texture or a url.
  41312. */
  41313. skyboxTexture: string | BaseTexture;
  41314. /**
  41315. * The color mixed in the skybox texture by default.
  41316. * BabylonJS clearColor by default.
  41317. */
  41318. skyboxColor: Color3;
  41319. /**
  41320. * The background rotation around the Y axis of the scene.
  41321. * This helps aligning the key lights of your scene with the background.
  41322. * 0 by default.
  41323. */
  41324. backgroundYRotation: number;
  41325. /**
  41326. * Compute automatically the size of the elements to best fit with the scene.
  41327. */
  41328. sizeAuto: boolean;
  41329. /**
  41330. * Default position of the rootMesh if autoSize is not true.
  41331. */
  41332. rootPosition: Vector3;
  41333. /**
  41334. * Sets up the image processing in the scene.
  41335. * true by default.
  41336. */
  41337. setupImageProcessing: boolean;
  41338. /**
  41339. * The texture used as your environment texture in the scene.
  41340. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  41341. *
  41342. * Remarks: Can be either a texture or a url.
  41343. */
  41344. environmentTexture: string | BaseTexture;
  41345. /**
  41346. * The value of the exposure to apply to the scene.
  41347. * 0.6 by default if setupImageProcessing is true.
  41348. */
  41349. cameraExposure: number;
  41350. /**
  41351. * The value of the contrast to apply to the scene.
  41352. * 1.6 by default if setupImageProcessing is true.
  41353. */
  41354. cameraContrast: number;
  41355. /**
  41356. * Specifies wether or not tonemapping should be enabled in the scene.
  41357. * true by default if setupImageProcessing is true.
  41358. */
  41359. toneMappingEnabled: boolean;
  41360. }
  41361. /**
  41362. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  41363. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  41364. * It also helps with the default setup of your imageProcessing configuration.
  41365. */
  41366. export class EnvironmentHelper {
  41367. /**
  41368. * Default ground texture URL.
  41369. */
  41370. private static _groundTextureCDNUrl;
  41371. /**
  41372. * Default skybox texture URL.
  41373. */
  41374. private static _skyboxTextureCDNUrl;
  41375. /**
  41376. * Default environment texture URL.
  41377. */
  41378. private static _environmentTextureCDNUrl;
  41379. /**
  41380. * Creates the default options for the helper.
  41381. */
  41382. private static _getDefaultOptions;
  41383. private _rootMesh;
  41384. /**
  41385. * Gets the root mesh created by the helper.
  41386. */
  41387. readonly rootMesh: Mesh;
  41388. private _skybox;
  41389. /**
  41390. * Gets the skybox created by the helper.
  41391. */
  41392. readonly skybox: Nullable<Mesh>;
  41393. private _skyboxTexture;
  41394. /**
  41395. * Gets the skybox texture created by the helper.
  41396. */
  41397. readonly skyboxTexture: Nullable<BaseTexture>;
  41398. private _skyboxMaterial;
  41399. /**
  41400. * Gets the skybox material created by the helper.
  41401. */
  41402. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  41403. private _ground;
  41404. /**
  41405. * Gets the ground mesh created by the helper.
  41406. */
  41407. readonly ground: Nullable<Mesh>;
  41408. private _groundTexture;
  41409. /**
  41410. * Gets the ground texture created by the helper.
  41411. */
  41412. readonly groundTexture: Nullable<BaseTexture>;
  41413. private _groundMirror;
  41414. /**
  41415. * Gets the ground mirror created by the helper.
  41416. */
  41417. readonly groundMirror: Nullable<MirrorTexture>;
  41418. /**
  41419. * Gets the ground mirror render list to helps pushing the meshes
  41420. * you wish in the ground reflection.
  41421. */
  41422. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  41423. private _groundMaterial;
  41424. /**
  41425. * Gets the ground material created by the helper.
  41426. */
  41427. readonly groundMaterial: Nullable<BackgroundMaterial>;
  41428. /**
  41429. * Stores the creation options.
  41430. */
  41431. private readonly _scene;
  41432. private _options;
  41433. /**
  41434. * This observable will be notified with any error during the creation of the environment,
  41435. * mainly texture creation errors.
  41436. */
  41437. onErrorObservable: Observable<{
  41438. message?: string;
  41439. exception?: any;
  41440. }>;
  41441. /**
  41442. * constructor
  41443. * @param options Defines the options we want to customize the helper
  41444. * @param scene The scene to add the material to
  41445. */
  41446. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  41447. /**
  41448. * Updates the background according to the new options
  41449. * @param options
  41450. */
  41451. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  41452. /**
  41453. * Sets the primary color of all the available elements.
  41454. * @param color the main color to affect to the ground and the background
  41455. */
  41456. setMainColor(color: Color3): void;
  41457. /**
  41458. * Setup the image processing according to the specified options.
  41459. */
  41460. private _setupImageProcessing;
  41461. /**
  41462. * Setup the environment texture according to the specified options.
  41463. */
  41464. private _setupEnvironmentTexture;
  41465. /**
  41466. * Setup the background according to the specified options.
  41467. */
  41468. private _setupBackground;
  41469. /**
  41470. * Get the scene sizes according to the setup.
  41471. */
  41472. private _getSceneSize;
  41473. /**
  41474. * Setup the ground according to the specified options.
  41475. */
  41476. private _setupGround;
  41477. /**
  41478. * Setup the ground material according to the specified options.
  41479. */
  41480. private _setupGroundMaterial;
  41481. /**
  41482. * Setup the ground diffuse texture according to the specified options.
  41483. */
  41484. private _setupGroundDiffuseTexture;
  41485. /**
  41486. * Setup the ground mirror texture according to the specified options.
  41487. */
  41488. private _setupGroundMirrorTexture;
  41489. /**
  41490. * Setup the ground to receive the mirror texture.
  41491. */
  41492. private _setupMirrorInGroundMaterial;
  41493. /**
  41494. * Setup the skybox according to the specified options.
  41495. */
  41496. private _setupSkybox;
  41497. /**
  41498. * Setup the skybox material according to the specified options.
  41499. */
  41500. private _setupSkyboxMaterial;
  41501. /**
  41502. * Setup the skybox reflection texture according to the specified options.
  41503. */
  41504. private _setupSkyboxReflectionTexture;
  41505. private _errorHandler;
  41506. /**
  41507. * Dispose all the elements created by the Helper.
  41508. */
  41509. dispose(): void;
  41510. }
  41511. }
  41512. declare module BABYLON {
  41513. /**
  41514. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  41515. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  41516. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  41517. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  41518. */
  41519. export class PhotoDome extends TransformNode {
  41520. private _useDirectMapping;
  41521. /**
  41522. * The texture being displayed on the sphere
  41523. */
  41524. protected _photoTexture: Texture;
  41525. /**
  41526. * Gets or sets the texture being displayed on the sphere
  41527. */
  41528. photoTexture: Texture;
  41529. /**
  41530. * Observable raised when an error occured while loading the 360 image
  41531. */
  41532. onLoadErrorObservable: Observable<string>;
  41533. /**
  41534. * The skybox material
  41535. */
  41536. protected _material: BackgroundMaterial;
  41537. /**
  41538. * The surface used for the skybox
  41539. */
  41540. protected _mesh: Mesh;
  41541. /**
  41542. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41543. * Also see the options.resolution property.
  41544. */
  41545. fovMultiplier: number;
  41546. /**
  41547. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  41548. * @param name Element's name, child elements will append suffixes for their own names.
  41549. * @param urlsOfPhoto defines the url of the photo to display
  41550. * @param options defines an object containing optional or exposed sub element properties
  41551. * @param onError defines a callback called when an error occured while loading the texture
  41552. */
  41553. constructor(name: string, urlOfPhoto: string, options: {
  41554. resolution?: number;
  41555. size?: number;
  41556. useDirectMapping?: boolean;
  41557. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  41558. /**
  41559. * Releases resources associated with this node.
  41560. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  41561. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  41562. */
  41563. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  41564. }
  41565. }
  41566. declare module BABYLON {
  41567. /**
  41568. * Class used to host texture specific utilities
  41569. */
  41570. export class TextureTools {
  41571. /**
  41572. * Uses the GPU to create a copy texture rescaled at a given size
  41573. * @param texture Texture to copy from
  41574. * @param width defines the desired width
  41575. * @param height defines the desired height
  41576. * @param useBilinearMode defines if bilinear mode has to be used
  41577. * @return the generated texture
  41578. */
  41579. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  41580. /**
  41581. * Gets an environment BRDF texture for a given scene
  41582. * @param scene defines the hosting scene
  41583. * @returns the environment BRDF texture
  41584. */
  41585. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  41586. private static _environmentBRDFBase64Texture;
  41587. }
  41588. }
  41589. declare module BABYLON {
  41590. /** @hidden */
  41591. export var pbrFragmentDeclaration: {
  41592. name: string;
  41593. shader: string;
  41594. };
  41595. }
  41596. declare module BABYLON {
  41597. /** @hidden */
  41598. export var pbrUboDeclaration: {
  41599. name: string;
  41600. shader: string;
  41601. };
  41602. }
  41603. declare module BABYLON {
  41604. /** @hidden */
  41605. export var pbrFunctions: {
  41606. name: string;
  41607. shader: string;
  41608. };
  41609. }
  41610. declare module BABYLON {
  41611. /** @hidden */
  41612. export var harmonicsFunctions: {
  41613. name: string;
  41614. shader: string;
  41615. };
  41616. }
  41617. declare module BABYLON {
  41618. /** @hidden */
  41619. export var pbrLightFunctions: {
  41620. name: string;
  41621. shader: string;
  41622. };
  41623. }
  41624. declare module BABYLON {
  41625. /** @hidden */
  41626. export var pbrPixelShader: {
  41627. name: string;
  41628. shader: string;
  41629. };
  41630. }
  41631. declare module BABYLON {
  41632. /** @hidden */
  41633. export var pbrVertexDeclaration: {
  41634. name: string;
  41635. shader: string;
  41636. };
  41637. }
  41638. declare module BABYLON {
  41639. /** @hidden */
  41640. export var pbrVertexShader: {
  41641. name: string;
  41642. shader: string;
  41643. };
  41644. }
  41645. declare module BABYLON {
  41646. /**
  41647. * The Physically based material base class of BJS.
  41648. *
  41649. * This offers the main features of a standard PBR material.
  41650. * For more information, please refer to the documentation :
  41651. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  41652. */
  41653. export abstract class PBRBaseMaterial extends PushMaterial {
  41654. /**
  41655. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  41656. */
  41657. static readonly PBRMATERIAL_OPAQUE: number;
  41658. /**
  41659. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  41660. */
  41661. static readonly PBRMATERIAL_ALPHATEST: number;
  41662. /**
  41663. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  41664. */
  41665. static readonly PBRMATERIAL_ALPHABLEND: number;
  41666. /**
  41667. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  41668. * They are also discarded below the alpha cutoff threshold to improve performances.
  41669. */
  41670. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  41671. /**
  41672. * Defines the default value of how much AO map is occluding the analytical lights
  41673. * (point spot...).
  41674. */
  41675. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  41676. /**
  41677. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  41678. */
  41679. static readonly LIGHTFALLOFF_PHYSICAL: number;
  41680. /**
  41681. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  41682. * to enhance interoperability with other engines.
  41683. */
  41684. static readonly LIGHTFALLOFF_GLTF: number;
  41685. /**
  41686. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  41687. * to enhance interoperability with other materials.
  41688. */
  41689. static readonly LIGHTFALLOFF_STANDARD: number;
  41690. /**
  41691. * Intensity of the direct lights e.g. the four lights available in your scene.
  41692. * This impacts both the direct diffuse and specular highlights.
  41693. */
  41694. protected _directIntensity: number;
  41695. /**
  41696. * Intensity of the emissive part of the material.
  41697. * This helps controlling the emissive effect without modifying the emissive color.
  41698. */
  41699. protected _emissiveIntensity: number;
  41700. /**
  41701. * Intensity of the environment e.g. how much the environment will light the object
  41702. * either through harmonics for rough material or through the refelction for shiny ones.
  41703. */
  41704. protected _environmentIntensity: number;
  41705. /**
  41706. * This is a special control allowing the reduction of the specular highlights coming from the
  41707. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  41708. */
  41709. protected _specularIntensity: number;
  41710. /**
  41711. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  41712. */
  41713. private _lightingInfos;
  41714. /**
  41715. * Debug Control allowing disabling the bump map on this material.
  41716. */
  41717. protected _disableBumpMap: boolean;
  41718. /**
  41719. * AKA Diffuse Texture in standard nomenclature.
  41720. */
  41721. protected _albedoTexture: BaseTexture;
  41722. /**
  41723. * AKA Occlusion Texture in other nomenclature.
  41724. */
  41725. protected _ambientTexture: BaseTexture;
  41726. /**
  41727. * AKA Occlusion Texture Intensity in other nomenclature.
  41728. */
  41729. protected _ambientTextureStrength: number;
  41730. /**
  41731. * Defines how much the AO map is occluding the analytical lights (point spot...).
  41732. * 1 means it completely occludes it
  41733. * 0 mean it has no impact
  41734. */
  41735. protected _ambientTextureImpactOnAnalyticalLights: number;
  41736. /**
  41737. * Stores the alpha values in a texture.
  41738. */
  41739. protected _opacityTexture: BaseTexture;
  41740. /**
  41741. * Stores the reflection values in a texture.
  41742. */
  41743. protected _reflectionTexture: BaseTexture;
  41744. /**
  41745. * Stores the refraction values in a texture.
  41746. */
  41747. protected _refractionTexture: BaseTexture;
  41748. /**
  41749. * Stores the emissive values in a texture.
  41750. */
  41751. protected _emissiveTexture: BaseTexture;
  41752. /**
  41753. * AKA Specular texture in other nomenclature.
  41754. */
  41755. protected _reflectivityTexture: BaseTexture;
  41756. /**
  41757. * Used to switch from specular/glossiness to metallic/roughness workflow.
  41758. */
  41759. protected _metallicTexture: BaseTexture;
  41760. /**
  41761. * Specifies the metallic scalar of the metallic/roughness workflow.
  41762. * Can also be used to scale the metalness values of the metallic texture.
  41763. */
  41764. protected _metallic: Nullable<number>;
  41765. /**
  41766. * Specifies the roughness scalar of the metallic/roughness workflow.
  41767. * Can also be used to scale the roughness values of the metallic texture.
  41768. */
  41769. protected _roughness: Nullable<number>;
  41770. /**
  41771. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  41772. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  41773. */
  41774. protected _microSurfaceTexture: BaseTexture;
  41775. /**
  41776. * Stores surface normal data used to displace a mesh in a texture.
  41777. */
  41778. protected _bumpTexture: BaseTexture;
  41779. /**
  41780. * Stores the pre-calculated light information of a mesh in a texture.
  41781. */
  41782. protected _lightmapTexture: BaseTexture;
  41783. /**
  41784. * The color of a material in ambient lighting.
  41785. */
  41786. protected _ambientColor: Color3;
  41787. /**
  41788. * AKA Diffuse Color in other nomenclature.
  41789. */
  41790. protected _albedoColor: Color3;
  41791. /**
  41792. * AKA Specular Color in other nomenclature.
  41793. */
  41794. protected _reflectivityColor: Color3;
  41795. /**
  41796. * The color applied when light is reflected from a material.
  41797. */
  41798. protected _reflectionColor: Color3;
  41799. /**
  41800. * The color applied when light is emitted from a material.
  41801. */
  41802. protected _emissiveColor: Color3;
  41803. /**
  41804. * AKA Glossiness in other nomenclature.
  41805. */
  41806. protected _microSurface: number;
  41807. /**
  41808. * source material index of refraction (IOR)' / 'destination material IOR.
  41809. */
  41810. protected _indexOfRefraction: number;
  41811. /**
  41812. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  41813. */
  41814. protected _invertRefractionY: boolean;
  41815. /**
  41816. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  41817. * Materials half opaque for instance using refraction could benefit from this control.
  41818. */
  41819. protected _linkRefractionWithTransparency: boolean;
  41820. /**
  41821. * Specifies that the material will use the light map as a show map.
  41822. */
  41823. protected _useLightmapAsShadowmap: boolean;
  41824. /**
  41825. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  41826. * makes the reflect vector face the model (under horizon).
  41827. */
  41828. protected _useHorizonOcclusion: boolean;
  41829. /**
  41830. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  41831. * too much the area relying on ambient texture to define their ambient occlusion.
  41832. */
  41833. protected _useRadianceOcclusion: boolean;
  41834. /**
  41835. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  41836. */
  41837. protected _useAlphaFromAlbedoTexture: boolean;
  41838. /**
  41839. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  41840. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41841. */
  41842. protected _useSpecularOverAlpha: boolean;
  41843. /**
  41844. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  41845. */
  41846. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  41847. /**
  41848. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  41849. */
  41850. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  41851. /**
  41852. * Specifies if the metallic texture contains the roughness information in its green channel.
  41853. */
  41854. protected _useRoughnessFromMetallicTextureGreen: boolean;
  41855. /**
  41856. * Specifies if the metallic texture contains the metallness information in its blue channel.
  41857. */
  41858. protected _useMetallnessFromMetallicTextureBlue: boolean;
  41859. /**
  41860. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  41861. */
  41862. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  41863. /**
  41864. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  41865. */
  41866. protected _useAmbientInGrayScale: boolean;
  41867. /**
  41868. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  41869. * The material will try to infer what glossiness each pixel should be.
  41870. */
  41871. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  41872. /**
  41873. * Defines the falloff type used in this material.
  41874. * It by default is Physical.
  41875. */
  41876. protected _lightFalloff: number;
  41877. /**
  41878. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41879. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41880. */
  41881. protected _useRadianceOverAlpha: boolean;
  41882. /**
  41883. * Allows using an object space normal map (instead of tangent space).
  41884. */
  41885. protected _useObjectSpaceNormalMap: boolean;
  41886. /**
  41887. * Allows using the bump map in parallax mode.
  41888. */
  41889. protected _useParallax: boolean;
  41890. /**
  41891. * Allows using the bump map in parallax occlusion mode.
  41892. */
  41893. protected _useParallaxOcclusion: boolean;
  41894. /**
  41895. * Controls the scale bias of the parallax mode.
  41896. */
  41897. protected _parallaxScaleBias: number;
  41898. /**
  41899. * If sets to true, disables all the lights affecting the material.
  41900. */
  41901. protected _disableLighting: boolean;
  41902. /**
  41903. * Number of Simultaneous lights allowed on the material.
  41904. */
  41905. protected _maxSimultaneousLights: number;
  41906. /**
  41907. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  41908. */
  41909. protected _invertNormalMapX: boolean;
  41910. /**
  41911. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  41912. */
  41913. protected _invertNormalMapY: boolean;
  41914. /**
  41915. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41916. */
  41917. protected _twoSidedLighting: boolean;
  41918. /**
  41919. * Defines the alpha limits in alpha test mode.
  41920. */
  41921. protected _alphaCutOff: number;
  41922. /**
  41923. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  41924. */
  41925. protected _forceAlphaTest: boolean;
  41926. /**
  41927. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  41928. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  41929. */
  41930. protected _useAlphaFresnel: boolean;
  41931. /**
  41932. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  41933. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  41934. */
  41935. protected _useLinearAlphaFresnel: boolean;
  41936. /**
  41937. * The transparency mode of the material.
  41938. */
  41939. protected _transparencyMode: Nullable<number>;
  41940. /**
  41941. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  41942. * from cos thetav and roughness:
  41943. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  41944. */
  41945. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  41946. /**
  41947. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  41948. */
  41949. protected _forceIrradianceInFragment: boolean;
  41950. /**
  41951. * Force normal to face away from face.
  41952. */
  41953. protected _forceNormalForward: boolean;
  41954. /**
  41955. * Enables specular anti aliasing in the PBR shader.
  41956. * It will both interacts on the Geometry for analytical and IBL lighting.
  41957. * It also prefilter the roughness map based on the bump values.
  41958. */
  41959. protected _enableSpecularAntiAliasing: boolean;
  41960. /**
  41961. * Default configuration related to image processing available in the PBR Material.
  41962. */
  41963. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41964. /**
  41965. * Keep track of the image processing observer to allow dispose and replace.
  41966. */
  41967. private _imageProcessingObserver;
  41968. /**
  41969. * Attaches a new image processing configuration to the PBR Material.
  41970. * @param configuration
  41971. */
  41972. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41973. /**
  41974. * Stores the available render targets.
  41975. */
  41976. private _renderTargets;
  41977. /**
  41978. * Sets the global ambient color for the material used in lighting calculations.
  41979. */
  41980. private _globalAmbientColor;
  41981. /**
  41982. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  41983. */
  41984. private _useLogarithmicDepth;
  41985. /**
  41986. * If set to true, no lighting calculations will be applied.
  41987. */
  41988. private _unlit;
  41989. /**
  41990. * Instantiates a new PBRMaterial instance.
  41991. *
  41992. * @param name The material name
  41993. * @param scene The scene the material will be use in.
  41994. */
  41995. constructor(name: string, scene: Scene);
  41996. /**
  41997. * Gets a boolean indicating that current material needs to register RTT
  41998. */
  41999. readonly hasRenderTargetTextures: boolean;
  42000. /**
  42001. * Gets the name of the material class.
  42002. */
  42003. getClassName(): string;
  42004. /**
  42005. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  42006. */
  42007. /**
  42008. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  42009. */
  42010. useLogarithmicDepth: boolean;
  42011. /**
  42012. * Gets the current transparency mode.
  42013. */
  42014. /**
  42015. * Sets the transparency mode of the material.
  42016. *
  42017. * | Value | Type | Description |
  42018. * | ----- | ----------------------------------- | ----------- |
  42019. * | 0 | OPAQUE | |
  42020. * | 1 | ALPHATEST | |
  42021. * | 2 | ALPHABLEND | |
  42022. * | 3 | ALPHATESTANDBLEND | |
  42023. *
  42024. */
  42025. transparencyMode: Nullable<number>;
  42026. /**
  42027. * Returns true if alpha blending should be disabled.
  42028. */
  42029. private readonly _disableAlphaBlending;
  42030. /**
  42031. * Specifies whether or not this material should be rendered in alpha blend mode.
  42032. */
  42033. needAlphaBlending(): boolean;
  42034. /**
  42035. * Specifies if the mesh will require alpha blending.
  42036. * @param mesh - BJS mesh.
  42037. */
  42038. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  42039. /**
  42040. * Specifies whether or not this material should be rendered in alpha test mode.
  42041. */
  42042. needAlphaTesting(): boolean;
  42043. /**
  42044. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  42045. */
  42046. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  42047. /**
  42048. * Gets the texture used for the alpha test.
  42049. */
  42050. getAlphaTestTexture(): BaseTexture;
  42051. /**
  42052. * Specifies that the submesh is ready to be used.
  42053. * @param mesh - BJS mesh.
  42054. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  42055. * @param useInstances - Specifies that instances should be used.
  42056. * @returns - boolean indicating that the submesh is ready or not.
  42057. */
  42058. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42059. /**
  42060. * Specifies if the material uses metallic roughness workflow.
  42061. * @returns boolean specifiying if the material uses metallic roughness workflow.
  42062. */
  42063. isMetallicWorkflow(): boolean;
  42064. private _prepareEffect;
  42065. private _prepareDefines;
  42066. /**
  42067. * Force shader compilation
  42068. */
  42069. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  42070. clipPlane: boolean;
  42071. }>): void;
  42072. /**
  42073. * Initializes the uniform buffer layout for the shader.
  42074. */
  42075. buildUniformLayout(): void;
  42076. /**
  42077. * Unbinds the textures.
  42078. */
  42079. unbind(): void;
  42080. /**
  42081. * Binds the submesh data.
  42082. * @param world - The world matrix.
  42083. * @param mesh - The BJS mesh.
  42084. * @param subMesh - A submesh of the BJS mesh.
  42085. */
  42086. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42087. /**
  42088. * Returns the animatable textures.
  42089. * @returns - Array of animatable textures.
  42090. */
  42091. getAnimatables(): IAnimatable[];
  42092. /**
  42093. * Returns the texture used for reflections.
  42094. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  42095. */
  42096. private _getReflectionTexture;
  42097. /**
  42098. * Returns the texture used for refraction or null if none is used.
  42099. * @returns - Refection texture if present. If no refraction texture and refraction
  42100. * is linked with transparency, returns environment texture. Otherwise, returns null.
  42101. */
  42102. private _getRefractionTexture;
  42103. /**
  42104. * Disposes the resources of the material.
  42105. * @param forceDisposeEffect - Forces the disposal of effects.
  42106. * @param forceDisposeTextures - Forces the disposal of all textures.
  42107. */
  42108. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42109. }
  42110. }
  42111. declare module BABYLON {
  42112. /**
  42113. * The Physically based material of BJS.
  42114. *
  42115. * This offers the main features of a standard PBR material.
  42116. * For more information, please refer to the documentation :
  42117. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  42118. */
  42119. export class PBRMaterial extends PBRBaseMaterial {
  42120. /**
  42121. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  42122. */
  42123. static readonly PBRMATERIAL_OPAQUE: number;
  42124. /**
  42125. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  42126. */
  42127. static readonly PBRMATERIAL_ALPHATEST: number;
  42128. /**
  42129. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42130. */
  42131. static readonly PBRMATERIAL_ALPHABLEND: number;
  42132. /**
  42133. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42134. * They are also discarded below the alpha cutoff threshold to improve performances.
  42135. */
  42136. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  42137. /**
  42138. * Defines the default value of how much AO map is occluding the analytical lights
  42139. * (point spot...).
  42140. */
  42141. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  42142. /**
  42143. * Intensity of the direct lights e.g. the four lights available in your scene.
  42144. * This impacts both the direct diffuse and specular highlights.
  42145. */
  42146. directIntensity: number;
  42147. /**
  42148. * Intensity of the emissive part of the material.
  42149. * This helps controlling the emissive effect without modifying the emissive color.
  42150. */
  42151. emissiveIntensity: number;
  42152. /**
  42153. * Intensity of the environment e.g. how much the environment will light the object
  42154. * either through harmonics for rough material or through the refelction for shiny ones.
  42155. */
  42156. environmentIntensity: number;
  42157. /**
  42158. * This is a special control allowing the reduction of the specular highlights coming from the
  42159. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  42160. */
  42161. specularIntensity: number;
  42162. /**
  42163. * Debug Control allowing disabling the bump map on this material.
  42164. */
  42165. disableBumpMap: boolean;
  42166. /**
  42167. * AKA Diffuse Texture in standard nomenclature.
  42168. */
  42169. albedoTexture: BaseTexture;
  42170. /**
  42171. * AKA Occlusion Texture in other nomenclature.
  42172. */
  42173. ambientTexture: BaseTexture;
  42174. /**
  42175. * AKA Occlusion Texture Intensity in other nomenclature.
  42176. */
  42177. ambientTextureStrength: number;
  42178. /**
  42179. * Defines how much the AO map is occluding the analytical lights (point spot...).
  42180. * 1 means it completely occludes it
  42181. * 0 mean it has no impact
  42182. */
  42183. ambientTextureImpactOnAnalyticalLights: number;
  42184. /**
  42185. * Stores the alpha values in a texture.
  42186. */
  42187. opacityTexture: BaseTexture;
  42188. /**
  42189. * Stores the reflection values in a texture.
  42190. */
  42191. reflectionTexture: Nullable<BaseTexture>;
  42192. /**
  42193. * Stores the emissive values in a texture.
  42194. */
  42195. emissiveTexture: BaseTexture;
  42196. /**
  42197. * AKA Specular texture in other nomenclature.
  42198. */
  42199. reflectivityTexture: BaseTexture;
  42200. /**
  42201. * Used to switch from specular/glossiness to metallic/roughness workflow.
  42202. */
  42203. metallicTexture: BaseTexture;
  42204. /**
  42205. * Specifies the metallic scalar of the metallic/roughness workflow.
  42206. * Can also be used to scale the metalness values of the metallic texture.
  42207. */
  42208. metallic: Nullable<number>;
  42209. /**
  42210. * Specifies the roughness scalar of the metallic/roughness workflow.
  42211. * Can also be used to scale the roughness values of the metallic texture.
  42212. */
  42213. roughness: Nullable<number>;
  42214. /**
  42215. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  42216. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  42217. */
  42218. microSurfaceTexture: BaseTexture;
  42219. /**
  42220. * Stores surface normal data used to displace a mesh in a texture.
  42221. */
  42222. bumpTexture: BaseTexture;
  42223. /**
  42224. * Stores the pre-calculated light information of a mesh in a texture.
  42225. */
  42226. lightmapTexture: BaseTexture;
  42227. /**
  42228. * Stores the refracted light information in a texture.
  42229. */
  42230. refractionTexture: BaseTexture;
  42231. /**
  42232. * The color of a material in ambient lighting.
  42233. */
  42234. ambientColor: Color3;
  42235. /**
  42236. * AKA Diffuse Color in other nomenclature.
  42237. */
  42238. albedoColor: Color3;
  42239. /**
  42240. * AKA Specular Color in other nomenclature.
  42241. */
  42242. reflectivityColor: Color3;
  42243. /**
  42244. * The color reflected from the material.
  42245. */
  42246. reflectionColor: Color3;
  42247. /**
  42248. * The color emitted from the material.
  42249. */
  42250. emissiveColor: Color3;
  42251. /**
  42252. * AKA Glossiness in other nomenclature.
  42253. */
  42254. microSurface: number;
  42255. /**
  42256. * source material index of refraction (IOR)' / 'destination material IOR.
  42257. */
  42258. indexOfRefraction: number;
  42259. /**
  42260. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  42261. */
  42262. invertRefractionY: boolean;
  42263. /**
  42264. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  42265. * Materials half opaque for instance using refraction could benefit from this control.
  42266. */
  42267. linkRefractionWithTransparency: boolean;
  42268. /**
  42269. * If true, the light map contains occlusion information instead of lighting info.
  42270. */
  42271. useLightmapAsShadowmap: boolean;
  42272. /**
  42273. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  42274. */
  42275. useAlphaFromAlbedoTexture: boolean;
  42276. /**
  42277. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  42278. */
  42279. forceAlphaTest: boolean;
  42280. /**
  42281. * Defines the alpha limits in alpha test mode.
  42282. */
  42283. alphaCutOff: number;
  42284. /**
  42285. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42286. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42287. */
  42288. useSpecularOverAlpha: boolean;
  42289. /**
  42290. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  42291. */
  42292. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  42293. /**
  42294. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  42295. */
  42296. useRoughnessFromMetallicTextureAlpha: boolean;
  42297. /**
  42298. * Specifies if the metallic texture contains the roughness information in its green channel.
  42299. */
  42300. useRoughnessFromMetallicTextureGreen: boolean;
  42301. /**
  42302. * Specifies if the metallic texture contains the metallness information in its blue channel.
  42303. */
  42304. useMetallnessFromMetallicTextureBlue: boolean;
  42305. /**
  42306. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  42307. */
  42308. useAmbientOcclusionFromMetallicTextureRed: boolean;
  42309. /**
  42310. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  42311. */
  42312. useAmbientInGrayScale: boolean;
  42313. /**
  42314. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  42315. * The material will try to infer what glossiness each pixel should be.
  42316. */
  42317. useAutoMicroSurfaceFromReflectivityMap: boolean;
  42318. /**
  42319. * BJS is using an harcoded light falloff based on a manually sets up range.
  42320. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  42321. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  42322. */
  42323. /**
  42324. * BJS is using an harcoded light falloff based on a manually sets up range.
  42325. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  42326. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  42327. */
  42328. usePhysicalLightFalloff: boolean;
  42329. /**
  42330. * In order to support the falloff compatibility with gltf, a special mode has been added
  42331. * to reproduce the gltf light falloff.
  42332. */
  42333. /**
  42334. * In order to support the falloff compatibility with gltf, a special mode has been added
  42335. * to reproduce the gltf light falloff.
  42336. */
  42337. useGLTFLightFalloff: boolean;
  42338. /**
  42339. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42340. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42341. */
  42342. useRadianceOverAlpha: boolean;
  42343. /**
  42344. * Allows using an object space normal map (instead of tangent space).
  42345. */
  42346. useObjectSpaceNormalMap: boolean;
  42347. /**
  42348. * Allows using the bump map in parallax mode.
  42349. */
  42350. useParallax: boolean;
  42351. /**
  42352. * Allows using the bump map in parallax occlusion mode.
  42353. */
  42354. useParallaxOcclusion: boolean;
  42355. /**
  42356. * Controls the scale bias of the parallax mode.
  42357. */
  42358. parallaxScaleBias: number;
  42359. /**
  42360. * If sets to true, disables all the lights affecting the material.
  42361. */
  42362. disableLighting: boolean;
  42363. /**
  42364. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  42365. */
  42366. forceIrradianceInFragment: boolean;
  42367. /**
  42368. * Number of Simultaneous lights allowed on the material.
  42369. */
  42370. maxSimultaneousLights: number;
  42371. /**
  42372. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42373. */
  42374. invertNormalMapX: boolean;
  42375. /**
  42376. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42377. */
  42378. invertNormalMapY: boolean;
  42379. /**
  42380. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42381. */
  42382. twoSidedLighting: boolean;
  42383. /**
  42384. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42385. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  42386. */
  42387. useAlphaFresnel: boolean;
  42388. /**
  42389. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42390. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  42391. */
  42392. useLinearAlphaFresnel: boolean;
  42393. /**
  42394. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42395. * And/Or occlude the blended part.
  42396. */
  42397. environmentBRDFTexture: Nullable<BaseTexture>;
  42398. /**
  42399. * Force normal to face away from face.
  42400. */
  42401. forceNormalForward: boolean;
  42402. /**
  42403. * Enables specular anti aliasing in the PBR shader.
  42404. * It will both interacts on the Geometry for analytical and IBL lighting.
  42405. * It also prefilter the roughness map based on the bump values.
  42406. */
  42407. enableSpecularAntiAliasing: boolean;
  42408. /**
  42409. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  42410. * makes the reflect vector face the model (under horizon).
  42411. */
  42412. useHorizonOcclusion: boolean;
  42413. /**
  42414. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  42415. * too much the area relying on ambient texture to define their ambient occlusion.
  42416. */
  42417. useRadianceOcclusion: boolean;
  42418. /**
  42419. * If set to true, no lighting calculations will be applied.
  42420. */
  42421. unlit: boolean;
  42422. /**
  42423. * Gets the image processing configuration used either in this material.
  42424. */
  42425. /**
  42426. * Sets the Default image processing configuration used either in the this material.
  42427. *
  42428. * If sets to null, the scene one is in use.
  42429. */
  42430. imageProcessingConfiguration: ImageProcessingConfiguration;
  42431. /**
  42432. * Gets wether the color curves effect is enabled.
  42433. */
  42434. /**
  42435. * Sets wether the color curves effect is enabled.
  42436. */
  42437. cameraColorCurvesEnabled: boolean;
  42438. /**
  42439. * Gets wether the color grading effect is enabled.
  42440. */
  42441. /**
  42442. * Gets wether the color grading effect is enabled.
  42443. */
  42444. cameraColorGradingEnabled: boolean;
  42445. /**
  42446. * Gets wether tonemapping is enabled or not.
  42447. */
  42448. /**
  42449. * Sets wether tonemapping is enabled or not
  42450. */
  42451. cameraToneMappingEnabled: boolean;
  42452. /**
  42453. * The camera exposure used on this material.
  42454. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42455. * This corresponds to a photographic exposure.
  42456. */
  42457. /**
  42458. * The camera exposure used on this material.
  42459. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42460. * This corresponds to a photographic exposure.
  42461. */
  42462. cameraExposure: number;
  42463. /**
  42464. * Gets The camera contrast used on this material.
  42465. */
  42466. /**
  42467. * Sets The camera contrast used on this material.
  42468. */
  42469. cameraContrast: number;
  42470. /**
  42471. * Gets the Color Grading 2D Lookup Texture.
  42472. */
  42473. /**
  42474. * Sets the Color Grading 2D Lookup Texture.
  42475. */
  42476. cameraColorGradingTexture: Nullable<BaseTexture>;
  42477. /**
  42478. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42479. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42480. * 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;
  42481. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42482. */
  42483. /**
  42484. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42485. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42486. * 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;
  42487. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42488. */
  42489. cameraColorCurves: Nullable<ColorCurves>;
  42490. /**
  42491. * Instantiates a new PBRMaterial instance.
  42492. *
  42493. * @param name The material name
  42494. * @param scene The scene the material will be use in.
  42495. */
  42496. constructor(name: string, scene: Scene);
  42497. /**
  42498. * Returns the name of this material class.
  42499. */
  42500. getClassName(): string;
  42501. /**
  42502. * Returns an array of the actively used textures.
  42503. * @returns - Array of BaseTextures
  42504. */
  42505. getActiveTextures(): BaseTexture[];
  42506. /**
  42507. * Checks to see if a texture is used in the material.
  42508. * @param texture - Base texture to use.
  42509. * @returns - Boolean specifying if a texture is used in the material.
  42510. */
  42511. hasTexture(texture: BaseTexture): boolean;
  42512. /**
  42513. * Makes a duplicate of the current material.
  42514. * @param name - name to use for the new material.
  42515. */
  42516. clone(name: string): PBRMaterial;
  42517. /**
  42518. * Serializes this PBR Material.
  42519. * @returns - An object with the serialized material.
  42520. */
  42521. serialize(): any;
  42522. /**
  42523. * Parses a PBR Material from a serialized object.
  42524. * @param source - Serialized object.
  42525. * @param scene - BJS scene instance.
  42526. * @param rootUrl - url for the scene object
  42527. * @returns - PBRMaterial
  42528. */
  42529. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  42530. }
  42531. }
  42532. declare module BABYLON {
  42533. /** @hidden */
  42534. export var _forceSceneHelpersToBundle: boolean;
  42535. interface Scene {
  42536. /**
  42537. * Creates a default light for the scene.
  42538. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  42539. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  42540. */
  42541. createDefaultLight(replace?: boolean): void;
  42542. /**
  42543. * Creates a default camera for the scene.
  42544. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  42545. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  42546. * @param replace has default false, when true replaces the active camera in the scene
  42547. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  42548. */
  42549. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  42550. /**
  42551. * Creates a default camera and a default light.
  42552. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  42553. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  42554. * @param replace has the default false, when true replaces the active camera/light in the scene
  42555. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  42556. */
  42557. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  42558. /**
  42559. * Creates a new sky box
  42560. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  42561. * @param environmentTexture defines the texture to use as environment texture
  42562. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  42563. * @param scale defines the overall scale of the skybox
  42564. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  42565. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  42566. * @returns a new mesh holding the sky box
  42567. */
  42568. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  42569. /**
  42570. * Creates a new environment
  42571. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  42572. * @param options defines the options you can use to configure the environment
  42573. * @returns the new EnvironmentHelper
  42574. */
  42575. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  42576. /**
  42577. * Creates a new VREXperienceHelper
  42578. * @see http://doc.babylonjs.com/how_to/webvr_helper
  42579. * @param webVROptions defines the options used to create the new VREXperienceHelper
  42580. * @returns a new VREXperienceHelper
  42581. */
  42582. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  42583. /**
  42584. * Creates a new XREXperienceHelper
  42585. * @see http://doc.babylonjs.com/how_to/webxr
  42586. * @returns a promise for a new XREXperienceHelper
  42587. */
  42588. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  42589. }
  42590. }
  42591. declare module BABYLON {
  42592. /**
  42593. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  42594. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  42595. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  42596. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  42597. */
  42598. export class VideoDome extends TransformNode {
  42599. private _useDirectMapping;
  42600. /**
  42601. * The video texture being displayed on the sphere
  42602. */
  42603. protected _videoTexture: VideoTexture;
  42604. /**
  42605. * Gets the video texture being displayed on the sphere
  42606. */
  42607. readonly videoTexture: VideoTexture;
  42608. /**
  42609. * The skybox material
  42610. */
  42611. protected _material: BackgroundMaterial;
  42612. /**
  42613. * The surface used for the skybox
  42614. */
  42615. protected _mesh: Mesh;
  42616. /**
  42617. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42618. * Also see the options.resolution property.
  42619. */
  42620. fovMultiplier: number;
  42621. /**
  42622. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  42623. * @param name Element's name, child elements will append suffixes for their own names.
  42624. * @param urlsOrVideo defines the url(s) or the video element to use
  42625. * @param options An object containing optional or exposed sub element properties
  42626. */
  42627. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  42628. resolution?: number;
  42629. clickToPlay?: boolean;
  42630. autoPlay?: boolean;
  42631. loop?: boolean;
  42632. size?: number;
  42633. poster?: string;
  42634. useDirectMapping?: boolean;
  42635. }, scene: Scene);
  42636. /**
  42637. * Releases resources associated with this node.
  42638. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  42639. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  42640. */
  42641. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  42642. }
  42643. }
  42644. declare module BABYLON {
  42645. /**
  42646. * This class can be used to get instrumentation data from a Babylon engine
  42647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42648. */
  42649. export class EngineInstrumentation implements IDisposable {
  42650. /**
  42651. * Define the instrumented engine.
  42652. */
  42653. engine: Engine;
  42654. private _captureGPUFrameTime;
  42655. private _gpuFrameTimeToken;
  42656. private _gpuFrameTime;
  42657. private _captureShaderCompilationTime;
  42658. private _shaderCompilationTime;
  42659. private _onBeginFrameObserver;
  42660. private _onEndFrameObserver;
  42661. private _onBeforeShaderCompilationObserver;
  42662. private _onAfterShaderCompilationObserver;
  42663. /**
  42664. * Gets the perf counter used for GPU frame time
  42665. */
  42666. readonly gpuFrameTimeCounter: PerfCounter;
  42667. /**
  42668. * Gets the GPU frame time capture status
  42669. */
  42670. /**
  42671. * Enable or disable the GPU frame time capture
  42672. */
  42673. captureGPUFrameTime: boolean;
  42674. /**
  42675. * Gets the perf counter used for shader compilation time
  42676. */
  42677. readonly shaderCompilationTimeCounter: PerfCounter;
  42678. /**
  42679. * Gets the shader compilation time capture status
  42680. */
  42681. /**
  42682. * Enable or disable the shader compilation time capture
  42683. */
  42684. captureShaderCompilationTime: boolean;
  42685. /**
  42686. * Instantiates a new engine instrumentation.
  42687. * This class can be used to get instrumentation data from a Babylon engine
  42688. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42689. * @param engine Defines the engine to instrument
  42690. */
  42691. constructor(
  42692. /**
  42693. * Define the instrumented engine.
  42694. */
  42695. engine: Engine);
  42696. /**
  42697. * Dispose and release associated resources.
  42698. */
  42699. dispose(): void;
  42700. }
  42701. }
  42702. declare module BABYLON {
  42703. /**
  42704. * This class can be used to get instrumentation data from a Babylon engine
  42705. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  42706. */
  42707. export class SceneInstrumentation implements IDisposable {
  42708. /**
  42709. * Defines the scene to instrument
  42710. */
  42711. scene: Scene;
  42712. private _captureActiveMeshesEvaluationTime;
  42713. private _activeMeshesEvaluationTime;
  42714. private _captureRenderTargetsRenderTime;
  42715. private _renderTargetsRenderTime;
  42716. private _captureFrameTime;
  42717. private _frameTime;
  42718. private _captureRenderTime;
  42719. private _renderTime;
  42720. private _captureInterFrameTime;
  42721. private _interFrameTime;
  42722. private _captureParticlesRenderTime;
  42723. private _particlesRenderTime;
  42724. private _captureSpritesRenderTime;
  42725. private _spritesRenderTime;
  42726. private _capturePhysicsTime;
  42727. private _physicsTime;
  42728. private _captureAnimationsTime;
  42729. private _animationsTime;
  42730. private _captureCameraRenderTime;
  42731. private _cameraRenderTime;
  42732. private _onBeforeActiveMeshesEvaluationObserver;
  42733. private _onAfterActiveMeshesEvaluationObserver;
  42734. private _onBeforeRenderTargetsRenderObserver;
  42735. private _onAfterRenderTargetsRenderObserver;
  42736. private _onAfterRenderObserver;
  42737. private _onBeforeDrawPhaseObserver;
  42738. private _onAfterDrawPhaseObserver;
  42739. private _onBeforeAnimationsObserver;
  42740. private _onBeforeParticlesRenderingObserver;
  42741. private _onAfterParticlesRenderingObserver;
  42742. private _onBeforeSpritesRenderingObserver;
  42743. private _onAfterSpritesRenderingObserver;
  42744. private _onBeforePhysicsObserver;
  42745. private _onAfterPhysicsObserver;
  42746. private _onAfterAnimationsObserver;
  42747. private _onBeforeCameraRenderObserver;
  42748. private _onAfterCameraRenderObserver;
  42749. /**
  42750. * Gets the perf counter used for active meshes evaluation time
  42751. */
  42752. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  42753. /**
  42754. * Gets the active meshes evaluation time capture status
  42755. */
  42756. /**
  42757. * Enable or disable the active meshes evaluation time capture
  42758. */
  42759. captureActiveMeshesEvaluationTime: boolean;
  42760. /**
  42761. * Gets the perf counter used for render targets render time
  42762. */
  42763. readonly renderTargetsRenderTimeCounter: PerfCounter;
  42764. /**
  42765. * Gets the render targets render time capture status
  42766. */
  42767. /**
  42768. * Enable or disable the render targets render time capture
  42769. */
  42770. captureRenderTargetsRenderTime: boolean;
  42771. /**
  42772. * Gets the perf counter used for particles render time
  42773. */
  42774. readonly particlesRenderTimeCounter: PerfCounter;
  42775. /**
  42776. * Gets the particles render time capture status
  42777. */
  42778. /**
  42779. * Enable or disable the particles render time capture
  42780. */
  42781. captureParticlesRenderTime: boolean;
  42782. /**
  42783. * Gets the perf counter used for sprites render time
  42784. */
  42785. readonly spritesRenderTimeCounter: PerfCounter;
  42786. /**
  42787. * Gets the sprites render time capture status
  42788. */
  42789. /**
  42790. * Enable or disable the sprites render time capture
  42791. */
  42792. captureSpritesRenderTime: boolean;
  42793. /**
  42794. * Gets the perf counter used for physics time
  42795. */
  42796. readonly physicsTimeCounter: PerfCounter;
  42797. /**
  42798. * Gets the physics time capture status
  42799. */
  42800. /**
  42801. * Enable or disable the physics time capture
  42802. */
  42803. capturePhysicsTime: boolean;
  42804. /**
  42805. * Gets the perf counter used for animations time
  42806. */
  42807. readonly animationsTimeCounter: PerfCounter;
  42808. /**
  42809. * Gets the animations time capture status
  42810. */
  42811. /**
  42812. * Enable or disable the animations time capture
  42813. */
  42814. captureAnimationsTime: boolean;
  42815. /**
  42816. * Gets the perf counter used for frame time capture
  42817. */
  42818. readonly frameTimeCounter: PerfCounter;
  42819. /**
  42820. * Gets the frame time capture status
  42821. */
  42822. /**
  42823. * Enable or disable the frame time capture
  42824. */
  42825. captureFrameTime: boolean;
  42826. /**
  42827. * Gets the perf counter used for inter-frames time capture
  42828. */
  42829. readonly interFrameTimeCounter: PerfCounter;
  42830. /**
  42831. * Gets the inter-frames time capture status
  42832. */
  42833. /**
  42834. * Enable or disable the inter-frames time capture
  42835. */
  42836. captureInterFrameTime: boolean;
  42837. /**
  42838. * Gets the perf counter used for render time capture
  42839. */
  42840. readonly renderTimeCounter: PerfCounter;
  42841. /**
  42842. * Gets the render time capture status
  42843. */
  42844. /**
  42845. * Enable or disable the render time capture
  42846. */
  42847. captureRenderTime: boolean;
  42848. /**
  42849. * Gets the perf counter used for camera render time capture
  42850. */
  42851. readonly cameraRenderTimeCounter: PerfCounter;
  42852. /**
  42853. * Gets the camera render time capture status
  42854. */
  42855. /**
  42856. * Enable or disable the camera render time capture
  42857. */
  42858. captureCameraRenderTime: boolean;
  42859. /**
  42860. * Gets the perf counter used for draw calls
  42861. */
  42862. readonly drawCallsCounter: PerfCounter;
  42863. /**
  42864. * Gets the perf counter used for texture collisions
  42865. */
  42866. readonly textureCollisionsCounter: PerfCounter;
  42867. /**
  42868. * Instantiates a new scene instrumentation.
  42869. * This class can be used to get instrumentation data from a Babylon engine
  42870. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  42871. * @param scene Defines the scene to instrument
  42872. */
  42873. constructor(
  42874. /**
  42875. * Defines the scene to instrument
  42876. */
  42877. scene: Scene);
  42878. /**
  42879. * Dispose and release associated resources.
  42880. */
  42881. dispose(): void;
  42882. }
  42883. }
  42884. declare module BABYLON {
  42885. /** @hidden */
  42886. export var glowMapGenerationPixelShader: {
  42887. name: string;
  42888. shader: string;
  42889. };
  42890. }
  42891. declare module BABYLON {
  42892. /** @hidden */
  42893. export var glowMapGenerationVertexShader: {
  42894. name: string;
  42895. shader: string;
  42896. };
  42897. }
  42898. declare module BABYLON {
  42899. /**
  42900. * Effect layer options. This helps customizing the behaviour
  42901. * of the effect layer.
  42902. */
  42903. export interface IEffectLayerOptions {
  42904. /**
  42905. * Multiplication factor apply to the canvas size to compute the render target size
  42906. * used to generated the objects (the smaller the faster).
  42907. */
  42908. mainTextureRatio: number;
  42909. /**
  42910. * Enforces a fixed size texture to ensure effect stability across devices.
  42911. */
  42912. mainTextureFixedSize?: number;
  42913. /**
  42914. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  42915. */
  42916. alphaBlendingMode: number;
  42917. /**
  42918. * The camera attached to the layer.
  42919. */
  42920. camera: Nullable<Camera>;
  42921. /**
  42922. * The rendering group to draw the layer in.
  42923. */
  42924. renderingGroupId: number;
  42925. }
  42926. /**
  42927. * The effect layer Helps adding post process effect blended with the main pass.
  42928. *
  42929. * This can be for instance use to generate glow or higlight effects on the scene.
  42930. *
  42931. * The effect layer class can not be used directly and is intented to inherited from to be
  42932. * customized per effects.
  42933. */
  42934. export abstract class EffectLayer {
  42935. private _vertexBuffers;
  42936. private _indexBuffer;
  42937. private _cachedDefines;
  42938. private _effectLayerMapGenerationEffect;
  42939. private _effectLayerOptions;
  42940. private _mergeEffect;
  42941. protected _scene: Scene;
  42942. protected _engine: Engine;
  42943. protected _maxSize: number;
  42944. protected _mainTextureDesiredSize: ISize;
  42945. protected _mainTexture: RenderTargetTexture;
  42946. protected _shouldRender: boolean;
  42947. protected _postProcesses: PostProcess[];
  42948. protected _textures: BaseTexture[];
  42949. protected _emissiveTextureAndColor: {
  42950. texture: Nullable<BaseTexture>;
  42951. color: Color4;
  42952. };
  42953. /**
  42954. * The name of the layer
  42955. */
  42956. name: string;
  42957. /**
  42958. * The clear color of the texture used to generate the glow map.
  42959. */
  42960. neutralColor: Color4;
  42961. /**
  42962. * Specifies wether the highlight layer is enabled or not.
  42963. */
  42964. isEnabled: boolean;
  42965. /**
  42966. * Gets the camera attached to the layer.
  42967. */
  42968. readonly camera: Nullable<Camera>;
  42969. /**
  42970. * Gets the rendering group id the layer should render in.
  42971. */
  42972. readonly renderingGroupId: number;
  42973. /**
  42974. * An event triggered when the effect layer has been disposed.
  42975. */
  42976. onDisposeObservable: Observable<EffectLayer>;
  42977. /**
  42978. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  42979. */
  42980. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  42981. /**
  42982. * An event triggered when the generated texture is being merged in the scene.
  42983. */
  42984. onBeforeComposeObservable: Observable<EffectLayer>;
  42985. /**
  42986. * An event triggered when the generated texture has been merged in the scene.
  42987. */
  42988. onAfterComposeObservable: Observable<EffectLayer>;
  42989. /**
  42990. * An event triggered when the efffect layer changes its size.
  42991. */
  42992. onSizeChangedObservable: Observable<EffectLayer>;
  42993. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  42994. /**
  42995. * Instantiates a new effect Layer and references it in the scene.
  42996. * @param name The name of the layer
  42997. * @param scene The scene to use the layer in
  42998. */
  42999. constructor(
  43000. /** The Friendly of the effect in the scene */
  43001. name: string, scene: Scene);
  43002. /**
  43003. * Get the effect name of the layer.
  43004. * @return The effect name
  43005. */
  43006. abstract getEffectName(): string;
  43007. /**
  43008. * Checks for the readiness of the element composing the layer.
  43009. * @param subMesh the mesh to check for
  43010. * @param useInstances specify wether or not to use instances to render the mesh
  43011. * @return true if ready otherwise, false
  43012. */
  43013. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43014. /**
  43015. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43016. * @returns true if the effect requires stencil during the main canvas render pass.
  43017. */
  43018. abstract needStencil(): boolean;
  43019. /**
  43020. * Create the merge effect. This is the shader use to blit the information back
  43021. * to the main canvas at the end of the scene rendering.
  43022. * @returns The effect containing the shader used to merge the effect on the main canvas
  43023. */
  43024. protected abstract _createMergeEffect(): Effect;
  43025. /**
  43026. * Creates the render target textures and post processes used in the effect layer.
  43027. */
  43028. protected abstract _createTextureAndPostProcesses(): void;
  43029. /**
  43030. * Implementation specific of rendering the generating effect on the main canvas.
  43031. * @param effect The effect used to render through
  43032. */
  43033. protected abstract _internalRender(effect: Effect): void;
  43034. /**
  43035. * Sets the required values for both the emissive texture and and the main color.
  43036. */
  43037. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  43038. /**
  43039. * Free any resources and references associated to a mesh.
  43040. * Internal use
  43041. * @param mesh The mesh to free.
  43042. */
  43043. abstract _disposeMesh(mesh: Mesh): void;
  43044. /**
  43045. * Serializes this layer (Glow or Highlight for example)
  43046. * @returns a serialized layer object
  43047. */
  43048. abstract serialize?(): any;
  43049. /**
  43050. * Initializes the effect layer with the required options.
  43051. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  43052. */
  43053. protected _init(options: Partial<IEffectLayerOptions>): void;
  43054. /**
  43055. * Generates the index buffer of the full screen quad blending to the main canvas.
  43056. */
  43057. private _generateIndexBuffer;
  43058. /**
  43059. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  43060. */
  43061. private _genrateVertexBuffer;
  43062. /**
  43063. * Sets the main texture desired size which is the closest power of two
  43064. * of the engine canvas size.
  43065. */
  43066. private _setMainTextureSize;
  43067. /**
  43068. * Creates the main texture for the effect layer.
  43069. */
  43070. protected _createMainTexture(): void;
  43071. /**
  43072. * Adds specific effects defines.
  43073. * @param defines The defines to add specifics to.
  43074. */
  43075. protected _addCustomEffectDefines(defines: string[]): void;
  43076. /**
  43077. * Checks for the readiness of the element composing the layer.
  43078. * @param subMesh the mesh to check for
  43079. * @param useInstances specify wether or not to use instances to render the mesh
  43080. * @param emissiveTexture the associated emissive texture used to generate the glow
  43081. * @return true if ready otherwise, false
  43082. */
  43083. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  43084. /**
  43085. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  43086. */
  43087. render(): void;
  43088. /**
  43089. * Determine if a given mesh will be used in the current effect.
  43090. * @param mesh mesh to test
  43091. * @returns true if the mesh will be used
  43092. */
  43093. hasMesh(mesh: AbstractMesh): boolean;
  43094. /**
  43095. * Returns true if the layer contains information to display, otherwise false.
  43096. * @returns true if the glow layer should be rendered
  43097. */
  43098. shouldRender(): 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 _shouldRenderMesh(mesh: AbstractMesh): boolean;
  43105. /**
  43106. * Returns true if the mesh can be rendered, otherwise false.
  43107. * @param mesh The mesh to render
  43108. * @param material The material used on the mesh
  43109. * @returns true if it can be rendered otherwise false
  43110. */
  43111. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  43112. /**
  43113. * Returns true if the mesh should render, otherwise false.
  43114. * @param mesh The mesh to render
  43115. * @returns true if it should render otherwise false
  43116. */
  43117. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  43118. /**
  43119. * Renders the submesh passed in parameter to the generation map.
  43120. */
  43121. protected _renderSubMesh(subMesh: SubMesh): void;
  43122. /**
  43123. * Rebuild the required buffers.
  43124. * @hidden Internal use only.
  43125. */ rebuild(): void;
  43126. /**
  43127. * Dispose only the render target textures and post process.
  43128. */
  43129. private _disposeTextureAndPostProcesses;
  43130. /**
  43131. * Dispose the highlight layer and free resources.
  43132. */
  43133. dispose(): void;
  43134. /**
  43135. * Gets the class name of the effect layer
  43136. * @returns the string with the class name of the effect layer
  43137. */
  43138. getClassName(): string;
  43139. /**
  43140. * Creates an effect layer from parsed effect layer data
  43141. * @param parsedEffectLayer defines effect layer data
  43142. * @param scene defines the current scene
  43143. * @param rootUrl defines the root URL containing the effect layer information
  43144. * @returns a parsed effect Layer
  43145. */
  43146. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  43147. }
  43148. }
  43149. declare module BABYLON {
  43150. interface AbstractScene {
  43151. /**
  43152. * The list of effect layers (highlights/glow) added to the scene
  43153. * @see http://doc.babylonjs.com/how_to/highlight_layer
  43154. * @see http://doc.babylonjs.com/how_to/glow_layer
  43155. */
  43156. effectLayers: Array<EffectLayer>;
  43157. /**
  43158. * Removes the given effect layer from this scene.
  43159. * @param toRemove defines the effect layer to remove
  43160. * @returns the index of the removed effect layer
  43161. */
  43162. removeEffectLayer(toRemove: EffectLayer): number;
  43163. /**
  43164. * Adds the given effect layer to this scene
  43165. * @param newEffectLayer defines the effect layer to add
  43166. */
  43167. addEffectLayer(newEffectLayer: EffectLayer): void;
  43168. }
  43169. /**
  43170. * Defines the layer scene component responsible to manage any effect layers
  43171. * in a given scene.
  43172. */
  43173. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  43174. /**
  43175. * The component name helpfull to identify the component in the list of scene components.
  43176. */
  43177. readonly name: string;
  43178. /**
  43179. * The scene the component belongs to.
  43180. */
  43181. scene: Scene;
  43182. private _engine;
  43183. private _renderEffects;
  43184. private _needStencil;
  43185. private _previousStencilState;
  43186. /**
  43187. * Creates a new instance of the component for the given scene
  43188. * @param scene Defines the scene to register the component in
  43189. */
  43190. constructor(scene: Scene);
  43191. /**
  43192. * Registers the component in a given scene
  43193. */
  43194. register(): void;
  43195. /**
  43196. * Rebuilds the elements related to this component in case of
  43197. * context lost for instance.
  43198. */
  43199. rebuild(): void;
  43200. /**
  43201. * Serializes the component data to the specified json object
  43202. * @param serializationObject The object to serialize to
  43203. */
  43204. serialize(serializationObject: any): void;
  43205. /**
  43206. * Adds all the element from the container to the scene
  43207. * @param container the container holding the elements
  43208. */
  43209. addFromContainer(container: AbstractScene): void;
  43210. /**
  43211. * Removes all the elements in the container from the scene
  43212. * @param container contains the elements to remove
  43213. */
  43214. removeFromContainer(container: AbstractScene): void;
  43215. /**
  43216. * Disposes the component and the associated ressources.
  43217. */
  43218. dispose(): void;
  43219. private _isReadyForMesh;
  43220. private _renderMainTexture;
  43221. private _setStencil;
  43222. private _setStencilBack;
  43223. private _draw;
  43224. private _drawCamera;
  43225. private _drawRenderingGroup;
  43226. }
  43227. }
  43228. declare module BABYLON {
  43229. /** @hidden */
  43230. export var glowMapMergePixelShader: {
  43231. name: string;
  43232. shader: string;
  43233. };
  43234. }
  43235. declare module BABYLON {
  43236. /** @hidden */
  43237. export var glowMapMergeVertexShader: {
  43238. name: string;
  43239. shader: string;
  43240. };
  43241. }
  43242. declare module BABYLON {
  43243. interface AbstractScene {
  43244. /**
  43245. * Return a the first highlight layer of the scene with a given name.
  43246. * @param name The name of the highlight layer to look for.
  43247. * @return The highlight layer if found otherwise null.
  43248. */
  43249. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  43250. }
  43251. /**
  43252. * Glow layer options. This helps customizing the behaviour
  43253. * of the glow layer.
  43254. */
  43255. export interface IGlowLayerOptions {
  43256. /**
  43257. * Multiplication factor apply to the canvas size to compute the render target size
  43258. * used to generated the glowing objects (the smaller the faster).
  43259. */
  43260. mainTextureRatio: number;
  43261. /**
  43262. * Enforces a fixed size texture to ensure resize independant blur.
  43263. */
  43264. mainTextureFixedSize?: number;
  43265. /**
  43266. * How big is the kernel of the blur texture.
  43267. */
  43268. blurKernelSize: number;
  43269. /**
  43270. * The camera attached to the layer.
  43271. */
  43272. camera: Nullable<Camera>;
  43273. /**
  43274. * Enable MSAA by chosing the number of samples.
  43275. */
  43276. mainTextureSamples?: number;
  43277. /**
  43278. * The rendering group to draw the layer in.
  43279. */
  43280. renderingGroupId: number;
  43281. }
  43282. /**
  43283. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  43284. *
  43285. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43286. * glowy meshes to your scene.
  43287. *
  43288. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  43289. */
  43290. export class GlowLayer extends EffectLayer {
  43291. /**
  43292. * Effect Name of the layer.
  43293. */
  43294. static readonly EffectName: string;
  43295. /**
  43296. * The default blur kernel size used for the glow.
  43297. */
  43298. static DefaultBlurKernelSize: number;
  43299. /**
  43300. * The default texture size ratio used for the glow.
  43301. */
  43302. static DefaultTextureRatio: number;
  43303. /**
  43304. * Sets the kernel size of the blur.
  43305. */
  43306. /**
  43307. * Gets the kernel size of the blur.
  43308. */
  43309. blurKernelSize: number;
  43310. /**
  43311. * Sets the glow intensity.
  43312. */
  43313. /**
  43314. * Gets the glow intensity.
  43315. */
  43316. intensity: number;
  43317. private _options;
  43318. private _intensity;
  43319. private _horizontalBlurPostprocess1;
  43320. private _verticalBlurPostprocess1;
  43321. private _horizontalBlurPostprocess2;
  43322. private _verticalBlurPostprocess2;
  43323. private _blurTexture1;
  43324. private _blurTexture2;
  43325. private _postProcesses1;
  43326. private _postProcesses2;
  43327. private _includedOnlyMeshes;
  43328. private _excludedMeshes;
  43329. /**
  43330. * Callback used to let the user override the color selection on a per mesh basis
  43331. */
  43332. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  43333. /**
  43334. * Callback used to let the user override the texture selection on a per mesh basis
  43335. */
  43336. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  43337. /**
  43338. * Instantiates a new glow Layer and references it to the scene.
  43339. * @param name The name of the layer
  43340. * @param scene The scene to use the layer in
  43341. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  43342. */
  43343. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  43344. /**
  43345. * Get the effect name of the layer.
  43346. * @return The effect name
  43347. */
  43348. getEffectName(): string;
  43349. /**
  43350. * Create the merge effect. This is the shader use to blit the information back
  43351. * to the main canvas at the end of the scene rendering.
  43352. */
  43353. protected _createMergeEffect(): Effect;
  43354. /**
  43355. * Creates the render target textures and post processes used in the glow layer.
  43356. */
  43357. protected _createTextureAndPostProcesses(): void;
  43358. /**
  43359. * Checks for the readiness of the element composing the layer.
  43360. * @param subMesh the mesh to check for
  43361. * @param useInstances specify wether or not to use instances to render the mesh
  43362. * @param emissiveTexture the associated emissive texture used to generate the glow
  43363. * @return true if ready otherwise, false
  43364. */
  43365. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43366. /**
  43367. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43368. */
  43369. needStencil(): boolean;
  43370. /**
  43371. * Returns true if the mesh can be rendered, otherwise false.
  43372. * @param mesh The mesh to render
  43373. * @param material The material used on the mesh
  43374. * @returns true if it can be rendered otherwise false
  43375. */
  43376. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  43377. /**
  43378. * Implementation specific of rendering the generating effect on the main canvas.
  43379. * @param effect The effect used to render through
  43380. */
  43381. protected _internalRender(effect: Effect): void;
  43382. /**
  43383. * Sets the required values for both the emissive texture and and the main color.
  43384. */
  43385. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  43386. /**
  43387. * Returns true if the mesh should render, otherwise false.
  43388. * @param mesh The mesh to render
  43389. * @returns true if it should render otherwise false
  43390. */
  43391. protected _shouldRenderMesh(mesh: Mesh): boolean;
  43392. /**
  43393. * Adds specific effects defines.
  43394. * @param defines The defines to add specifics to.
  43395. */
  43396. protected _addCustomEffectDefines(defines: string[]): void;
  43397. /**
  43398. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  43399. * @param mesh The mesh to exclude from the glow layer
  43400. */
  43401. addExcludedMesh(mesh: Mesh): void;
  43402. /**
  43403. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  43404. * @param mesh The mesh to remove
  43405. */
  43406. removeExcludedMesh(mesh: Mesh): void;
  43407. /**
  43408. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  43409. * @param mesh The mesh to include in the glow layer
  43410. */
  43411. addIncludedOnlyMesh(mesh: Mesh): void;
  43412. /**
  43413. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  43414. * @param mesh The mesh to remove
  43415. */
  43416. removeIncludedOnlyMesh(mesh: Mesh): void;
  43417. /**
  43418. * Determine if a given mesh will be used in the glow layer
  43419. * @param mesh The mesh to test
  43420. * @returns true if the mesh will be highlighted by the current glow layer
  43421. */
  43422. hasMesh(mesh: AbstractMesh): boolean;
  43423. /**
  43424. * Free any resources and references associated to a mesh.
  43425. * Internal use
  43426. * @param mesh The mesh to free.
  43427. * @hidden
  43428. */ disposeMesh(mesh: Mesh): void;
  43429. /**
  43430. * Gets the class name of the effect layer
  43431. * @returns the string with the class name of the effect layer
  43432. */
  43433. getClassName(): string;
  43434. /**
  43435. * Serializes this glow layer
  43436. * @returns a serialized glow layer object
  43437. */
  43438. serialize(): any;
  43439. /**
  43440. * Creates a Glow Layer from parsed glow layer data
  43441. * @param parsedGlowLayer defines glow layer data
  43442. * @param scene defines the current scene
  43443. * @param rootUrl defines the root URL containing the glow layer information
  43444. * @returns a parsed Glow Layer
  43445. */
  43446. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  43447. }
  43448. }
  43449. declare module BABYLON {
  43450. /** @hidden */
  43451. export var glowBlurPostProcessPixelShader: {
  43452. name: string;
  43453. shader: string;
  43454. };
  43455. }
  43456. declare module BABYLON {
  43457. interface AbstractScene {
  43458. /**
  43459. * Return a the first highlight layer of the scene with a given name.
  43460. * @param name The name of the highlight layer to look for.
  43461. * @return The highlight layer if found otherwise null.
  43462. */
  43463. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  43464. }
  43465. /**
  43466. * Highlight layer options. This helps customizing the behaviour
  43467. * of the highlight layer.
  43468. */
  43469. export interface IHighlightLayerOptions {
  43470. /**
  43471. * Multiplication factor apply to the canvas size to compute the render target size
  43472. * used to generated the glowing objects (the smaller the faster).
  43473. */
  43474. mainTextureRatio: number;
  43475. /**
  43476. * Enforces a fixed size texture to ensure resize independant blur.
  43477. */
  43478. mainTextureFixedSize?: number;
  43479. /**
  43480. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  43481. * of the picture to blur (the smaller the faster).
  43482. */
  43483. blurTextureSizeRatio: number;
  43484. /**
  43485. * How big in texel of the blur texture is the vertical blur.
  43486. */
  43487. blurVerticalSize: number;
  43488. /**
  43489. * How big in texel of the blur texture is the horizontal blur.
  43490. */
  43491. blurHorizontalSize: number;
  43492. /**
  43493. * Alpha blending mode used to apply the blur. Default is combine.
  43494. */
  43495. alphaBlendingMode: number;
  43496. /**
  43497. * The camera attached to the layer.
  43498. */
  43499. camera: Nullable<Camera>;
  43500. /**
  43501. * Should we display highlight as a solid stroke?
  43502. */
  43503. isStroke?: boolean;
  43504. /**
  43505. * The rendering group to draw the layer in.
  43506. */
  43507. renderingGroupId: number;
  43508. }
  43509. /**
  43510. * The highlight layer Helps adding a glow effect around a mesh.
  43511. *
  43512. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43513. * glowy meshes to your scene.
  43514. *
  43515. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  43516. */
  43517. export class HighlightLayer extends EffectLayer {
  43518. name: string;
  43519. /**
  43520. * Effect Name of the highlight layer.
  43521. */
  43522. static readonly EffectName: string;
  43523. /**
  43524. * The neutral color used during the preparation of the glow effect.
  43525. * This is black by default as the blend operation is a blend operation.
  43526. */
  43527. static NeutralColor: Color4;
  43528. /**
  43529. * Stencil value used for glowing meshes.
  43530. */
  43531. static GlowingMeshStencilReference: number;
  43532. /**
  43533. * Stencil value used for the other meshes in the scene.
  43534. */
  43535. static NormalMeshStencilReference: number;
  43536. /**
  43537. * Specifies whether or not the inner glow is ACTIVE in the layer.
  43538. */
  43539. innerGlow: boolean;
  43540. /**
  43541. * Specifies whether or not the outer glow is ACTIVE in the layer.
  43542. */
  43543. outerGlow: boolean;
  43544. /**
  43545. * Specifies the horizontal size of the blur.
  43546. */
  43547. /**
  43548. * Gets the horizontal size of the blur.
  43549. */
  43550. blurHorizontalSize: number;
  43551. /**
  43552. * Specifies the vertical size of the blur.
  43553. */
  43554. /**
  43555. * Gets the vertical size of the blur.
  43556. */
  43557. blurVerticalSize: number;
  43558. /**
  43559. * An event triggered when the highlight layer is being blurred.
  43560. */
  43561. onBeforeBlurObservable: Observable<HighlightLayer>;
  43562. /**
  43563. * An event triggered when the highlight layer has been blurred.
  43564. */
  43565. onAfterBlurObservable: Observable<HighlightLayer>;
  43566. private _instanceGlowingMeshStencilReference;
  43567. private _options;
  43568. private _downSamplePostprocess;
  43569. private _horizontalBlurPostprocess;
  43570. private _verticalBlurPostprocess;
  43571. private _blurTexture;
  43572. private _meshes;
  43573. private _excludedMeshes;
  43574. /**
  43575. * Instantiates a new highlight Layer and references it to the scene..
  43576. * @param name The name of the layer
  43577. * @param scene The scene to use the layer in
  43578. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  43579. */
  43580. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  43581. /**
  43582. * Get the effect name of the layer.
  43583. * @return The effect name
  43584. */
  43585. getEffectName(): string;
  43586. /**
  43587. * Create the merge effect. This is the shader use to blit the information back
  43588. * to the main canvas at the end of the scene rendering.
  43589. */
  43590. protected _createMergeEffect(): Effect;
  43591. /**
  43592. * Creates the render target textures and post processes used in the highlight layer.
  43593. */
  43594. protected _createTextureAndPostProcesses(): void;
  43595. /**
  43596. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43597. */
  43598. needStencil(): boolean;
  43599. /**
  43600. * Checks for the readiness of the element composing the layer.
  43601. * @param subMesh the mesh to check for
  43602. * @param useInstances specify wether or not to use instances to render the mesh
  43603. * @param emissiveTexture the associated emissive texture used to generate the glow
  43604. * @return true if ready otherwise, false
  43605. */
  43606. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43607. /**
  43608. * Implementation specific of rendering the generating effect on the main canvas.
  43609. * @param effect The effect used to render through
  43610. */
  43611. protected _internalRender(effect: Effect): void;
  43612. /**
  43613. * Returns true if the layer contains information to display, otherwise false.
  43614. */
  43615. shouldRender(): boolean;
  43616. /**
  43617. * Returns true if the mesh should render, otherwise false.
  43618. * @param mesh The mesh to render
  43619. * @returns true if it should render otherwise false
  43620. */
  43621. protected _shouldRenderMesh(mesh: Mesh): boolean;
  43622. /**
  43623. * Sets the required values for both the emissive texture and and the main color.
  43624. */
  43625. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  43626. /**
  43627. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  43628. * @param mesh The mesh to exclude from the highlight layer
  43629. */
  43630. addExcludedMesh(mesh: Mesh): void;
  43631. /**
  43632. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  43633. * @param mesh The mesh to highlight
  43634. */
  43635. removeExcludedMesh(mesh: Mesh): void;
  43636. /**
  43637. * Determine if a given mesh will be highlighted by the current HighlightLayer
  43638. * @param mesh mesh to test
  43639. * @returns true if the mesh will be highlighted by the current HighlightLayer
  43640. */
  43641. hasMesh(mesh: AbstractMesh): boolean;
  43642. /**
  43643. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  43644. * @param mesh The mesh to highlight
  43645. * @param color The color of the highlight
  43646. * @param glowEmissiveOnly Extract the glow from the emissive texture
  43647. */
  43648. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  43649. /**
  43650. * Remove a mesh from the highlight layer in order to make it stop glowing.
  43651. * @param mesh The mesh to highlight
  43652. */
  43653. removeMesh(mesh: Mesh): void;
  43654. /**
  43655. * Force the stencil to the normal expected value for none glowing parts
  43656. */
  43657. private _defaultStencilReference;
  43658. /**
  43659. * Free any resources and references associated to a mesh.
  43660. * Internal use
  43661. * @param mesh The mesh to free.
  43662. * @hidden
  43663. */ disposeMesh(mesh: Mesh): void;
  43664. /**
  43665. * Dispose the highlight layer and free resources.
  43666. */
  43667. dispose(): void;
  43668. /**
  43669. * Gets the class name of the effect layer
  43670. * @returns the string with the class name of the effect layer
  43671. */
  43672. getClassName(): string;
  43673. /**
  43674. * Serializes this Highlight layer
  43675. * @returns a serialized Highlight layer object
  43676. */
  43677. serialize(): any;
  43678. /**
  43679. * Creates a Highlight layer from parsed Highlight layer data
  43680. * @param parsedHightlightLayer defines the Highlight layer data
  43681. * @param scene defines the current scene
  43682. * @param rootUrl defines the root URL containing the Highlight layer information
  43683. * @returns a parsed Highlight layer
  43684. */
  43685. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  43686. }
  43687. }
  43688. declare module BABYLON {
  43689. /** @hidden */
  43690. export var lensFlarePixelShader: {
  43691. name: string;
  43692. shader: string;
  43693. };
  43694. }
  43695. declare module BABYLON {
  43696. /** @hidden */
  43697. export var lensFlareVertexShader: {
  43698. name: string;
  43699. shader: string;
  43700. };
  43701. }
  43702. declare module BABYLON {
  43703. /**
  43704. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43705. * It is usually composed of several `lensFlare`.
  43706. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43707. */
  43708. export class LensFlareSystem {
  43709. /**
  43710. * Define the name of the lens flare system
  43711. */
  43712. name: string;
  43713. /**
  43714. * List of lens flares used in this system.
  43715. */
  43716. lensFlares: LensFlare[];
  43717. /**
  43718. * Define a limit from the border the lens flare can be visible.
  43719. */
  43720. borderLimit: number;
  43721. /**
  43722. * Define a viewport border we do not want to see the lens flare in.
  43723. */
  43724. viewportBorder: number;
  43725. /**
  43726. * Define a predicate which could limit the list of meshes able to occlude the effect.
  43727. */
  43728. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43729. /**
  43730. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  43731. */
  43732. layerMask: number;
  43733. /**
  43734. * Define the id of the lens flare system in the scene.
  43735. * (equal to name by default)
  43736. */
  43737. id: string;
  43738. private _scene;
  43739. private _emitter;
  43740. private _vertexBuffers;
  43741. private _indexBuffer;
  43742. private _effect;
  43743. private _positionX;
  43744. private _positionY;
  43745. private _isEnabled;
  43746. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  43747. /**
  43748. * Instantiates a lens flare system.
  43749. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43750. * It is usually composed of several `lensFlare`.
  43751. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43752. * @param name Define the name of the lens flare system in the scene
  43753. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  43754. * @param scene Define the scene the lens flare system belongs to
  43755. */
  43756. constructor(
  43757. /**
  43758. * Define the name of the lens flare system
  43759. */
  43760. name: string, emitter: any, scene: Scene);
  43761. /**
  43762. * Define if the lens flare system is enabled.
  43763. */
  43764. isEnabled: boolean;
  43765. /**
  43766. * Get the scene the effects belongs to.
  43767. * @returns the scene holding the lens flare system
  43768. */
  43769. getScene(): Scene;
  43770. /**
  43771. * Get the emitter of the lens flare system.
  43772. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43773. * @returns the emitter of the lens flare system
  43774. */
  43775. getEmitter(): any;
  43776. /**
  43777. * Set the emitter of the lens flare system.
  43778. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43779. * @param newEmitter Define the new emitter of the system
  43780. */
  43781. setEmitter(newEmitter: any): void;
  43782. /**
  43783. * Get the lens flare system emitter position.
  43784. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  43785. * @returns the position
  43786. */
  43787. getEmitterPosition(): Vector3;
  43788. /**
  43789. * @hidden
  43790. */
  43791. computeEffectivePosition(globalViewport: Viewport): boolean;
  43792. /** @hidden */ isVisible(): boolean;
  43793. /**
  43794. * @hidden
  43795. */
  43796. render(): boolean;
  43797. /**
  43798. * Dispose and release the lens flare with its associated resources.
  43799. */
  43800. dispose(): void;
  43801. /**
  43802. * Parse a lens flare system from a JSON repressentation
  43803. * @param parsedLensFlareSystem Define the JSON to parse
  43804. * @param scene Define the scene the parsed system should be instantiated in
  43805. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  43806. * @returns the parsed system
  43807. */
  43808. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  43809. /**
  43810. * Serialize the current Lens Flare System into a JSON representation.
  43811. * @returns the serialized JSON
  43812. */
  43813. serialize(): any;
  43814. }
  43815. }
  43816. declare module BABYLON {
  43817. /**
  43818. * This represents one of the lens effect in a `lensFlareSystem`.
  43819. * It controls one of the indiviual texture used in the effect.
  43820. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43821. */
  43822. export class LensFlare {
  43823. /**
  43824. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  43825. */
  43826. size: number;
  43827. /**
  43828. * 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.
  43829. */
  43830. position: number;
  43831. /**
  43832. * Define the lens color.
  43833. */
  43834. color: Color3;
  43835. /**
  43836. * Define the lens texture.
  43837. */
  43838. texture: Nullable<Texture>;
  43839. /**
  43840. * Define the alpha mode to render this particular lens.
  43841. */
  43842. alphaMode: number;
  43843. private _system;
  43844. /**
  43845. * Creates 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 (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. * @returns The newly created Lens Flare
  43855. */
  43856. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  43857. /**
  43858. * Instantiates a new Lens Flare.
  43859. * This represents one of the lens effect in a `lensFlareSystem`.
  43860. * It controls one of the indiviual texture used in the effect.
  43861. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43862. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  43863. * @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.
  43864. * @param color Define the lens color
  43865. * @param imgUrl Define the lens texture url
  43866. * @param system Define the `lensFlareSystem` this flare is part of
  43867. */
  43868. constructor(
  43869. /**
  43870. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  43871. */
  43872. size: number,
  43873. /**
  43874. * 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.
  43875. */
  43876. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  43877. /**
  43878. * Dispose and release the lens flare with its associated resources.
  43879. */
  43880. dispose(): void;
  43881. }
  43882. }
  43883. declare module BABYLON {
  43884. interface AbstractScene {
  43885. /**
  43886. * The list of lens flare system added to the scene
  43887. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43888. */
  43889. lensFlareSystems: Array<LensFlareSystem>;
  43890. /**
  43891. * Removes the given lens flare system from this scene.
  43892. * @param toRemove The lens flare system to remove
  43893. * @returns The index of the removed lens flare system
  43894. */
  43895. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  43896. /**
  43897. * Adds the given lens flare system to this scene
  43898. * @param newLensFlareSystem The lens flare system to add
  43899. */
  43900. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  43901. /**
  43902. * Gets a lens flare system using its name
  43903. * @param name defines the name to look for
  43904. * @returns the lens flare system or null if not found
  43905. */
  43906. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  43907. /**
  43908. * Gets a lens flare system using its id
  43909. * @param id defines the id to look for
  43910. * @returns the lens flare system or null if not found
  43911. */
  43912. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  43913. }
  43914. /**
  43915. * Defines the lens flare scene component responsible to manage any lens flares
  43916. * in a given scene.
  43917. */
  43918. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  43919. /**
  43920. * The component name helpfull to identify the component in the list of scene components.
  43921. */
  43922. readonly name: string;
  43923. /**
  43924. * The scene the component belongs to.
  43925. */
  43926. scene: Scene;
  43927. /**
  43928. * Creates a new instance of the component for the given scene
  43929. * @param scene Defines the scene to register the component in
  43930. */
  43931. constructor(scene: Scene);
  43932. /**
  43933. * Registers the component in a given scene
  43934. */
  43935. register(): void;
  43936. /**
  43937. * Rebuilds the elements related to this component in case of
  43938. * context lost for instance.
  43939. */
  43940. rebuild(): void;
  43941. /**
  43942. * Adds all the element from the container to the scene
  43943. * @param container the container holding the elements
  43944. */
  43945. addFromContainer(container: AbstractScene): void;
  43946. /**
  43947. * Removes all the elements in the container from the scene
  43948. * @param container contains the elements to remove
  43949. */
  43950. removeFromContainer(container: AbstractScene): void;
  43951. /**
  43952. * Serializes the component data to the specified json object
  43953. * @param serializationObject The object to serialize to
  43954. */
  43955. serialize(serializationObject: any): void;
  43956. /**
  43957. * Disposes the component and the associated ressources.
  43958. */
  43959. dispose(): void;
  43960. private _draw;
  43961. }
  43962. }
  43963. declare module BABYLON {
  43964. /**
  43965. * Defines the shadow generator component responsible to manage any shadow generators
  43966. * in a given scene.
  43967. */
  43968. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  43969. /**
  43970. * The component name helpfull to identify the component in the list of scene components.
  43971. */
  43972. readonly name: string;
  43973. /**
  43974. * The scene the component belongs to.
  43975. */
  43976. scene: Scene;
  43977. /**
  43978. * Creates a new instance of the component for the given scene
  43979. * @param scene Defines the scene to register the component in
  43980. */
  43981. constructor(scene: Scene);
  43982. /**
  43983. * Registers the component in a given scene
  43984. */
  43985. register(): void;
  43986. /**
  43987. * Rebuilds the elements related to this component in case of
  43988. * context lost for instance.
  43989. */
  43990. rebuild(): void;
  43991. /**
  43992. * Serializes the component data to the specified json object
  43993. * @param serializationObject The object to serialize to
  43994. */
  43995. serialize(serializationObject: any): void;
  43996. /**
  43997. * Adds all the element from the container to the scene
  43998. * @param container the container holding the elements
  43999. */
  44000. addFromContainer(container: AbstractScene): void;
  44001. /**
  44002. * Removes all the elements in the container from the scene
  44003. * @param container contains the elements to remove
  44004. */
  44005. removeFromContainer(container: AbstractScene): void;
  44006. /**
  44007. * Rebuilds the elements related to this component in case of
  44008. * context lost for instance.
  44009. */
  44010. dispose(): void;
  44011. private _gatherRenderTargets;
  44012. }
  44013. }
  44014. declare module BABYLON {
  44015. /**
  44016. * A directional light is defined by a direction (what a surprise!).
  44017. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44018. * 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.
  44019. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44020. */
  44021. export class DirectionalLight extends ShadowLight {
  44022. private _shadowFrustumSize;
  44023. /**
  44024. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44025. */
  44026. /**
  44027. * Specifies a fix frustum size for the shadow generation.
  44028. */
  44029. shadowFrustumSize: number;
  44030. private _shadowOrthoScale;
  44031. /**
  44032. * Gets the shadow projection scale against the optimal computed one.
  44033. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44034. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44035. */
  44036. /**
  44037. * Sets the shadow projection scale against the optimal computed one.
  44038. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44039. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44040. */
  44041. shadowOrthoScale: number;
  44042. /**
  44043. * Automatically compute the projection matrix to best fit (including all the casters)
  44044. * on each frame.
  44045. */
  44046. autoUpdateExtends: boolean;
  44047. private _orthoLeft;
  44048. private _orthoRight;
  44049. private _orthoTop;
  44050. private _orthoBottom;
  44051. /**
  44052. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44053. * The directional light is emitted from everywhere in the given direction.
  44054. * It can cast shadows.
  44055. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44056. * @param name The friendly name of the light
  44057. * @param direction The direction of the light
  44058. * @param scene The scene the light belongs to
  44059. */
  44060. constructor(name: string, direction: Vector3, scene: Scene);
  44061. /**
  44062. * Returns the string "DirectionalLight".
  44063. * @return The class name
  44064. */
  44065. getClassName(): string;
  44066. /**
  44067. * Returns the integer 1.
  44068. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44069. */
  44070. getTypeID(): number;
  44071. /**
  44072. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44073. * Returns the DirectionalLight Shadow projection matrix.
  44074. */
  44075. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44076. /**
  44077. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44078. * Returns the DirectionalLight Shadow projection matrix.
  44079. */
  44080. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44081. /**
  44082. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44083. * Returns the DirectionalLight Shadow projection matrix.
  44084. */
  44085. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44086. protected _buildUniformLayout(): void;
  44087. /**
  44088. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44089. * @param effect The effect to update
  44090. * @param lightIndex The index of the light in the effect to update
  44091. * @returns The directional light
  44092. */
  44093. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44094. /**
  44095. * Gets the minZ used for shadow according to both the scene and the light.
  44096. *
  44097. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44098. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44099. * @param activeCamera The camera we are returning the min for
  44100. * @returns the depth min z
  44101. */
  44102. getDepthMinZ(activeCamera: Camera): number;
  44103. /**
  44104. * Gets the maxZ used for shadow according to both the scene and the light.
  44105. *
  44106. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44107. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44108. * @param activeCamera The camera we are returning the max for
  44109. * @returns the depth max z
  44110. */
  44111. getDepthMaxZ(activeCamera: Camera): number;
  44112. /**
  44113. * Prepares the list of defines specific to the light type.
  44114. * @param defines the list of defines
  44115. * @param lightIndex defines the index of the light for the effect
  44116. */
  44117. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44118. }
  44119. }
  44120. declare module BABYLON {
  44121. /**
  44122. * A point light is a light defined by an unique point in world space.
  44123. * The light is emitted in every direction from this point.
  44124. * A good example of a point light is a standard light bulb.
  44125. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44126. */
  44127. export class PointLight extends ShadowLight {
  44128. private _shadowAngle;
  44129. /**
  44130. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44131. * This specifies what angle the shadow will use to be created.
  44132. *
  44133. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  44134. */
  44135. /**
  44136. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44137. * This specifies what angle the shadow will use to be created.
  44138. *
  44139. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  44140. */
  44141. shadowAngle: number;
  44142. /**
  44143. * Gets the direction if it has been set.
  44144. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44145. */
  44146. /**
  44147. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44148. */
  44149. direction: Vector3;
  44150. /**
  44151. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  44152. * A PointLight emits the light in every direction.
  44153. * It can cast shadows.
  44154. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  44155. * ```javascript
  44156. * var pointLight = new PointLight("pl", camera.position, scene);
  44157. * ```
  44158. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44159. * @param name The light friendly name
  44160. * @param position The position of the point light in the scene
  44161. * @param scene The scene the lights belongs to
  44162. */
  44163. constructor(name: string, position: Vector3, scene: Scene);
  44164. /**
  44165. * Returns the string "PointLight"
  44166. * @returns the class name
  44167. */
  44168. getClassName(): string;
  44169. /**
  44170. * Returns the integer 0.
  44171. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44172. */
  44173. getTypeID(): number;
  44174. /**
  44175. * Specifies wether or not the shadowmap should be a cube texture.
  44176. * @returns true if the shadowmap needs to be a cube texture.
  44177. */
  44178. needCube(): boolean;
  44179. /**
  44180. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  44181. * @param faceIndex The index of the face we are computed the direction to generate shadow
  44182. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  44183. */
  44184. getShadowDirection(faceIndex?: number): Vector3;
  44185. /**
  44186. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  44187. * - fov = PI / 2
  44188. * - aspect ratio : 1.0
  44189. * - z-near and far equal to the active camera minZ and maxZ.
  44190. * Returns the PointLight.
  44191. */
  44192. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44193. protected _buildUniformLayout(): void;
  44194. /**
  44195. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  44196. * @param effect The effect to update
  44197. * @param lightIndex The index of the light in the effect to update
  44198. * @returns The point light
  44199. */
  44200. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  44201. /**
  44202. * Prepares the list of defines specific to the light type.
  44203. * @param defines the list of defines
  44204. * @param lightIndex defines the index of the light for the effect
  44205. */
  44206. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44207. }
  44208. }
  44209. declare module BABYLON {
  44210. /**
  44211. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44212. * These values define a cone of light starting from the position, emitting toward the direction.
  44213. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44214. * and the exponent defines the speed of the decay of the light with distance (reach).
  44215. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44216. */
  44217. export class SpotLight extends ShadowLight {
  44218. private _angle;
  44219. private _innerAngle;
  44220. private _cosHalfAngle;
  44221. private _lightAngleScale;
  44222. private _lightAngleOffset;
  44223. /**
  44224. * Gets the cone angle of the spot light in Radians.
  44225. */
  44226. /**
  44227. * Sets the cone angle of the spot light in Radians.
  44228. */
  44229. angle: number;
  44230. /**
  44231. * Only used in gltf falloff mode, this defines the angle where
  44232. * the directional falloff will start before cutting at angle which could be seen
  44233. * as outer angle.
  44234. */
  44235. /**
  44236. * Only used in gltf falloff mode, this defines the angle where
  44237. * the directional falloff will start before cutting at angle which could be seen
  44238. * as outer angle.
  44239. */
  44240. innerAngle: number;
  44241. private _shadowAngleScale;
  44242. /**
  44243. * Allows scaling the angle of the light for shadow generation only.
  44244. */
  44245. /**
  44246. * Allows scaling the angle of the light for shadow generation only.
  44247. */
  44248. shadowAngleScale: number;
  44249. /**
  44250. * The light decay speed with the distance from the emission spot.
  44251. */
  44252. exponent: number;
  44253. private _projectionTextureMatrix;
  44254. /**
  44255. * Allows reading the projecton texture
  44256. */
  44257. readonly projectionTextureMatrix: Matrix;
  44258. protected _projectionTextureLightNear: number;
  44259. /**
  44260. * Gets the near clip of the Spotlight for texture projection.
  44261. */
  44262. /**
  44263. * Sets the near clip of the Spotlight for texture projection.
  44264. */
  44265. projectionTextureLightNear: number;
  44266. protected _projectionTextureLightFar: number;
  44267. /**
  44268. * Gets the far clip of the Spotlight for texture projection.
  44269. */
  44270. /**
  44271. * Sets the far clip of the Spotlight for texture projection.
  44272. */
  44273. projectionTextureLightFar: number;
  44274. protected _projectionTextureUpDirection: Vector3;
  44275. /**
  44276. * Gets the Up vector of the Spotlight for texture projection.
  44277. */
  44278. /**
  44279. * Sets the Up vector of the Spotlight for texture projection.
  44280. */
  44281. projectionTextureUpDirection: Vector3;
  44282. private _projectionTexture;
  44283. /**
  44284. * Gets the projection texture of the light.
  44285. */
  44286. /**
  44287. * Sets the projection texture of the light.
  44288. */
  44289. projectionTexture: Nullable<BaseTexture>;
  44290. private _projectionTextureViewLightDirty;
  44291. private _projectionTextureProjectionLightDirty;
  44292. private _projectionTextureDirty;
  44293. private _projectionTextureViewTargetVector;
  44294. private _projectionTextureViewLightMatrix;
  44295. private _projectionTextureProjectionLightMatrix;
  44296. private _projectionTextureScalingMatrix;
  44297. /**
  44298. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44299. * It can cast shadows.
  44300. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44301. * @param name The light friendly name
  44302. * @param position The position of the spot light in the scene
  44303. * @param direction The direction of the light in the scene
  44304. * @param angle The cone angle of the light in Radians
  44305. * @param exponent The light decay speed with the distance from the emission spot
  44306. * @param scene The scene the lights belongs to
  44307. */
  44308. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44309. /**
  44310. * Returns the string "SpotLight".
  44311. * @returns the class name
  44312. */
  44313. getClassName(): string;
  44314. /**
  44315. * Returns the integer 2.
  44316. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44317. */
  44318. getTypeID(): number;
  44319. /**
  44320. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44321. */
  44322. protected _setDirection(value: Vector3): void;
  44323. /**
  44324. * Overrides the position setter to recompute the projection texture view light Matrix.
  44325. */
  44326. protected _setPosition(value: Vector3): void;
  44327. /**
  44328. * 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.
  44329. * Returns the SpotLight.
  44330. */
  44331. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44332. protected _computeProjectionTextureViewLightMatrix(): void;
  44333. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44334. /**
  44335. * Main function for light texture projection matrix computing.
  44336. */
  44337. protected _computeProjectionTextureMatrix(): void;
  44338. protected _buildUniformLayout(): void;
  44339. private _computeAngleValues;
  44340. /**
  44341. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44342. * @param effect The effect to update
  44343. * @param lightIndex The index of the light in the effect to update
  44344. * @returns The spot light
  44345. */
  44346. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44347. /**
  44348. * Disposes the light and the associated resources.
  44349. */
  44350. dispose(): void;
  44351. /**
  44352. * Prepares the list of defines specific to the light type.
  44353. * @param defines the list of defines
  44354. * @param lightIndex defines the index of the light for the effect
  44355. */
  44356. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44357. }
  44358. }
  44359. declare module BABYLON {
  44360. /**
  44361. * Header information of HDR texture files.
  44362. */
  44363. export interface HDRInfo {
  44364. /**
  44365. * The height of the texture in pixels.
  44366. */
  44367. height: number;
  44368. /**
  44369. * The width of the texture in pixels.
  44370. */
  44371. width: number;
  44372. /**
  44373. * The index of the beginning of the data in the binary file.
  44374. */
  44375. dataPosition: number;
  44376. }
  44377. /**
  44378. * This groups tools to convert HDR texture to native colors array.
  44379. */
  44380. export class HDRTools {
  44381. private static Ldexp;
  44382. private static Rgbe2float;
  44383. private static readStringLine;
  44384. /**
  44385. * Reads header information from an RGBE texture stored in a native array.
  44386. * More information on this format are available here:
  44387. * https://en.wikipedia.org/wiki/RGBE_image_format
  44388. *
  44389. * @param uint8array The binary file stored in native array.
  44390. * @return The header information.
  44391. */
  44392. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  44393. /**
  44394. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  44395. * This RGBE texture needs to store the information as a panorama.
  44396. *
  44397. * More information on this format are available here:
  44398. * https://en.wikipedia.org/wiki/RGBE_image_format
  44399. *
  44400. * @param buffer The binary file stored in an array buffer.
  44401. * @param size The expected size of the extracted cubemap.
  44402. * @return The Cube Map information.
  44403. */
  44404. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  44405. /**
  44406. * Returns the pixels data extracted from an RGBE texture.
  44407. * This pixels will be stored left to right up to down in the R G B order in one array.
  44408. *
  44409. * More information on this format are available here:
  44410. * https://en.wikipedia.org/wiki/RGBE_image_format
  44411. *
  44412. * @param uint8array The binary file stored in an array buffer.
  44413. * @param hdrInfo The header information of the file.
  44414. * @return The pixels data in RGB right to left up to down order.
  44415. */
  44416. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  44417. private static RGBE_ReadPixels_RLE;
  44418. }
  44419. }
  44420. declare module BABYLON {
  44421. /**
  44422. * This represents a texture coming from an HDR input.
  44423. *
  44424. * The only supported format is currently panorama picture stored in RGBE format.
  44425. * Example of such files can be found on HDRLib: http://hdrlib.com/
  44426. */
  44427. export class HDRCubeTexture extends BaseTexture {
  44428. private static _facesMapping;
  44429. private _generateHarmonics;
  44430. private _noMipmap;
  44431. private _textureMatrix;
  44432. private _size;
  44433. private _onLoad;
  44434. private _onError;
  44435. /**
  44436. * The texture URL.
  44437. */
  44438. url: string;
  44439. /**
  44440. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  44441. */
  44442. coordinatesMode: number;
  44443. protected _isBlocking: boolean;
  44444. /**
  44445. * Sets wether or not the texture is blocking during loading.
  44446. */
  44447. /**
  44448. * Gets wether or not the texture is blocking during loading.
  44449. */
  44450. isBlocking: boolean;
  44451. protected _rotationY: number;
  44452. /**
  44453. * Sets texture matrix rotation angle around Y axis in radians.
  44454. */
  44455. /**
  44456. * Gets texture matrix rotation angle around Y axis radians.
  44457. */
  44458. rotationY: number;
  44459. /**
  44460. * Gets or sets the center of the bounding box associated with the cube texture
  44461. * It must define where the camera used to render the texture was set
  44462. */
  44463. boundingBoxPosition: Vector3;
  44464. private _boundingBoxSize;
  44465. /**
  44466. * Gets or sets the size of the bounding box associated with the cube texture
  44467. * When defined, the cubemap will switch to local mode
  44468. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  44469. * @example https://www.babylonjs-playground.com/#RNASML
  44470. */
  44471. boundingBoxSize: Vector3;
  44472. /**
  44473. * Instantiates an HDRTexture from the following parameters.
  44474. *
  44475. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  44476. * @param scene The scene the texture will be used in
  44477. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  44478. * @param noMipmap Forces to not generate the mipmap if true
  44479. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  44480. * @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)
  44481. * @param reserved Reserved flag for internal use.
  44482. */
  44483. 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>);
  44484. /**
  44485. * Get the current class name of the texture useful for serialization or dynamic coding.
  44486. * @returns "HDRCubeTexture"
  44487. */
  44488. getClassName(): string;
  44489. /**
  44490. * Occurs when the file is raw .hdr file.
  44491. */
  44492. private loadTexture;
  44493. clone(): HDRCubeTexture;
  44494. delayLoad(): void;
  44495. /**
  44496. * Get the texture reflection matrix used to rotate/transform the reflection.
  44497. * @returns the reflection matrix
  44498. */
  44499. getReflectionTextureMatrix(): Matrix;
  44500. /**
  44501. * Set the texture reflection matrix used to rotate/transform the reflection.
  44502. * @param value Define the reflection matrix to set
  44503. */
  44504. setReflectionTextureMatrix(value: Matrix): void;
  44505. /**
  44506. * Parses a JSON representation of an HDR Texture in order to create the texture
  44507. * @param parsedTexture Define the JSON representation
  44508. * @param scene Define the scene the texture should be created in
  44509. * @param rootUrl Define the root url in case we need to load relative dependencies
  44510. * @returns the newly created texture after parsing
  44511. */
  44512. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  44513. serialize(): any;
  44514. }
  44515. }
  44516. declare module BABYLON {
  44517. /**
  44518. * Class used to control physics engine
  44519. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  44520. */
  44521. export class PhysicsEngine implements IPhysicsEngine {
  44522. private _physicsPlugin;
  44523. /**
  44524. * Global value used to control the smallest number supported by the simulation
  44525. */
  44526. static Epsilon: number;
  44527. private _impostors;
  44528. private _joints;
  44529. /**
  44530. * Gets the gravity vector used by the simulation
  44531. */
  44532. gravity: Vector3;
  44533. /**
  44534. * Factory used to create the default physics plugin.
  44535. * @returns The default physics plugin
  44536. */
  44537. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  44538. /**
  44539. * Creates a new Physics Engine
  44540. * @param gravity defines the gravity vector used by the simulation
  44541. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  44542. */
  44543. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  44544. /**
  44545. * Sets the gravity vector used by the simulation
  44546. * @param gravity defines the gravity vector to use
  44547. */
  44548. setGravity(gravity: Vector3): void;
  44549. /**
  44550. * Set the time step of the physics engine.
  44551. * Default is 1/60.
  44552. * To slow it down, enter 1/600 for example.
  44553. * To speed it up, 1/30
  44554. * @param newTimeStep defines the new timestep to apply to this world.
  44555. */
  44556. setTimeStep(newTimeStep?: number): void;
  44557. /**
  44558. * Get the time step of the physics engine.
  44559. * @returns the current time step
  44560. */
  44561. getTimeStep(): number;
  44562. /**
  44563. * Release all resources
  44564. */
  44565. dispose(): void;
  44566. /**
  44567. * Gets the name of the current physics plugin
  44568. * @returns the name of the plugin
  44569. */
  44570. getPhysicsPluginName(): string;
  44571. /**
  44572. * Adding a new impostor for the impostor tracking.
  44573. * This will be done by the impostor itself.
  44574. * @param impostor the impostor to add
  44575. */
  44576. addImpostor(impostor: PhysicsImpostor): void;
  44577. /**
  44578. * Remove an impostor from the engine.
  44579. * This impostor and its mesh will not longer be updated by the physics engine.
  44580. * @param impostor the impostor to remove
  44581. */
  44582. removeImpostor(impostor: PhysicsImpostor): void;
  44583. /**
  44584. * Add a joint to the physics engine
  44585. * @param mainImpostor defines the main impostor to which the joint is added.
  44586. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  44587. * @param joint defines the joint that will connect both impostors.
  44588. */
  44589. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  44590. /**
  44591. * Removes a joint from the simulation
  44592. * @param mainImpostor defines the impostor used with the joint
  44593. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  44594. * @param joint defines the joint to remove
  44595. */
  44596. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  44597. /**
  44598. * Called by the scene. No need to call it.
  44599. * @param delta defines the timespam between frames
  44600. */ step(delta: number): void;
  44601. /**
  44602. * Gets the current plugin used to run the simulation
  44603. * @returns current plugin
  44604. */
  44605. getPhysicsPlugin(): IPhysicsEnginePlugin;
  44606. /**
  44607. * Gets the list of physic impostors
  44608. * @returns an array of PhysicsImpostor
  44609. */
  44610. getImpostors(): Array<PhysicsImpostor>;
  44611. /**
  44612. * Gets the impostor for a physics enabled object
  44613. * @param object defines the object impersonated by the impostor
  44614. * @returns the PhysicsImpostor or null if not found
  44615. */
  44616. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  44617. /**
  44618. * Gets the impostor for a physics body object
  44619. * @param body defines physics body used by the impostor
  44620. * @returns the PhysicsImpostor or null if not found
  44621. */
  44622. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  44623. }
  44624. }
  44625. declare module BABYLON {
  44626. /** @hidden */
  44627. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  44628. private _useDeltaForWorldStep;
  44629. world: any;
  44630. name: string;
  44631. private _physicsMaterials;
  44632. private _fixedTimeStep;
  44633. BJSCANNON: any;
  44634. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  44635. setGravity(gravity: Vector3): void;
  44636. setTimeStep(timeStep: number): void;
  44637. getTimeStep(): number;
  44638. executeStep(delta: number): void;
  44639. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  44640. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  44641. generatePhysicsBody(impostor: PhysicsImpostor): void;
  44642. private _processChildMeshes;
  44643. removePhysicsBody(impostor: PhysicsImpostor): void;
  44644. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  44645. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  44646. private _addMaterial;
  44647. private _checkWithEpsilon;
  44648. private _createShape;
  44649. private _createHeightmap;
  44650. private _minus90X;
  44651. private _plus90X;
  44652. private _tmpPosition;
  44653. private _tmpDeltaPosition;
  44654. private _tmpUnityRotation;
  44655. private _updatePhysicsBodyTransformation;
  44656. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  44657. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  44658. isSupported(): boolean;
  44659. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  44660. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  44661. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  44662. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  44663. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  44664. getBodyMass(impostor: PhysicsImpostor): number;
  44665. getBodyFriction(impostor: PhysicsImpostor): number;
  44666. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  44667. getBodyRestitution(impostor: PhysicsImpostor): number;
  44668. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  44669. sleepBody(impostor: PhysicsImpostor): void;
  44670. wakeUpBody(impostor: PhysicsImpostor): void;
  44671. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  44672. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  44673. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  44674. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  44675. getRadius(impostor: PhysicsImpostor): number;
  44676. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  44677. dispose(): void;
  44678. private _extendNamespace;
  44679. }
  44680. }
  44681. declare module BABYLON {
  44682. /** @hidden */
  44683. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  44684. world: any;
  44685. name: string;
  44686. BJSOIMO: any;
  44687. constructor(iterations?: number, oimoInjection?: any);
  44688. setGravity(gravity: Vector3): void;
  44689. setTimeStep(timeStep: number): void;
  44690. getTimeStep(): number;
  44691. private _tmpImpostorsArray;
  44692. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  44693. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  44694. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  44695. generatePhysicsBody(impostor: PhysicsImpostor): void;
  44696. private _tmpPositionVector;
  44697. removePhysicsBody(impostor: PhysicsImpostor): void;
  44698. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  44699. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  44700. isSupported(): boolean;
  44701. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  44702. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  44703. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  44704. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  44705. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  44706. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  44707. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  44708. getBodyMass(impostor: PhysicsImpostor): number;
  44709. getBodyFriction(impostor: PhysicsImpostor): number;
  44710. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  44711. getBodyRestitution(impostor: PhysicsImpostor): number;
  44712. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  44713. sleepBody(impostor: PhysicsImpostor): void;
  44714. wakeUpBody(impostor: PhysicsImpostor): void;
  44715. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  44716. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  44717. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  44718. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  44719. getRadius(impostor: PhysicsImpostor): number;
  44720. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  44721. dispose(): void;
  44722. }
  44723. }
  44724. declare module BABYLON {
  44725. interface AbstractScene {
  44726. /**
  44727. * The list of reflection probes added to the scene
  44728. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  44729. */
  44730. reflectionProbes: Array<ReflectionProbe>;
  44731. /**
  44732. * Removes the given reflection probe from this scene.
  44733. * @param toRemove The reflection probe to remove
  44734. * @returns The index of the removed reflection probe
  44735. */
  44736. removeReflectionProbe(toRemove: ReflectionProbe): number;
  44737. /**
  44738. * Adds the given reflection probe to this scene.
  44739. * @param newReflectionProbe The reflection probe to add
  44740. */
  44741. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  44742. }
  44743. /**
  44744. * Class used to generate realtime reflection / refraction cube textures
  44745. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  44746. */
  44747. export class ReflectionProbe {
  44748. /** defines the name of the probe */
  44749. name: string;
  44750. private _scene;
  44751. private _renderTargetTexture;
  44752. private _projectionMatrix;
  44753. private _viewMatrix;
  44754. private _target;
  44755. private _add;
  44756. private _attachedMesh;
  44757. private _invertYAxis;
  44758. /** Gets or sets probe position (center of the cube map) */
  44759. position: Vector3;
  44760. /**
  44761. * Creates a new reflection probe
  44762. * @param name defines the name of the probe
  44763. * @param size defines the texture resolution (for each face)
  44764. * @param scene defines the hosting scene
  44765. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  44766. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  44767. */
  44768. constructor(
  44769. /** defines the name of the probe */
  44770. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  44771. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  44772. samples: number;
  44773. /** Gets or sets the refresh rate to use (on every frame by default) */
  44774. refreshRate: number;
  44775. /**
  44776. * Gets the hosting scene
  44777. * @returns a Scene
  44778. */
  44779. getScene(): Scene;
  44780. /** Gets the internal CubeTexture used to render to */
  44781. readonly cubeTexture: RenderTargetTexture;
  44782. /** Gets the list of meshes to render */
  44783. readonly renderList: Nullable<AbstractMesh[]>;
  44784. /**
  44785. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  44786. * @param mesh defines the mesh to attach to
  44787. */
  44788. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44789. /**
  44790. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  44791. * @param renderingGroupId The rendering group id corresponding to its index
  44792. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44793. */
  44794. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  44795. /**
  44796. * Clean all associated resources
  44797. */
  44798. dispose(): void;
  44799. /**
  44800. * Converts the reflection probe information to a readable string for debug purpose.
  44801. * @param fullDetails Supports for multiple levels of logging within scene loading
  44802. * @returns the human readable reflection probe info
  44803. */
  44804. toString(fullDetails?: boolean): string;
  44805. /**
  44806. * Get the class name of the relfection probe.
  44807. * @returns "ReflectionProbe"
  44808. */
  44809. getClassName(): string;
  44810. /**
  44811. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  44812. * @returns The JSON representation of the texture
  44813. */
  44814. serialize(): any;
  44815. /**
  44816. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  44817. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  44818. * @param scene Define the scene the parsed reflection probe should be instantiated in
  44819. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  44820. * @returns The parsed reflection probe if successful
  44821. */
  44822. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  44823. }
  44824. }
  44825. declare module BABYLON {
  44826. /** @hidden */
  44827. export var _BabylonLoaderRegistered: boolean;
  44828. }
  44829. declare module BABYLON {
  44830. /**
  44831. * The Physically based simple base material of BJS.
  44832. *
  44833. * This enables better naming and convention enforcements on top of the pbrMaterial.
  44834. * It is used as the base class for both the specGloss and metalRough conventions.
  44835. */
  44836. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  44837. /**
  44838. * Number of Simultaneous lights allowed on the material.
  44839. */
  44840. maxSimultaneousLights: number;
  44841. /**
  44842. * If sets to true, disables all the lights affecting the material.
  44843. */
  44844. disableLighting: boolean;
  44845. /**
  44846. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  44847. */
  44848. environmentTexture: BaseTexture;
  44849. /**
  44850. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44851. */
  44852. invertNormalMapX: boolean;
  44853. /**
  44854. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44855. */
  44856. invertNormalMapY: boolean;
  44857. /**
  44858. * Normal map used in the model.
  44859. */
  44860. normalTexture: BaseTexture;
  44861. /**
  44862. * Emissivie color used to self-illuminate the model.
  44863. */
  44864. emissiveColor: Color3;
  44865. /**
  44866. * Emissivie texture used to self-illuminate the model.
  44867. */
  44868. emissiveTexture: BaseTexture;
  44869. /**
  44870. * Occlusion Channel Strenght.
  44871. */
  44872. occlusionStrength: number;
  44873. /**
  44874. * Occlusion Texture of the material (adding extra occlusion effects).
  44875. */
  44876. occlusionTexture: BaseTexture;
  44877. /**
  44878. * Defines the alpha limits in alpha test mode.
  44879. */
  44880. alphaCutOff: number;
  44881. /**
  44882. * Gets the current double sided mode.
  44883. */
  44884. /**
  44885. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44886. */
  44887. doubleSided: boolean;
  44888. /**
  44889. * Stores the pre-calculated light information of a mesh in a texture.
  44890. */
  44891. lightmapTexture: BaseTexture;
  44892. /**
  44893. * If true, the light map contains occlusion information instead of lighting info.
  44894. */
  44895. useLightmapAsShadowmap: boolean;
  44896. /**
  44897. * Return the active textures of the material.
  44898. */
  44899. getActiveTextures(): BaseTexture[];
  44900. hasTexture(texture: BaseTexture): boolean;
  44901. /**
  44902. * Instantiates a new PBRMaterial instance.
  44903. *
  44904. * @param name The material name
  44905. * @param scene The scene the material will be use in.
  44906. */
  44907. constructor(name: string, scene: Scene);
  44908. getClassName(): string;
  44909. }
  44910. }
  44911. declare module BABYLON {
  44912. /**
  44913. * The PBR material of BJS following the metal roughness convention.
  44914. *
  44915. * This fits to the PBR convention in the GLTF definition:
  44916. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  44917. */
  44918. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  44919. /**
  44920. * The base color has two different interpretations depending on the value of metalness.
  44921. * When the material is a metal, the base color is the specific measured reflectance value
  44922. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  44923. * of the material.
  44924. */
  44925. baseColor: Color3;
  44926. /**
  44927. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  44928. * well as opacity information in the alpha channel.
  44929. */
  44930. baseTexture: BaseTexture;
  44931. /**
  44932. * Specifies the metallic scalar value of the material.
  44933. * Can also be used to scale the metalness values of the metallic texture.
  44934. */
  44935. metallic: number;
  44936. /**
  44937. * Specifies the roughness scalar value of the material.
  44938. * Can also be used to scale the roughness values of the metallic texture.
  44939. */
  44940. roughness: number;
  44941. /**
  44942. * Texture containing both the metallic value in the B channel and the
  44943. * roughness value in the G channel to keep better precision.
  44944. */
  44945. metallicRoughnessTexture: BaseTexture;
  44946. /**
  44947. * Instantiates a new PBRMetalRoughnessMaterial instance.
  44948. *
  44949. * @param name The material name
  44950. * @param scene The scene the material will be use in.
  44951. */
  44952. constructor(name: string, scene: Scene);
  44953. /**
  44954. * Return the currrent class name of the material.
  44955. */
  44956. getClassName(): string;
  44957. /**
  44958. * Return the active textures of the material.
  44959. */
  44960. getActiveTextures(): BaseTexture[];
  44961. /**
  44962. * Checks to see if a texture is used in the material.
  44963. * @param texture - Base texture to use.
  44964. * @returns - Boolean specifying if a texture is used in the material.
  44965. */
  44966. hasTexture(texture: BaseTexture): boolean;
  44967. /**
  44968. * Makes a duplicate of the current material.
  44969. * @param name - name to use for the new material.
  44970. */
  44971. clone(name: string): PBRMetallicRoughnessMaterial;
  44972. /**
  44973. * Serialize the material to a parsable JSON object.
  44974. */
  44975. serialize(): any;
  44976. /**
  44977. * Parses a JSON object correponding to the serialize function.
  44978. */
  44979. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  44980. }
  44981. }
  44982. declare module BABYLON {
  44983. /**
  44984. * The PBR material of BJS following the specular glossiness convention.
  44985. *
  44986. * This fits to the PBR convention in the GLTF definition:
  44987. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  44988. */
  44989. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  44990. /**
  44991. * Specifies the diffuse color of the material.
  44992. */
  44993. diffuseColor: Color3;
  44994. /**
  44995. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  44996. * channel.
  44997. */
  44998. diffuseTexture: BaseTexture;
  44999. /**
  45000. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  45001. */
  45002. specularColor: Color3;
  45003. /**
  45004. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  45005. */
  45006. glossiness: number;
  45007. /**
  45008. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  45009. */
  45010. specularGlossinessTexture: BaseTexture;
  45011. /**
  45012. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  45013. *
  45014. * @param name The material name
  45015. * @param scene The scene the material will be use in.
  45016. */
  45017. constructor(name: string, scene: Scene);
  45018. /**
  45019. * Return the currrent class name of the material.
  45020. */
  45021. getClassName(): string;
  45022. /**
  45023. * Return the active textures of the material.
  45024. */
  45025. getActiveTextures(): BaseTexture[];
  45026. /**
  45027. * Checks to see if a texture is used in the material.
  45028. * @param texture - Base texture to use.
  45029. * @returns - Boolean specifying if a texture is used in the material.
  45030. */
  45031. hasTexture(texture: BaseTexture): boolean;
  45032. /**
  45033. * Makes a duplicate of the current material.
  45034. * @param name - name to use for the new material.
  45035. */
  45036. clone(name: string): PBRSpecularGlossinessMaterial;
  45037. /**
  45038. * Serialize the material to a parsable JSON object.
  45039. */
  45040. serialize(): any;
  45041. /**
  45042. * Parses a JSON object correponding to the serialize function.
  45043. */
  45044. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  45045. }
  45046. }
  45047. declare module BABYLON {
  45048. /**
  45049. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  45050. * It can help converting any input color in a desired output one. This can then be used to create effects
  45051. * from sepia, black and white to sixties or futuristic rendering...
  45052. *
  45053. * The only supported format is currently 3dl.
  45054. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  45055. */
  45056. export class ColorGradingTexture extends BaseTexture {
  45057. /**
  45058. * The current texture matrix. (will always be identity in color grading texture)
  45059. */
  45060. private _textureMatrix;
  45061. /**
  45062. * The texture URL.
  45063. */
  45064. url: string;
  45065. /**
  45066. * Empty line regex stored for GC.
  45067. */
  45068. private static _noneEmptyLineRegex;
  45069. private _engine;
  45070. /**
  45071. * Instantiates a ColorGradingTexture from the following parameters.
  45072. *
  45073. * @param url The location of the color gradind data (currently only supporting 3dl)
  45074. * @param scene The scene the texture will be used in
  45075. */
  45076. constructor(url: string, scene: Scene);
  45077. /**
  45078. * Returns the texture matrix used in most of the material.
  45079. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  45080. */
  45081. getTextureMatrix(): Matrix;
  45082. /**
  45083. * Occurs when the file being loaded is a .3dl LUT file.
  45084. */
  45085. private load3dlTexture;
  45086. /**
  45087. * Starts the loading process of the texture.
  45088. */
  45089. private loadTexture;
  45090. /**
  45091. * Clones the color gradind texture.
  45092. */
  45093. clone(): ColorGradingTexture;
  45094. /**
  45095. * Called during delayed load for textures.
  45096. */
  45097. delayLoad(): void;
  45098. /**
  45099. * Parses a color grading texture serialized by Babylon.
  45100. * @param parsedTexture The texture information being parsedTexture
  45101. * @param scene The scene to load the texture in
  45102. * @param rootUrl The root url of the data assets to load
  45103. * @return A color gradind texture
  45104. */
  45105. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  45106. /**
  45107. * Serializes the LUT texture to json format.
  45108. */
  45109. serialize(): any;
  45110. }
  45111. }
  45112. declare module BABYLON {
  45113. /**
  45114. * Direct draw surface info
  45115. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45116. */
  45117. export interface DDSInfo {
  45118. /**
  45119. * Width of the texture
  45120. */
  45121. width: number;
  45122. /**
  45123. * Width of the texture
  45124. */
  45125. height: number;
  45126. /**
  45127. * Number of Mipmaps for the texture
  45128. * @see https://en.wikipedia.org/wiki/Mipmap
  45129. */
  45130. mipmapCount: number;
  45131. /**
  45132. * If the textures format is a known fourCC format
  45133. * @see https://www.fourcc.org/
  45134. */
  45135. isFourCC: boolean;
  45136. /**
  45137. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45138. */
  45139. isRGB: boolean;
  45140. /**
  45141. * If the texture is a lumincance format
  45142. */
  45143. isLuminance: boolean;
  45144. /**
  45145. * If this is a cube texture
  45146. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45147. */
  45148. isCube: boolean;
  45149. /**
  45150. * If the texture is a compressed format eg. FOURCC_DXT1
  45151. */
  45152. isCompressed: boolean;
  45153. /**
  45154. * The dxgiFormat of the texture
  45155. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45156. */
  45157. dxgiFormat: number;
  45158. /**
  45159. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45160. */
  45161. textureType: number;
  45162. /**
  45163. * Sphericle polynomial created for the dds texture
  45164. */
  45165. sphericalPolynomial?: SphericalPolynomial;
  45166. }
  45167. /**
  45168. * Class used to provide DDS decompression tools
  45169. */
  45170. export class DDSTools {
  45171. /**
  45172. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45173. */
  45174. static StoreLODInAlphaChannel: boolean;
  45175. /**
  45176. * Gets DDS information from an array buffer
  45177. * @param arrayBuffer defines the array buffer to read data from
  45178. * @returns the DDS information
  45179. */
  45180. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45181. private static _FloatView;
  45182. private static _Int32View;
  45183. private static _ToHalfFloat;
  45184. private static _FromHalfFloat;
  45185. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45186. private static _GetHalfFloatRGBAArrayBuffer;
  45187. private static _GetFloatRGBAArrayBuffer;
  45188. private static _GetFloatAsUIntRGBAArrayBuffer;
  45189. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45190. private static _GetRGBAArrayBuffer;
  45191. private static _ExtractLongWordOrder;
  45192. private static _GetRGBArrayBuffer;
  45193. private static _GetLuminanceArrayBuffer;
  45194. /**
  45195. * Uploads DDS Levels to a Babylon Texture
  45196. * @hidden
  45197. */
  45198. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45199. }
  45200. interface Engine {
  45201. /**
  45202. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45203. * @param rootUrl defines the url where the file to load is located
  45204. * @param scene defines the current scene
  45205. * @param lodScale defines scale to apply to the mip map selection
  45206. * @param lodOffset defines offset to apply to the mip map selection
  45207. * @param onLoad defines an optional callback raised when the texture is loaded
  45208. * @param onError defines an optional callback raised if there is an issue to load the texture
  45209. * @param format defines the format of the data
  45210. * @param forcedExtension defines the extension to use to pick the right loader
  45211. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45212. * @returns the cube texture as an InternalTexture
  45213. */
  45214. 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;
  45215. }
  45216. }
  45217. declare module BABYLON {
  45218. /**
  45219. * Implementation of the DDS Texture Loader.
  45220. * @hidden
  45221. */
  45222. export class _DDSTextureLoader implements IInternalTextureLoader {
  45223. /**
  45224. * Defines wether the loader supports cascade loading the different faces.
  45225. */
  45226. readonly supportCascades: boolean;
  45227. /**
  45228. * This returns if the loader support the current file information.
  45229. * @param extension defines the file extension of the file being loaded
  45230. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45231. * @param fallback defines the fallback internal texture if any
  45232. * @param isBase64 defines whether the texture is encoded as a base64
  45233. * @param isBuffer defines whether the texture data are stored as a buffer
  45234. * @returns true if the loader can load the specified file
  45235. */
  45236. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45237. /**
  45238. * Transform the url before loading if required.
  45239. * @param rootUrl the url of the texture
  45240. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45241. * @returns the transformed texture
  45242. */
  45243. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45244. /**
  45245. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45246. * @param rootUrl the url of the texture
  45247. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45248. * @returns the fallback texture
  45249. */
  45250. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45251. /**
  45252. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45253. * @param data contains the texture data
  45254. * @param texture defines the BabylonJS internal texture
  45255. * @param createPolynomials will be true if polynomials have been requested
  45256. * @param onLoad defines the callback to trigger once the texture is ready
  45257. * @param onError defines the callback to trigger in case of error
  45258. */
  45259. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45260. /**
  45261. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45262. * @param data contains the texture data
  45263. * @param texture defines the BabylonJS internal texture
  45264. * @param callback defines the method to call once ready to upload
  45265. */
  45266. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45267. }
  45268. }
  45269. declare module BABYLON {
  45270. /** @hidden */
  45271. export var rgbdEncodePixelShader: {
  45272. name: string;
  45273. shader: string;
  45274. };
  45275. }
  45276. declare module BABYLON {
  45277. /** @hidden */
  45278. export var rgbdDecodePixelShader: {
  45279. name: string;
  45280. shader: string;
  45281. };
  45282. }
  45283. declare module BABYLON {
  45284. /**
  45285. * Raw texture data and descriptor sufficient for WebGL texture upload
  45286. */
  45287. export interface EnvironmentTextureInfo {
  45288. /**
  45289. * Version of the environment map
  45290. */
  45291. version: number;
  45292. /**
  45293. * Width of image
  45294. */
  45295. width: number;
  45296. /**
  45297. * Irradiance information stored in the file.
  45298. */
  45299. irradiance: any;
  45300. /**
  45301. * Specular information stored in the file.
  45302. */
  45303. specular: any;
  45304. }
  45305. /**
  45306. * Sets of helpers addressing the serialization and deserialization of environment texture
  45307. * stored in a BabylonJS env file.
  45308. * Those files are usually stored as .env files.
  45309. */
  45310. export class EnvironmentTextureTools {
  45311. /**
  45312. * Magic number identifying the env file.
  45313. */
  45314. private static _MagicBytes;
  45315. /**
  45316. * Gets the environment info from an env file.
  45317. * @param data The array buffer containing the .env bytes.
  45318. * @returns the environment file info (the json header) if successfully parsed.
  45319. */
  45320. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45321. /**
  45322. * Creates an environment texture from a loaded cube texture.
  45323. * @param texture defines the cube texture to convert in env file
  45324. * @return a promise containing the environment data if succesfull.
  45325. */
  45326. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45327. /**
  45328. * Creates a JSON representation of the spherical data.
  45329. * @param texture defines the texture containing the polynomials
  45330. * @return the JSON representation of the spherical info
  45331. */
  45332. private static _CreateEnvTextureIrradiance;
  45333. /**
  45334. * Uploads the texture info contained in the env file to the GPU.
  45335. * @param texture defines the internal texture to upload to
  45336. * @param arrayBuffer defines the buffer cotaining the data to load
  45337. * @param info defines the texture info retrieved through the GetEnvInfo method
  45338. * @returns a promise
  45339. */
  45340. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45341. /**
  45342. * Uploads the levels of image data to the GPU.
  45343. * @param texture defines the internal texture to upload to
  45344. * @param imageData defines the array buffer views of image data [mipmap][face]
  45345. * @returns a promise
  45346. */
  45347. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45348. /**
  45349. * Uploads spherical polynomials information to the texture.
  45350. * @param texture defines the texture we are trying to upload the information to
  45351. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45352. */
  45353. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45354. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45355. }
  45356. }
  45357. declare module BABYLON {
  45358. /**
  45359. * Implementation of the ENV Texture Loader.
  45360. * @hidden
  45361. */
  45362. export class _ENVTextureLoader implements IInternalTextureLoader {
  45363. /**
  45364. * Defines wether the loader supports cascade loading the different faces.
  45365. */
  45366. readonly supportCascades: boolean;
  45367. /**
  45368. * This returns if the loader support the current file information.
  45369. * @param extension defines the file extension of the file being loaded
  45370. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45371. * @param fallback defines the fallback internal texture if any
  45372. * @param isBase64 defines whether the texture is encoded as a base64
  45373. * @param isBuffer defines whether the texture data are stored as a buffer
  45374. * @returns true if the loader can load the specified file
  45375. */
  45376. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45377. /**
  45378. * Transform the url before loading if required.
  45379. * @param rootUrl the url of the texture
  45380. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45381. * @returns the transformed texture
  45382. */
  45383. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45384. /**
  45385. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45386. * @param rootUrl the url of the texture
  45387. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45388. * @returns the fallback texture
  45389. */
  45390. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45391. /**
  45392. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45393. * @param data contains the texture data
  45394. * @param texture defines the BabylonJS internal texture
  45395. * @param createPolynomials will be true if polynomials have been requested
  45396. * @param onLoad defines the callback to trigger once the texture is ready
  45397. * @param onError defines the callback to trigger in case of error
  45398. */
  45399. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45400. /**
  45401. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45402. * @param data contains the texture data
  45403. * @param texture defines the BabylonJS internal texture
  45404. * @param callback defines the method to call once ready to upload
  45405. */
  45406. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45407. }
  45408. }
  45409. declare module BABYLON {
  45410. /**
  45411. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45412. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45413. */
  45414. export class KhronosTextureContainer {
  45415. /** contents of the KTX container file */
  45416. arrayBuffer: any;
  45417. private static HEADER_LEN;
  45418. private static COMPRESSED_2D;
  45419. private static COMPRESSED_3D;
  45420. private static TEX_2D;
  45421. private static TEX_3D;
  45422. /**
  45423. * Gets the openGL type
  45424. */
  45425. glType: number;
  45426. /**
  45427. * Gets the openGL type size
  45428. */
  45429. glTypeSize: number;
  45430. /**
  45431. * Gets the openGL format
  45432. */
  45433. glFormat: number;
  45434. /**
  45435. * Gets the openGL internal format
  45436. */
  45437. glInternalFormat: number;
  45438. /**
  45439. * Gets the base internal format
  45440. */
  45441. glBaseInternalFormat: number;
  45442. /**
  45443. * Gets image width in pixel
  45444. */
  45445. pixelWidth: number;
  45446. /**
  45447. * Gets image height in pixel
  45448. */
  45449. pixelHeight: number;
  45450. /**
  45451. * Gets image depth in pixels
  45452. */
  45453. pixelDepth: number;
  45454. /**
  45455. * Gets the number of array elements
  45456. */
  45457. numberOfArrayElements: number;
  45458. /**
  45459. * Gets the number of faces
  45460. */
  45461. numberOfFaces: number;
  45462. /**
  45463. * Gets the number of mipmap levels
  45464. */
  45465. numberOfMipmapLevels: number;
  45466. /**
  45467. * Gets the bytes of key value data
  45468. */
  45469. bytesOfKeyValueData: number;
  45470. /**
  45471. * Gets the load type
  45472. */
  45473. loadType: number;
  45474. /**
  45475. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45476. */
  45477. isInvalid: boolean;
  45478. /**
  45479. * Creates a new KhronosTextureContainer
  45480. * @param arrayBuffer contents of the KTX container file
  45481. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45482. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45483. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45484. */
  45485. constructor(
  45486. /** contents of the KTX container file */
  45487. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45488. /**
  45489. * Uploads KTX content to a Babylon Texture.
  45490. * It is assumed that the texture has already been created & is currently bound
  45491. * @hidden
  45492. */
  45493. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45494. private _upload2DCompressedLevels;
  45495. }
  45496. }
  45497. declare module BABYLON {
  45498. /**
  45499. * Implementation of the KTX Texture Loader.
  45500. * @hidden
  45501. */
  45502. export class _KTXTextureLoader implements IInternalTextureLoader {
  45503. /**
  45504. * Defines wether the loader supports cascade loading the different faces.
  45505. */
  45506. readonly supportCascades: boolean;
  45507. /**
  45508. * This returns if the loader support the current file information.
  45509. * @param extension defines the file extension of the file being loaded
  45510. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45511. * @param fallback defines the fallback internal texture if any
  45512. * @param isBase64 defines whether the texture is encoded as a base64
  45513. * @param isBuffer defines whether the texture data are stored as a buffer
  45514. * @returns true if the loader can load the specified file
  45515. */
  45516. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45517. /**
  45518. * Transform the url before loading if required.
  45519. * @param rootUrl the url of the texture
  45520. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45521. * @returns the transformed texture
  45522. */
  45523. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45524. /**
  45525. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45526. * @param rootUrl the url of the texture
  45527. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45528. * @returns the fallback texture
  45529. */
  45530. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45531. /**
  45532. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45533. * @param data contains the texture data
  45534. * @param texture defines the BabylonJS internal texture
  45535. * @param createPolynomials will be true if polynomials have been requested
  45536. * @param onLoad defines the callback to trigger once the texture is ready
  45537. * @param onError defines the callback to trigger in case of error
  45538. */
  45539. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45540. /**
  45541. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45542. * @param data contains the texture data
  45543. * @param texture defines the BabylonJS internal texture
  45544. * @param callback defines the method to call once ready to upload
  45545. */
  45546. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45547. }
  45548. }
  45549. declare module BABYLON {
  45550. /**
  45551. * Based on jsTGALoader - Javascript loader for TGA file
  45552. * By Vincent Thibault
  45553. * @see http://blog.robrowser.com/javascript-tga-loader.html
  45554. */
  45555. export class TGATools {
  45556. private static _TYPE_INDEXED;
  45557. private static _TYPE_RGB;
  45558. private static _TYPE_GREY;
  45559. private static _TYPE_RLE_INDEXED;
  45560. private static _TYPE_RLE_RGB;
  45561. private static _TYPE_RLE_GREY;
  45562. private static _ORIGIN_MASK;
  45563. private static _ORIGIN_SHIFT;
  45564. private static _ORIGIN_BL;
  45565. private static _ORIGIN_BR;
  45566. private static _ORIGIN_UL;
  45567. private static _ORIGIN_UR;
  45568. /**
  45569. * Gets the header of a TGA file
  45570. * @param data defines the TGA data
  45571. * @returns the header
  45572. */
  45573. static GetTGAHeader(data: Uint8Array): any;
  45574. /**
  45575. * Uploads TGA content to a Babylon Texture
  45576. * @hidden
  45577. */
  45578. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  45579. /** @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;
  45580. /** @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;
  45581. /** @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;
  45582. /** @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;
  45583. /** @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;
  45584. /** @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;
  45585. }
  45586. }
  45587. declare module BABYLON {
  45588. /**
  45589. * Implementation of the TGA Texture Loader.
  45590. * @hidden
  45591. */
  45592. export class _TGATextureLoader implements IInternalTextureLoader {
  45593. /**
  45594. * Defines wether the loader supports cascade loading the different faces.
  45595. */
  45596. readonly supportCascades: boolean;
  45597. /**
  45598. * This returns if the loader support the current file information.
  45599. * @param extension defines the file extension of the file being loaded
  45600. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45601. * @param fallback defines the fallback internal texture if any
  45602. * @param isBase64 defines whether the texture is encoded as a base64
  45603. * @param isBuffer defines whether the texture data are stored as a buffer
  45604. * @returns true if the loader can load the specified file
  45605. */
  45606. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45607. /**
  45608. * Transform the url before loading if required.
  45609. * @param rootUrl the url of the texture
  45610. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45611. * @returns the transformed texture
  45612. */
  45613. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45614. /**
  45615. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45616. * @param rootUrl the url of the texture
  45617. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45618. * @returns the fallback texture
  45619. */
  45620. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45621. /**
  45622. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45623. * @param data contains the texture data
  45624. * @param texture defines the BabylonJS internal texture
  45625. * @param createPolynomials will be true if polynomials have been requested
  45626. * @param onLoad defines the callback to trigger once the texture is ready
  45627. * @param onError defines the callback to trigger in case of error
  45628. */
  45629. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45630. /**
  45631. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45632. * @param data contains the texture data
  45633. * @param texture defines the BabylonJS internal texture
  45634. * @param callback defines the method to call once ready to upload
  45635. */
  45636. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45637. }
  45638. }
  45639. declare module BABYLON {
  45640. /**
  45641. * 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.
  45642. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  45643. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  45644. */
  45645. export class CustomProceduralTexture extends ProceduralTexture {
  45646. private _animate;
  45647. private _time;
  45648. private _config;
  45649. private _texturePath;
  45650. /**
  45651. * Instantiates a new Custom Procedural Texture.
  45652. * 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.
  45653. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  45654. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  45655. * @param name Define the name of the texture
  45656. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  45657. * @param size Define the size of the texture to create
  45658. * @param scene Define the scene the texture belongs to
  45659. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  45660. * @param generateMipMaps Define if the texture should creates mip maps or not
  45661. */
  45662. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  45663. private _loadJson;
  45664. /**
  45665. * Is the texture ready to be used ? (rendered at least once)
  45666. * @returns true if ready, otherwise, false.
  45667. */
  45668. isReady(): boolean;
  45669. /**
  45670. * Render the texture to its associated render target.
  45671. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  45672. */
  45673. render(useCameraPostProcess?: boolean): void;
  45674. /**
  45675. * Update the list of dependant textures samplers in the shader.
  45676. */
  45677. updateTextures(): void;
  45678. /**
  45679. * Update the uniform values of the procedural texture in the shader.
  45680. */
  45681. updateShaderUniforms(): void;
  45682. /**
  45683. * Define if the texture animates or not.
  45684. */
  45685. animate: boolean;
  45686. }
  45687. }
  45688. declare module BABYLON {
  45689. /** @hidden */
  45690. export var noisePixelShader: {
  45691. name: string;
  45692. shader: string;
  45693. };
  45694. }
  45695. declare module BABYLON {
  45696. /**
  45697. * Class used to generate noise procedural textures
  45698. */
  45699. export class NoiseProceduralTexture extends ProceduralTexture {
  45700. private _time;
  45701. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  45702. brightness: number;
  45703. /** Defines the number of octaves to process */
  45704. octaves: number;
  45705. /** Defines the level of persistence (0.8 by default) */
  45706. persistence: number;
  45707. /** Gets or sets animation speed factor (default is 1) */
  45708. animationSpeedFactor: number;
  45709. /**
  45710. * Creates a new NoiseProceduralTexture
  45711. * @param name defines the name fo the texture
  45712. * @param size defines the size of the texture (default is 256)
  45713. * @param scene defines the hosting scene
  45714. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  45715. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  45716. */
  45717. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  45718. private _updateShaderUniforms;
  45719. protected _getDefines(): string;
  45720. /** Generate the current state of the procedural texture */
  45721. render(useCameraPostProcess?: boolean): void;
  45722. /**
  45723. * Serializes this noise procedural texture
  45724. * @returns a serialized noise procedural texture object
  45725. */
  45726. serialize(): any;
  45727. /**
  45728. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  45729. * @param parsedTexture defines parsed texture data
  45730. * @param scene defines the current scene
  45731. * @param rootUrl defines the root URL containing noise procedural texture information
  45732. * @returns a parsed NoiseProceduralTexture
  45733. */
  45734. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  45735. }
  45736. }
  45737. declare module BABYLON {
  45738. /**
  45739. * Raw cube texture where the raw buffers are passed in
  45740. */
  45741. export class RawCubeTexture extends CubeTexture {
  45742. /**
  45743. * Creates a cube texture where the raw buffers are passed in.
  45744. * @param scene defines the scene the texture is attached to
  45745. * @param data defines the array of data to use to create each face
  45746. * @param size defines the size of the textures
  45747. * @param format defines the format of the data
  45748. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45749. * @param generateMipMaps defines if the engine should generate the mip levels
  45750. * @param invertY defines if data must be stored with Y axis inverted
  45751. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45752. * @param compression defines the compression used (null by default)
  45753. */
  45754. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  45755. /**
  45756. * Updates the raw cube texture.
  45757. * @param data defines the data to store
  45758. * @param format defines the data format
  45759. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45760. * @param invertY defines if data must be stored with Y axis inverted
  45761. * @param compression defines the compression used (null by default)
  45762. * @param level defines which level of the texture to update
  45763. */
  45764. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  45765. /**
  45766. * Updates a raw cube texture with RGBD encoded data.
  45767. * @param data defines the array of data [mipmap][face] to use to create each face
  45768. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  45769. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45770. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45771. * @returns a promsie that resolves when the operation is complete
  45772. */
  45773. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  45774. /**
  45775. * Clones the raw cube texture.
  45776. * @return a new cube texture
  45777. */
  45778. clone(): CubeTexture;
  45779. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45780. }
  45781. }
  45782. declare module BABYLON {
  45783. /**
  45784. * Class used to store 3D textures containing user data
  45785. */
  45786. export class RawTexture3D extends Texture {
  45787. /** Gets or sets the texture format to use */
  45788. format: number;
  45789. private _engine;
  45790. /**
  45791. * Create a new RawTexture3D
  45792. * @param data defines the data of the texture
  45793. * @param width defines the width of the texture
  45794. * @param height defines the height of the texture
  45795. * @param depth defines the depth of the texture
  45796. * @param format defines the texture format to use
  45797. * @param scene defines the hosting scene
  45798. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  45799. * @param invertY defines if texture must be stored with Y axis inverted
  45800. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  45801. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45802. */
  45803. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  45804. /** Gets or sets the texture format to use */
  45805. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  45806. /**
  45807. * Update the texture with new data
  45808. * @param data defines the data to store in the texture
  45809. */
  45810. update(data: ArrayBufferView): void;
  45811. }
  45812. }
  45813. declare module BABYLON {
  45814. /**
  45815. * Creates a refraction texture used by refraction channel of the standard material.
  45816. * It is like a mirror but to see through a material.
  45817. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  45818. */
  45819. export class RefractionTexture extends RenderTargetTexture {
  45820. /**
  45821. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  45822. * 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.
  45823. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  45824. */
  45825. refractionPlane: Plane;
  45826. /**
  45827. * Define how deep under the surface we should see.
  45828. */
  45829. depth: number;
  45830. /**
  45831. * Creates a refraction texture used by refraction channel of the standard material.
  45832. * It is like a mirror but to see through a material.
  45833. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  45834. * @param name Define the texture name
  45835. * @param size Define the size of the underlying texture
  45836. * @param scene Define the scene the refraction belongs to
  45837. * @param generateMipMaps Define if we need to generate mips level for the refraction
  45838. */
  45839. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  45840. /**
  45841. * Clone the refraction texture.
  45842. * @returns the cloned texture
  45843. */
  45844. clone(): RefractionTexture;
  45845. /**
  45846. * Serialize the texture to a JSON representation you could use in Parse later on
  45847. * @returns the serialized JSON representation
  45848. */
  45849. serialize(): any;
  45850. }
  45851. }
  45852. declare module BABYLON {
  45853. /**
  45854. * Configuration for Draco compression
  45855. */
  45856. export interface IDracoCompressionConfiguration {
  45857. /**
  45858. * Configuration for the decoder.
  45859. */
  45860. decoder?: {
  45861. /**
  45862. * The url to the WebAssembly module.
  45863. */
  45864. wasmUrl?: string;
  45865. /**
  45866. * The url to the WebAssembly binary.
  45867. */
  45868. wasmBinaryUrl?: string;
  45869. /**
  45870. * The url to the fallback JavaScript module.
  45871. */
  45872. fallbackUrl?: string;
  45873. };
  45874. }
  45875. /**
  45876. * Draco compression (https://google.github.io/draco/)
  45877. *
  45878. * This class wraps the Draco module.
  45879. *
  45880. * **Encoder**
  45881. *
  45882. * The encoder is not currently implemented.
  45883. *
  45884. * **Decoder**
  45885. *
  45886. * 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.
  45887. *
  45888. * To update the configuration, use the following code:
  45889. * ```javascript
  45890. * DracoCompression.Configuration = {
  45891. * decoder: {
  45892. * wasmUrl: "<url to the WebAssembly library>",
  45893. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  45894. * fallbackUrl: "<url to the fallback JavaScript library>",
  45895. * }
  45896. * };
  45897. * ```
  45898. *
  45899. * 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.
  45900. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  45901. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  45902. *
  45903. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  45904. * ```javascript
  45905. * var dracoCompression = new DracoCompression();
  45906. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  45907. * [VertexBuffer.PositionKind]: 0
  45908. * });
  45909. * ```
  45910. *
  45911. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  45912. */
  45913. export class DracoCompression implements IDisposable {
  45914. private static _DecoderModulePromise;
  45915. /**
  45916. * The configuration. Defaults to the following urls:
  45917. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  45918. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  45919. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  45920. */
  45921. static Configuration: IDracoCompressionConfiguration;
  45922. /**
  45923. * Returns true if the decoder is available.
  45924. */
  45925. static readonly DecoderAvailable: boolean;
  45926. /**
  45927. * Constructor
  45928. */
  45929. constructor();
  45930. /**
  45931. * Stop all async operations and release resources.
  45932. */
  45933. dispose(): void;
  45934. /**
  45935. * Decode Draco compressed mesh data to vertex data.
  45936. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  45937. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  45938. * @returns A promise that resolves with the decoded vertex data
  45939. */
  45940. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  45941. [kind: string]: number;
  45942. }): Promise<VertexData>;
  45943. private static _GetDecoderModule;
  45944. private static _LoadScriptAsync;
  45945. private static _LoadFileAsync;
  45946. }
  45947. }
  45948. declare module BABYLON {
  45949. /**
  45950. * Class for building Constructive Solid Geometry
  45951. */
  45952. export class CSG {
  45953. private polygons;
  45954. /**
  45955. * The world matrix
  45956. */
  45957. matrix: Matrix;
  45958. /**
  45959. * Stores the position
  45960. */
  45961. position: Vector3;
  45962. /**
  45963. * Stores the rotation
  45964. */
  45965. rotation: Vector3;
  45966. /**
  45967. * Stores the rotation quaternion
  45968. */
  45969. rotationQuaternion: Nullable<Quaternion>;
  45970. /**
  45971. * Stores the scaling vector
  45972. */
  45973. scaling: Vector3;
  45974. /**
  45975. * Convert the Mesh to CSG
  45976. * @param mesh The Mesh to convert to CSG
  45977. * @returns A new CSG from the Mesh
  45978. */
  45979. static FromMesh(mesh: Mesh): CSG;
  45980. /**
  45981. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  45982. * @param polygons Polygons used to construct a CSG solid
  45983. */
  45984. private static FromPolygons;
  45985. /**
  45986. * Clones, or makes a deep copy, of the CSG
  45987. * @returns A new CSG
  45988. */
  45989. clone(): CSG;
  45990. /**
  45991. * Unions this CSG with another CSG
  45992. * @param csg The CSG to union against this CSG
  45993. * @returns The unioned CSG
  45994. */
  45995. union(csg: CSG): CSG;
  45996. /**
  45997. * Unions this CSG with another CSG in place
  45998. * @param csg The CSG to union against this CSG
  45999. */
  46000. unionInPlace(csg: CSG): void;
  46001. /**
  46002. * Subtracts this CSG with another CSG
  46003. * @param csg The CSG to subtract against this CSG
  46004. * @returns A new CSG
  46005. */
  46006. subtract(csg: CSG): CSG;
  46007. /**
  46008. * Subtracts this CSG with another CSG in place
  46009. * @param csg The CSG to subtact against this CSG
  46010. */
  46011. subtractInPlace(csg: CSG): void;
  46012. /**
  46013. * Intersect this CSG with another CSG
  46014. * @param csg The CSG to intersect against this CSG
  46015. * @returns A new CSG
  46016. */
  46017. intersect(csg: CSG): CSG;
  46018. /**
  46019. * Intersects this CSG with another CSG in place
  46020. * @param csg The CSG to intersect against this CSG
  46021. */
  46022. intersectInPlace(csg: CSG): void;
  46023. /**
  46024. * Return a new CSG solid with solid and empty space switched. This solid is
  46025. * not modified.
  46026. * @returns A new CSG solid with solid and empty space switched
  46027. */
  46028. inverse(): CSG;
  46029. /**
  46030. * Inverses the CSG in place
  46031. */
  46032. inverseInPlace(): void;
  46033. /**
  46034. * This is used to keep meshes transformations so they can be restored
  46035. * when we build back a Babylon Mesh
  46036. * NB : All CSG operations are performed in world coordinates
  46037. * @param csg The CSG to copy the transform attributes from
  46038. * @returns This CSG
  46039. */
  46040. copyTransformAttributes(csg: CSG): CSG;
  46041. /**
  46042. * Build Raw mesh from CSG
  46043. * Coordinates here are in world space
  46044. * @param name The name of the mesh geometry
  46045. * @param scene The Scene
  46046. * @param keepSubMeshes Specifies if the submeshes should be kept
  46047. * @returns A new Mesh
  46048. */
  46049. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  46050. /**
  46051. * Build Mesh from CSG taking material and transforms into account
  46052. * @param name The name of the Mesh
  46053. * @param material The material of the Mesh
  46054. * @param scene The Scene
  46055. * @param keepSubMeshes Specifies if submeshes should be kept
  46056. * @returns The new Mesh
  46057. */
  46058. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  46059. }
  46060. }
  46061. declare module BABYLON {
  46062. /**
  46063. * Class containing static functions to help procedurally build meshes
  46064. */
  46065. export class RibbonBuilder {
  46066. /**
  46067. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  46068. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  46069. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  46070. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  46071. * * 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
  46072. * * 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
  46073. * * 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
  46074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46075. * * 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
  46076. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46077. * * 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
  46078. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  46079. * * 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
  46080. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  46081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46082. * @param name defines the name of the mesh
  46083. * @param options defines the options used to create the mesh
  46084. * @param scene defines the hosting scene
  46085. * @returns the ribbon mesh
  46086. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  46087. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46088. */
  46089. static CreateRibbon(name: string, options: {
  46090. pathArray: Vector3[][];
  46091. closeArray?: boolean;
  46092. closePath?: boolean;
  46093. offset?: number;
  46094. updatable?: boolean;
  46095. sideOrientation?: number;
  46096. frontUVs?: Vector4;
  46097. backUVs?: Vector4;
  46098. instance?: Mesh;
  46099. invertUV?: boolean;
  46100. uvs?: Vector2[];
  46101. colors?: Color4[];
  46102. }, scene?: Nullable<Scene>): Mesh;
  46103. }
  46104. }
  46105. declare module BABYLON {
  46106. /**
  46107. * Class containing static functions to help procedurally build meshes
  46108. */
  46109. export class TorusKnotBuilder {
  46110. /**
  46111. * Creates a torus knot mesh
  46112. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  46113. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  46114. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  46115. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  46116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46117. * * 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
  46118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46119. * @param name defines the name of the mesh
  46120. * @param options defines the options used to create the mesh
  46121. * @param scene defines the hosting scene
  46122. * @returns the torus knot mesh
  46123. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  46124. */
  46125. static CreateTorusKnot(name: string, options: {
  46126. radius?: number;
  46127. tube?: number;
  46128. radialSegments?: number;
  46129. tubularSegments?: number;
  46130. p?: number;
  46131. q?: number;
  46132. updatable?: boolean;
  46133. sideOrientation?: number;
  46134. frontUVs?: Vector4;
  46135. backUVs?: Vector4;
  46136. }, scene: any): Mesh;
  46137. }
  46138. }
  46139. declare module BABYLON {
  46140. /**
  46141. * Polygon
  46142. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  46143. */
  46144. export class Polygon {
  46145. /**
  46146. * Creates a rectangle
  46147. * @param xmin bottom X coord
  46148. * @param ymin bottom Y coord
  46149. * @param xmax top X coord
  46150. * @param ymax top Y coord
  46151. * @returns points that make the resulting rectation
  46152. */
  46153. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  46154. /**
  46155. * Creates a circle
  46156. * @param radius radius of circle
  46157. * @param cx scale in x
  46158. * @param cy scale in y
  46159. * @param numberOfSides number of sides that make up the circle
  46160. * @returns points that make the resulting circle
  46161. */
  46162. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  46163. /**
  46164. * Creates a polygon from input string
  46165. * @param input Input polygon data
  46166. * @returns the parsed points
  46167. */
  46168. static Parse(input: string): Vector2[];
  46169. /**
  46170. * Starts building a polygon from x and y coordinates
  46171. * @param x x coordinate
  46172. * @param y y coordinate
  46173. * @returns the started path2
  46174. */
  46175. static StartingAt(x: number, y: number): Path2;
  46176. }
  46177. /**
  46178. * Builds a polygon
  46179. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  46180. */
  46181. export class PolygonMeshBuilder {
  46182. private _points;
  46183. private _outlinepoints;
  46184. private _holes;
  46185. private _name;
  46186. private _scene;
  46187. private _epoints;
  46188. private _eholes;
  46189. private _addToepoint;
  46190. /**
  46191. * Babylon reference to the earcut plugin.
  46192. */
  46193. bjsEarcut: any;
  46194. /**
  46195. * Creates a PolygonMeshBuilder
  46196. * @param name name of the builder
  46197. * @param contours Path of the polygon
  46198. * @param scene scene to add to
  46199. * @param earcutInjection can be used to inject your own earcut reference
  46200. */
  46201. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  46202. /**
  46203. * Adds a whole within the polygon
  46204. * @param hole Array of points defining the hole
  46205. * @returns this
  46206. */
  46207. addHole(hole: Vector2[]): PolygonMeshBuilder;
  46208. /**
  46209. * Creates the polygon
  46210. * @param updatable If the mesh should be updatable
  46211. * @param depth The depth of the mesh created
  46212. * @returns the created mesh
  46213. */
  46214. build(updatable?: boolean, depth?: number): Mesh;
  46215. /**
  46216. * Adds a side to the polygon
  46217. * @param positions points that make the polygon
  46218. * @param normals normals of the polygon
  46219. * @param uvs uvs of the polygon
  46220. * @param indices indices of the polygon
  46221. * @param bounds bounds of the polygon
  46222. * @param points points of the polygon
  46223. * @param depth depth of the polygon
  46224. * @param flip flip of the polygon
  46225. */
  46226. private addSide;
  46227. }
  46228. }
  46229. declare module BABYLON {
  46230. /**
  46231. * Class containing static functions to help procedurally build meshes
  46232. */
  46233. export class PolygonBuilder {
  46234. /**
  46235. * Creates a polygon mesh
  46236. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  46237. * * 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
  46238. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  46239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46240. * * 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)
  46241. * * Remember you can only change the shape positions, not their number when updating a polygon
  46242. * @param name defines the name of the mesh
  46243. * @param options defines the options used to create the mesh
  46244. * @param scene defines the hosting scene
  46245. * @param earcutInjection can be used to inject your own earcut reference
  46246. * @returns the polygon mesh
  46247. */
  46248. static CreatePolygon(name: string, options: {
  46249. shape: Vector3[];
  46250. holes?: Vector3[][];
  46251. depth?: number;
  46252. faceUV?: Vector4[];
  46253. faceColors?: Color4[];
  46254. updatable?: boolean;
  46255. sideOrientation?: number;
  46256. frontUVs?: Vector4;
  46257. backUVs?: Vector4;
  46258. }, scene: Scene, earcutInjection?: any): Mesh;
  46259. /**
  46260. * Creates an extruded polygon mesh, with depth in the Y direction.
  46261. * * 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)
  46262. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46263. * @param name defines the name of the mesh
  46264. * @param options defines the options used to create the mesh
  46265. * @param scene defines the hosting scene
  46266. * @param earcutInjection can be used to inject your own earcut reference
  46267. * @returns the polygon mesh
  46268. */
  46269. static ExtrudePolygon(name: string, options: {
  46270. shape: Vector3[];
  46271. holes?: Vector3[][];
  46272. depth?: number;
  46273. faceUV?: Vector4[];
  46274. faceColors?: Color4[];
  46275. updatable?: boolean;
  46276. sideOrientation?: number;
  46277. frontUVs?: Vector4;
  46278. backUVs?: Vector4;
  46279. }, scene: Scene, earcutInjection?: any): Mesh;
  46280. }
  46281. }
  46282. declare module BABYLON {
  46283. /**
  46284. * Class containing static functions to help procedurally build meshes
  46285. */
  46286. export class ShapeBuilder {
  46287. /**
  46288. * 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.
  46289. * * 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.
  46290. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46291. * * 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.
  46292. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  46293. * * 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
  46294. * * 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
  46295. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  46296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46297. * * 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
  46298. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  46299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46300. * @param name defines the name of the mesh
  46301. * @param options defines the options used to create the mesh
  46302. * @param scene defines the hosting scene
  46303. * @returns the extruded shape mesh
  46304. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46305. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46306. */
  46307. static ExtrudeShape(name: string, options: {
  46308. shape: Vector3[];
  46309. path: Vector3[];
  46310. scale?: number;
  46311. rotation?: number;
  46312. cap?: number;
  46313. updatable?: boolean;
  46314. sideOrientation?: number;
  46315. frontUVs?: Vector4;
  46316. backUVs?: Vector4;
  46317. instance?: Mesh;
  46318. invertUV?: boolean;
  46319. }, scene?: Nullable<Scene>): Mesh;
  46320. /**
  46321. * Creates an custom extruded shape mesh.
  46322. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  46323. * * 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.
  46324. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46325. * * 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
  46326. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  46327. * * 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
  46328. * * It must returns a float value that will be the scale value applied to the shape on each path point
  46329. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  46330. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  46331. * * 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
  46332. * * 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
  46333. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  46334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46335. * * 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
  46336. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46338. * @param name defines the name of the mesh
  46339. * @param options defines the options used to create the mesh
  46340. * @param scene defines the hosting scene
  46341. * @returns the custom extruded shape mesh
  46342. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  46343. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46344. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46345. */
  46346. static ExtrudeShapeCustom(name: string, options: {
  46347. shape: Vector3[];
  46348. path: Vector3[];
  46349. scaleFunction?: any;
  46350. rotationFunction?: any;
  46351. ribbonCloseArray?: boolean;
  46352. ribbonClosePath?: boolean;
  46353. cap?: number;
  46354. updatable?: boolean;
  46355. sideOrientation?: number;
  46356. frontUVs?: Vector4;
  46357. backUVs?: Vector4;
  46358. instance?: Mesh;
  46359. invertUV?: boolean;
  46360. }, scene: Scene): Mesh;
  46361. private static _ExtrudeShapeGeneric;
  46362. }
  46363. }
  46364. declare module BABYLON {
  46365. /**
  46366. * Class containing static functions to help procedurally build meshes
  46367. */
  46368. export class LatheBuilder {
  46369. /**
  46370. * Creates lathe mesh.
  46371. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  46372. * * 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
  46373. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  46374. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  46375. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  46376. * * 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
  46377. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  46378. * * 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
  46379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46380. * * 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
  46381. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46383. * @param name defines the name of the mesh
  46384. * @param options defines the options used to create the mesh
  46385. * @param scene defines the hosting scene
  46386. * @returns the lathe mesh
  46387. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  46388. */
  46389. static CreateLathe(name: string, options: {
  46390. shape: Vector3[];
  46391. radius?: number;
  46392. tessellation?: number;
  46393. clip?: number;
  46394. arc?: number;
  46395. closed?: boolean;
  46396. updatable?: boolean;
  46397. sideOrientation?: number;
  46398. frontUVs?: Vector4;
  46399. backUVs?: Vector4;
  46400. cap?: number;
  46401. invertUV?: boolean;
  46402. }, scene: Scene): Mesh;
  46403. }
  46404. }
  46405. declare module BABYLON {
  46406. /**
  46407. * Class containing static functions to help procedurally build meshes
  46408. */
  46409. export class TubeBuilder {
  46410. /**
  46411. * Creates a tube mesh.
  46412. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  46413. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  46414. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  46415. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  46416. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  46417. * * 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)
  46418. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  46419. * * 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
  46420. * * 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
  46421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46422. * * 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
  46423. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46425. * @param name defines the name of the mesh
  46426. * @param options defines the options used to create the mesh
  46427. * @param scene defines the hosting scene
  46428. * @returns the tube mesh
  46429. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46430. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  46431. */
  46432. static CreateTube(name: string, options: {
  46433. path: Vector3[];
  46434. radius?: number;
  46435. tessellation?: number;
  46436. radiusFunction?: {
  46437. (i: number, distance: number): number;
  46438. };
  46439. cap?: number;
  46440. arc?: number;
  46441. updatable?: boolean;
  46442. sideOrientation?: number;
  46443. frontUVs?: Vector4;
  46444. backUVs?: Vector4;
  46445. instance?: Mesh;
  46446. invertUV?: boolean;
  46447. }, scene: Scene): Mesh;
  46448. }
  46449. }
  46450. declare module BABYLON {
  46451. /**
  46452. * Class containing static functions to help procedurally build meshes
  46453. */
  46454. export class IcoSphereBuilder {
  46455. /**
  46456. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  46457. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  46458. * * 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`)
  46459. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  46460. * * 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
  46461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46462. * * 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
  46463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46464. * @param name defines the name of the mesh
  46465. * @param options defines the options used to create the mesh
  46466. * @param scene defines the hosting scene
  46467. * @returns the icosahedron mesh
  46468. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  46469. */
  46470. static CreateIcoSphere(name: string, options: {
  46471. radius?: number;
  46472. radiusX?: number;
  46473. radiusY?: number;
  46474. radiusZ?: number;
  46475. flat?: boolean;
  46476. subdivisions?: number;
  46477. sideOrientation?: number;
  46478. frontUVs?: Vector4;
  46479. backUVs?: Vector4;
  46480. updatable?: boolean;
  46481. }, scene: Scene): Mesh;
  46482. }
  46483. }
  46484. declare module BABYLON {
  46485. /**
  46486. * Class containing static functions to help procedurally build meshes
  46487. */
  46488. export class DecalBuilder {
  46489. /**
  46490. * Creates a decal mesh.
  46491. * 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
  46492. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  46493. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  46494. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  46495. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  46496. * @param name defines the name of the mesh
  46497. * @param sourceMesh defines the mesh where the decal must be applied
  46498. * @param options defines the options used to create the mesh
  46499. * @param scene defines the hosting scene
  46500. * @returns the decal mesh
  46501. * @see https://doc.babylonjs.com/how_to/decals
  46502. */
  46503. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  46504. position?: Vector3;
  46505. normal?: Vector3;
  46506. size?: Vector3;
  46507. angle?: number;
  46508. }): Mesh;
  46509. }
  46510. }
  46511. declare module BABYLON {
  46512. /**
  46513. * Class containing static functions to help procedurally build meshes
  46514. */
  46515. export class MeshBuilder {
  46516. /**
  46517. * Creates a box mesh
  46518. * * The parameter `size` sets the size (float) of each box side (default 1)
  46519. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46520. * * 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)
  46521. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46523. * * 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
  46524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46525. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46526. * @param name defines the name of the mesh
  46527. * @param options defines the options used to create the mesh
  46528. * @param scene defines the hosting scene
  46529. * @returns the box mesh
  46530. */
  46531. static CreateBox(name: string, options: {
  46532. size?: number;
  46533. width?: number;
  46534. height?: number;
  46535. depth?: number;
  46536. faceUV?: Vector4[];
  46537. faceColors?: Color4[];
  46538. sideOrientation?: number;
  46539. frontUVs?: Vector4;
  46540. backUVs?: Vector4;
  46541. updatable?: boolean;
  46542. }, scene?: Nullable<Scene>): Mesh;
  46543. /**
  46544. * Creates a sphere mesh
  46545. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46546. * * 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`)
  46547. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46548. * * 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
  46549. * * 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)
  46550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46551. * * 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
  46552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46553. * @param name defines the name of the mesh
  46554. * @param options defines the options used to create the mesh
  46555. * @param scene defines the hosting scene
  46556. * @returns the sphere mesh
  46557. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46558. */
  46559. static CreateSphere(name: string, options: {
  46560. segments?: number;
  46561. diameter?: number;
  46562. diameterX?: number;
  46563. diameterY?: number;
  46564. diameterZ?: number;
  46565. arc?: number;
  46566. slice?: number;
  46567. sideOrientation?: number;
  46568. frontUVs?: Vector4;
  46569. backUVs?: Vector4;
  46570. updatable?: boolean;
  46571. }, scene: any): Mesh;
  46572. /**
  46573. * Creates a plane polygonal mesh. By default, this is a disc
  46574. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  46575. * * 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
  46576. * * 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
  46577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46578. * * 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
  46579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46580. * @param name defines the name of the mesh
  46581. * @param options defines the options used to create the mesh
  46582. * @param scene defines the hosting scene
  46583. * @returns the plane polygonal mesh
  46584. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  46585. */
  46586. static CreateDisc(name: string, options: {
  46587. radius?: number;
  46588. tessellation?: number;
  46589. arc?: number;
  46590. updatable?: boolean;
  46591. sideOrientation?: number;
  46592. frontUVs?: Vector4;
  46593. backUVs?: Vector4;
  46594. }, scene?: Nullable<Scene>): Mesh;
  46595. /**
  46596. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  46597. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  46598. * * 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`)
  46599. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  46600. * * 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
  46601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46602. * * 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
  46603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46604. * @param name defines the name of the mesh
  46605. * @param options defines the options used to create the mesh
  46606. * @param scene defines the hosting scene
  46607. * @returns the icosahedron mesh
  46608. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  46609. */
  46610. static CreateIcoSphere(name: string, options: {
  46611. radius?: number;
  46612. radiusX?: number;
  46613. radiusY?: number;
  46614. radiusZ?: number;
  46615. flat?: boolean;
  46616. subdivisions?: number;
  46617. sideOrientation?: number;
  46618. frontUVs?: Vector4;
  46619. backUVs?: Vector4;
  46620. updatable?: boolean;
  46621. }, scene: Scene): Mesh;
  46622. /**
  46623. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  46624. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  46625. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  46626. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  46627. * * 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
  46628. * * 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
  46629. * * 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
  46630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46631. * * 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
  46632. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46633. * * 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
  46634. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  46635. * * 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
  46636. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  46637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46638. * @param name defines the name of the mesh
  46639. * @param options defines the options used to create the mesh
  46640. * @param scene defines the hosting scene
  46641. * @returns the ribbon mesh
  46642. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  46643. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46644. */
  46645. static CreateRibbon(name: string, options: {
  46646. pathArray: Vector3[][];
  46647. closeArray?: boolean;
  46648. closePath?: boolean;
  46649. offset?: number;
  46650. updatable?: boolean;
  46651. sideOrientation?: number;
  46652. frontUVs?: Vector4;
  46653. backUVs?: Vector4;
  46654. instance?: Mesh;
  46655. invertUV?: boolean;
  46656. uvs?: Vector2[];
  46657. colors?: Color4[];
  46658. }, scene?: Nullable<Scene>): Mesh;
  46659. /**
  46660. * Creates a cylinder or a cone mesh
  46661. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46662. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46663. * * 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.
  46664. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46665. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46666. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46667. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46668. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46669. * * 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).
  46670. * * 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
  46671. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46672. * * 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
  46673. * * 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.
  46674. * * If `enclose` is false, a ring surface is one element.
  46675. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46676. * * 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
  46677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46678. * * 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
  46679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46680. * @param name defines the name of the mesh
  46681. * @param options defines the options used to create the mesh
  46682. * @param scene defines the hosting scene
  46683. * @returns the cylinder mesh
  46684. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46685. */
  46686. static CreateCylinder(name: string, options: {
  46687. height?: number;
  46688. diameterTop?: number;
  46689. diameterBottom?: number;
  46690. diameter?: number;
  46691. tessellation?: number;
  46692. subdivisions?: number;
  46693. arc?: number;
  46694. faceColors?: Color4[];
  46695. faceUV?: Vector4[];
  46696. updatable?: boolean;
  46697. hasRings?: boolean;
  46698. enclose?: boolean;
  46699. sideOrientation?: number;
  46700. frontUVs?: Vector4;
  46701. backUVs?: Vector4;
  46702. }, scene: any): Mesh;
  46703. /**
  46704. * Creates a torus mesh
  46705. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46706. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46707. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46709. * * 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
  46710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46711. * @param name defines the name of the mesh
  46712. * @param options defines the options used to create the mesh
  46713. * @param scene defines the hosting scene
  46714. * @returns the torus mesh
  46715. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46716. */
  46717. static CreateTorus(name: string, options: {
  46718. diameter?: number;
  46719. thickness?: number;
  46720. tessellation?: number;
  46721. updatable?: boolean;
  46722. sideOrientation?: number;
  46723. frontUVs?: Vector4;
  46724. backUVs?: Vector4;
  46725. }, scene: any): Mesh;
  46726. /**
  46727. * Creates a torus knot mesh
  46728. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  46729. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  46730. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  46731. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  46732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46733. * * 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
  46734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46735. * @param name defines the name of the mesh
  46736. * @param options defines the options used to create the mesh
  46737. * @param scene defines the hosting scene
  46738. * @returns the torus knot mesh
  46739. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  46740. */
  46741. static CreateTorusKnot(name: string, options: {
  46742. radius?: number;
  46743. tube?: number;
  46744. radialSegments?: number;
  46745. tubularSegments?: number;
  46746. p?: number;
  46747. q?: number;
  46748. updatable?: boolean;
  46749. sideOrientation?: number;
  46750. frontUVs?: Vector4;
  46751. backUVs?: Vector4;
  46752. }, scene: any): Mesh;
  46753. /**
  46754. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46755. * * 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
  46756. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46757. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46758. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46759. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46760. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46761. * * 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
  46762. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46764. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46765. * @param name defines the name of the new line system
  46766. * @param options defines the options used to create the line system
  46767. * @param scene defines the hosting scene
  46768. * @returns a new line system mesh
  46769. */
  46770. static CreateLineSystem(name: string, options: {
  46771. lines: Vector3[][];
  46772. updatable?: boolean;
  46773. instance?: Nullable<LinesMesh>;
  46774. colors?: Nullable<Color4[][]>;
  46775. useVertexAlpha?: boolean;
  46776. }, scene: Nullable<Scene>): LinesMesh;
  46777. /**
  46778. * Creates a line mesh
  46779. * 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
  46780. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46781. * * The parameter `points` is an array successive Vector3
  46782. * * 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
  46783. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46784. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46785. * * When updating an instance, remember that only point positions can change, not the number of points
  46786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46787. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46788. * @param name defines the name of the new line system
  46789. * @param options defines the options used to create the line system
  46790. * @param scene defines the hosting scene
  46791. * @returns a new line mesh
  46792. */
  46793. static CreateLines(name: string, options: {
  46794. points: Vector3[];
  46795. updatable?: boolean;
  46796. instance?: Nullable<LinesMesh>;
  46797. colors?: Color4[];
  46798. useVertexAlpha?: boolean;
  46799. }, scene?: Nullable<Scene>): LinesMesh;
  46800. /**
  46801. * Creates a dashed line mesh
  46802. * * 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
  46803. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46804. * * The parameter `points` is an array successive Vector3
  46805. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46806. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46807. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46808. * * 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
  46809. * * When updating an instance, remember that only point positions can change, not the number of points
  46810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46811. * @param name defines the name of the mesh
  46812. * @param options defines the options used to create the mesh
  46813. * @param scene defines the hosting scene
  46814. * @returns the dashed line mesh
  46815. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46816. */
  46817. static CreateDashedLines(name: string, options: {
  46818. points: Vector3[];
  46819. dashSize?: number;
  46820. gapSize?: number;
  46821. dashNb?: number;
  46822. updatable?: boolean;
  46823. instance?: LinesMesh;
  46824. }, scene?: Nullable<Scene>): LinesMesh;
  46825. /**
  46826. * 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.
  46827. * * 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.
  46828. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46829. * * 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.
  46830. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  46831. * * 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
  46832. * * 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
  46833. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  46834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46835. * * 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
  46836. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  46837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46838. * @param name defines the name of the mesh
  46839. * @param options defines the options used to create the mesh
  46840. * @param scene defines the hosting scene
  46841. * @returns the extruded shape mesh
  46842. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46844. */
  46845. static ExtrudeShape(name: string, options: {
  46846. shape: Vector3[];
  46847. path: Vector3[];
  46848. scale?: number;
  46849. rotation?: number;
  46850. cap?: number;
  46851. updatable?: boolean;
  46852. sideOrientation?: number;
  46853. frontUVs?: Vector4;
  46854. backUVs?: Vector4;
  46855. instance?: Mesh;
  46856. invertUV?: boolean;
  46857. }, scene?: Nullable<Scene>): Mesh;
  46858. /**
  46859. * Creates an custom extruded shape mesh.
  46860. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  46861. * * 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.
  46862. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46863. * * 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
  46864. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  46865. * * 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
  46866. * * It must returns a float value that will be the scale value applied to the shape on each path point
  46867. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  46868. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  46869. * * 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
  46870. * * 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
  46871. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  46872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46873. * * 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
  46874. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46876. * @param name defines the name of the mesh
  46877. * @param options defines the options used to create the mesh
  46878. * @param scene defines the hosting scene
  46879. * @returns the custom extruded shape mesh
  46880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  46881. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46883. */
  46884. static ExtrudeShapeCustom(name: string, options: {
  46885. shape: Vector3[];
  46886. path: Vector3[];
  46887. scaleFunction?: any;
  46888. rotationFunction?: any;
  46889. ribbonCloseArray?: boolean;
  46890. ribbonClosePath?: boolean;
  46891. cap?: number;
  46892. updatable?: boolean;
  46893. sideOrientation?: number;
  46894. frontUVs?: Vector4;
  46895. backUVs?: Vector4;
  46896. instance?: Mesh;
  46897. invertUV?: boolean;
  46898. }, scene: Scene): Mesh;
  46899. /**
  46900. * Creates lathe mesh.
  46901. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  46902. * * 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
  46903. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  46904. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  46905. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  46906. * * 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
  46907. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  46908. * * 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
  46909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46910. * * 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
  46911. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46913. * @param name defines the name of the mesh
  46914. * @param options defines the options used to create the mesh
  46915. * @param scene defines the hosting scene
  46916. * @returns the lathe mesh
  46917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  46918. */
  46919. static CreateLathe(name: string, options: {
  46920. shape: Vector3[];
  46921. radius?: number;
  46922. tessellation?: number;
  46923. clip?: number;
  46924. arc?: number;
  46925. closed?: boolean;
  46926. updatable?: boolean;
  46927. sideOrientation?: number;
  46928. frontUVs?: Vector4;
  46929. backUVs?: Vector4;
  46930. cap?: number;
  46931. invertUV?: boolean;
  46932. }, scene: Scene): Mesh;
  46933. /**
  46934. * Creates a plane mesh
  46935. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46936. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46937. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46939. * * 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
  46940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46941. * @param name defines the name of the mesh
  46942. * @param options defines the options used to create the mesh
  46943. * @param scene defines the hosting scene
  46944. * @returns the plane mesh
  46945. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46946. */
  46947. static CreatePlane(name: string, options: {
  46948. size?: number;
  46949. width?: number;
  46950. height?: number;
  46951. sideOrientation?: number;
  46952. frontUVs?: Vector4;
  46953. backUVs?: Vector4;
  46954. updatable?: boolean;
  46955. sourcePlane?: Plane;
  46956. }, scene: Scene): Mesh;
  46957. /**
  46958. * Creates a ground mesh
  46959. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46960. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46962. * @param name defines the name of the mesh
  46963. * @param options defines the options used to create the mesh
  46964. * @param scene defines the hosting scene
  46965. * @returns the ground mesh
  46966. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46967. */
  46968. static CreateGround(name: string, options: {
  46969. width?: number;
  46970. height?: number;
  46971. subdivisions?: number;
  46972. subdivisionsX?: number;
  46973. subdivisionsY?: number;
  46974. updatable?: boolean;
  46975. }, scene: any): Mesh;
  46976. /**
  46977. * Creates a tiled ground mesh
  46978. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46979. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46980. * * 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
  46981. * * 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
  46982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46983. * @param name defines the name of the mesh
  46984. * @param options defines the options used to create the mesh
  46985. * @param scene defines the hosting scene
  46986. * @returns the tiled ground mesh
  46987. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46988. */
  46989. static CreateTiledGround(name: string, options: {
  46990. xmin: number;
  46991. zmin: number;
  46992. xmax: number;
  46993. zmax: number;
  46994. subdivisions?: {
  46995. w: number;
  46996. h: number;
  46997. };
  46998. precision?: {
  46999. w: number;
  47000. h: number;
  47001. };
  47002. updatable?: boolean;
  47003. }, scene: Scene): Mesh;
  47004. /**
  47005. * Creates a ground mesh from a height map
  47006. * * The parameter `url` sets the URL of the height map image resource.
  47007. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47008. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47009. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47010. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47011. * * 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.
  47012. * * 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).
  47013. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47015. * @param name defines the name of the mesh
  47016. * @param url defines the url to the height map
  47017. * @param options defines the options used to create the mesh
  47018. * @param scene defines the hosting scene
  47019. * @returns the ground mesh
  47020. * @see https://doc.babylonjs.com/babylon101/height_map
  47021. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47022. */
  47023. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47024. width?: number;
  47025. height?: number;
  47026. subdivisions?: number;
  47027. minHeight?: number;
  47028. maxHeight?: number;
  47029. colorFilter?: Color3;
  47030. alphaFilter?: number;
  47031. updatable?: boolean;
  47032. onReady?: (mesh: GroundMesh) => void;
  47033. }, scene: Scene): GroundMesh;
  47034. /**
  47035. * Creates a polygon mesh
  47036. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  47037. * * 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
  47038. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  47039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47040. * * 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)
  47041. * * Remember you can only change the shape positions, not their number when updating a polygon
  47042. * @param name defines the name of the mesh
  47043. * @param options defines the options used to create the mesh
  47044. * @param scene defines the hosting scene
  47045. * @param earcutInjection can be used to inject your own earcut reference
  47046. * @returns the polygon mesh
  47047. */
  47048. static CreatePolygon(name: string, options: {
  47049. shape: Vector3[];
  47050. holes?: Vector3[][];
  47051. depth?: number;
  47052. faceUV?: Vector4[];
  47053. faceColors?: Color4[];
  47054. updatable?: boolean;
  47055. sideOrientation?: number;
  47056. frontUVs?: Vector4;
  47057. backUVs?: Vector4;
  47058. }, scene: Scene, earcutInjection?: any): Mesh;
  47059. /**
  47060. * Creates an extruded polygon mesh, with depth in the Y direction.
  47061. * * 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)
  47062. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47063. * @param name defines the name of the mesh
  47064. * @param options defines the options used to create the mesh
  47065. * @param scene defines the hosting scene
  47066. * @param earcutInjection can be used to inject your own earcut reference
  47067. * @returns the polygon mesh
  47068. */
  47069. static ExtrudePolygon(name: string, options: {
  47070. shape: Vector3[];
  47071. holes?: Vector3[][];
  47072. depth?: number;
  47073. faceUV?: Vector4[];
  47074. faceColors?: Color4[];
  47075. updatable?: boolean;
  47076. sideOrientation?: number;
  47077. frontUVs?: Vector4;
  47078. backUVs?: Vector4;
  47079. }, scene: Scene, earcutInjection?: any): Mesh;
  47080. /**
  47081. * Creates a tube mesh.
  47082. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47083. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  47084. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  47085. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  47086. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  47087. * * 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)
  47088. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  47089. * * 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
  47090. * * 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
  47091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47092. * * 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
  47093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47095. * @param name defines the name of the mesh
  47096. * @param options defines the options used to create the mesh
  47097. * @param scene defines the hosting scene
  47098. * @returns the tube mesh
  47099. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47100. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  47101. */
  47102. static CreateTube(name: string, options: {
  47103. path: Vector3[];
  47104. radius?: number;
  47105. tessellation?: number;
  47106. radiusFunction?: {
  47107. (i: number, distance: number): number;
  47108. };
  47109. cap?: number;
  47110. arc?: number;
  47111. updatable?: boolean;
  47112. sideOrientation?: number;
  47113. frontUVs?: Vector4;
  47114. backUVs?: Vector4;
  47115. instance?: Mesh;
  47116. invertUV?: boolean;
  47117. }, scene: Scene): Mesh;
  47118. /**
  47119. * Creates a polyhedron mesh
  47120. * * 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
  47121. * * The parameter `size` (positive float, default 1) sets the polygon size
  47122. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47123. * * 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`
  47124. * * 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
  47125. * * 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)`)
  47126. * * 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
  47127. * * 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
  47128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47129. * * 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
  47130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47131. * @param name defines the name of the mesh
  47132. * @param options defines the options used to create the mesh
  47133. * @param scene defines the hosting scene
  47134. * @returns the polyhedron mesh
  47135. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47136. */
  47137. static CreatePolyhedron(name: string, options: {
  47138. type?: number;
  47139. size?: number;
  47140. sizeX?: number;
  47141. sizeY?: number;
  47142. sizeZ?: number;
  47143. custom?: any;
  47144. faceUV?: Vector4[];
  47145. faceColors?: Color4[];
  47146. flat?: boolean;
  47147. updatable?: boolean;
  47148. sideOrientation?: number;
  47149. frontUVs?: Vector4;
  47150. backUVs?: Vector4;
  47151. }, scene: Scene): Mesh;
  47152. /**
  47153. * Creates a decal mesh.
  47154. * 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
  47155. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  47156. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  47157. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  47158. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  47159. * @param name defines the name of the mesh
  47160. * @param sourceMesh defines the mesh where the decal must be applied
  47161. * @param options defines the options used to create the mesh
  47162. * @param scene defines the hosting scene
  47163. * @returns the decal mesh
  47164. * @see https://doc.babylonjs.com/how_to/decals
  47165. */
  47166. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  47167. position?: Vector3;
  47168. normal?: Vector3;
  47169. size?: Vector3;
  47170. angle?: number;
  47171. }): Mesh;
  47172. }
  47173. }
  47174. declare module BABYLON {
  47175. /**
  47176. * A simplifier interface for future simplification implementations
  47177. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47178. */
  47179. export interface ISimplifier {
  47180. /**
  47181. * Simplification of a given mesh according to the given settings.
  47182. * Since this requires computation, it is assumed that the function runs async.
  47183. * @param settings The settings of the simplification, including quality and distance
  47184. * @param successCallback A callback that will be called after the mesh was simplified.
  47185. * @param errorCallback in case of an error, this callback will be called. optional.
  47186. */
  47187. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  47188. }
  47189. /**
  47190. * Expected simplification settings.
  47191. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  47192. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47193. */
  47194. export interface ISimplificationSettings {
  47195. /**
  47196. * Gets or sets the expected quality
  47197. */
  47198. quality: number;
  47199. /**
  47200. * Gets or sets the distance when this optimized version should be used
  47201. */
  47202. distance: number;
  47203. /**
  47204. * Gets an already optimized mesh
  47205. */
  47206. optimizeMesh?: boolean;
  47207. }
  47208. /**
  47209. * Class used to specify simplification options
  47210. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47211. */
  47212. export class SimplificationSettings implements ISimplificationSettings {
  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. * Creates a SimplificationSettings
  47221. * @param quality expected quality
  47222. * @param distance distance when this optimized version should be used
  47223. * @param optimizeMesh already optimized mesh
  47224. */
  47225. constructor(
  47226. /** expected quality */
  47227. quality: number,
  47228. /** distance when this optimized version should be used */
  47229. distance: number,
  47230. /** already optimized mesh */
  47231. optimizeMesh?: boolean | undefined);
  47232. }
  47233. /**
  47234. * Interface used to define a simplification task
  47235. */
  47236. export interface ISimplificationTask {
  47237. /**
  47238. * Array of settings
  47239. */
  47240. settings: Array<ISimplificationSettings>;
  47241. /**
  47242. * Simplification type
  47243. */
  47244. simplificationType: SimplificationType;
  47245. /**
  47246. * Mesh to simplify
  47247. */
  47248. mesh: Mesh;
  47249. /**
  47250. * Callback called on success
  47251. */
  47252. successCallback?: () => void;
  47253. /**
  47254. * Defines if parallel processing can be used
  47255. */
  47256. parallelProcessing: boolean;
  47257. }
  47258. /**
  47259. * Queue used to order the simplification tasks
  47260. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47261. */
  47262. export class SimplificationQueue {
  47263. private _simplificationArray;
  47264. /**
  47265. * Gets a boolean indicating that the process is still running
  47266. */
  47267. running: boolean;
  47268. /**
  47269. * Creates a new queue
  47270. */
  47271. constructor();
  47272. /**
  47273. * Adds a new simplification task
  47274. * @param task defines a task to add
  47275. */
  47276. addTask(task: ISimplificationTask): void;
  47277. /**
  47278. * Execute next task
  47279. */
  47280. executeNext(): void;
  47281. /**
  47282. * Execute a simplification task
  47283. * @param task defines the task to run
  47284. */
  47285. runSimplification(task: ISimplificationTask): void;
  47286. private getSimplifier;
  47287. }
  47288. /**
  47289. * The implemented types of simplification
  47290. * At the moment only Quadratic Error Decimation is implemented
  47291. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47292. */
  47293. export enum SimplificationType {
  47294. /** Quadratic error decimation */
  47295. QUADRATIC = 0
  47296. }
  47297. }
  47298. declare module BABYLON {
  47299. interface Scene {
  47300. /** @hidden (Backing field) */ simplificationQueue: SimplificationQueue;
  47301. /**
  47302. * Gets or sets the simplification queue attached to the scene
  47303. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47304. */
  47305. simplificationQueue: SimplificationQueue;
  47306. }
  47307. interface Mesh {
  47308. /**
  47309. * Simplify the mesh according to the given array of settings.
  47310. * Function will return immediately and will simplify async
  47311. * @param settings a collection of simplification settings
  47312. * @param parallelProcessing should all levels calculate parallel or one after the other
  47313. * @param simplificationType the type of simplification to run
  47314. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  47315. * @returns the current mesh
  47316. */
  47317. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  47318. }
  47319. /**
  47320. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  47321. * created in a scene
  47322. */
  47323. export class SimplicationQueueSceneComponent implements ISceneComponent {
  47324. /**
  47325. * The component name helpfull to identify the component in the list of scene components.
  47326. */
  47327. readonly name: string;
  47328. /**
  47329. * The scene the component belongs to.
  47330. */
  47331. scene: Scene;
  47332. /**
  47333. * Creates a new instance of the component for the given scene
  47334. * @param scene Defines the scene to register the component in
  47335. */
  47336. constructor(scene: Scene);
  47337. /**
  47338. * Registers the component in a given scene
  47339. */
  47340. register(): void;
  47341. /**
  47342. * Rebuilds the elements related to this component in case of
  47343. * context lost for instance.
  47344. */
  47345. rebuild(): void;
  47346. /**
  47347. * Disposes the component and the associated ressources
  47348. */
  47349. dispose(): void;
  47350. private _beforeCameraUpdate;
  47351. }
  47352. }
  47353. declare module BABYLON {
  47354. /**
  47355. * Class used to enable access to IndexedDB
  47356. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  47357. */
  47358. export class Database implements IOfflineProvider {
  47359. private _callbackManifestChecked;
  47360. private _currentSceneUrl;
  47361. private _db;
  47362. private _enableSceneOffline;
  47363. private _enableTexturesOffline;
  47364. private _manifestVersionFound;
  47365. private _mustUpdateRessources;
  47366. private _hasReachedQuota;
  47367. private _isSupported;
  47368. private _idbFactory;
  47369. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  47370. private static IsUASupportingBlobStorage;
  47371. /**
  47372. * Gets a boolean indicating if Database storate is enabled (off by default)
  47373. */
  47374. static IDBStorageEnabled: boolean;
  47375. /**
  47376. * Gets a boolean indicating if scene must be saved in the database
  47377. */
  47378. readonly enableSceneOffline: boolean;
  47379. /**
  47380. * Gets a boolean indicating if textures must be saved in the database
  47381. */
  47382. readonly enableTexturesOffline: boolean;
  47383. /**
  47384. * Creates a new Database
  47385. * @param urlToScene defines the url to load the scene
  47386. * @param callbackManifestChecked defines the callback to use when manifest is checked
  47387. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  47388. */
  47389. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  47390. private static _ParseURL;
  47391. private static _ReturnFullUrlLocation;
  47392. private _checkManifestFile;
  47393. /**
  47394. * Open the database and make it available
  47395. * @param successCallback defines the callback to call on success
  47396. * @param errorCallback defines the callback to call on error
  47397. */
  47398. open(successCallback: () => void, errorCallback: () => void): void;
  47399. /**
  47400. * Loads an image from the database
  47401. * @param url defines the url to load from
  47402. * @param image defines the target DOM image
  47403. */
  47404. loadImage(url: string, image: HTMLImageElement): void;
  47405. private _loadImageFromDBAsync;
  47406. private _saveImageIntoDBAsync;
  47407. private _checkVersionFromDB;
  47408. private _loadVersionFromDBAsync;
  47409. private _saveVersionIntoDBAsync;
  47410. /**
  47411. * Loads a file from database
  47412. * @param url defines the URL to load from
  47413. * @param sceneLoaded defines a callback to call on success
  47414. * @param progressCallBack defines a callback to call when progress changed
  47415. * @param errorCallback defines a callback to call on error
  47416. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  47417. */
  47418. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  47419. private _loadFileAsync;
  47420. private _saveFileAsync;
  47421. /**
  47422. * Validates if xhr data is correct
  47423. * @param xhr defines the request to validate
  47424. * @param dataType defines the expected data type
  47425. * @returns true if data is correct
  47426. */
  47427. private static _ValidateXHRData;
  47428. }
  47429. }
  47430. declare module BABYLON {
  47431. /** @hidden */
  47432. export var gpuUpdateParticlesPixelShader: {
  47433. name: string;
  47434. shader: string;
  47435. };
  47436. }
  47437. declare module BABYLON {
  47438. /** @hidden */
  47439. export var gpuUpdateParticlesVertexShader: {
  47440. name: string;
  47441. shader: string;
  47442. };
  47443. }
  47444. declare module BABYLON {
  47445. /** @hidden */
  47446. export var clipPlaneFragmentDeclaration2: {
  47447. name: string;
  47448. shader: string;
  47449. };
  47450. }
  47451. declare module BABYLON {
  47452. /** @hidden */
  47453. export var gpuRenderParticlesPixelShader: {
  47454. name: string;
  47455. shader: string;
  47456. };
  47457. }
  47458. declare module BABYLON {
  47459. /** @hidden */
  47460. export var clipPlaneVertexDeclaration2: {
  47461. name: string;
  47462. shader: string;
  47463. };
  47464. }
  47465. declare module BABYLON {
  47466. /** @hidden */
  47467. export var gpuRenderParticlesVertexShader: {
  47468. name: string;
  47469. shader: string;
  47470. };
  47471. }
  47472. declare module BABYLON {
  47473. /**
  47474. * This represents a GPU particle system in Babylon
  47475. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  47476. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  47477. */
  47478. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  47479. /**
  47480. * The layer mask we are rendering the particles through.
  47481. */
  47482. layerMask: number;
  47483. private _capacity;
  47484. private _activeCount;
  47485. private _currentActiveCount;
  47486. private _accumulatedCount;
  47487. private _renderEffect;
  47488. private _updateEffect;
  47489. private _buffer0;
  47490. private _buffer1;
  47491. private _spriteBuffer;
  47492. private _updateVAO;
  47493. private _renderVAO;
  47494. private _targetIndex;
  47495. private _sourceBuffer;
  47496. private _targetBuffer;
  47497. private _engine;
  47498. private _currentRenderId;
  47499. private _started;
  47500. private _stopped;
  47501. private _timeDelta;
  47502. private _randomTexture;
  47503. private _randomTexture2;
  47504. private _attributesStrideSize;
  47505. private _updateEffectOptions;
  47506. private _randomTextureSize;
  47507. private _actualFrame;
  47508. private readonly _rawTextureWidth;
  47509. /**
  47510. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  47511. */
  47512. static readonly IsSupported: boolean;
  47513. /**
  47514. * An event triggered when the system is disposed.
  47515. */
  47516. onDisposeObservable: Observable<GPUParticleSystem>;
  47517. /**
  47518. * Gets the maximum number of particles active at the same time.
  47519. * @returns The max number of active particles.
  47520. */
  47521. getCapacity(): number;
  47522. /**
  47523. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  47524. * to override the particles.
  47525. */
  47526. forceDepthWrite: boolean;
  47527. /**
  47528. * Gets or set the number of active particles
  47529. */
  47530. activeParticleCount: number;
  47531. private _preWarmDone;
  47532. /**
  47533. * Is this system ready to be used/rendered
  47534. * @return true if the system is ready
  47535. */
  47536. isReady(): boolean;
  47537. /**
  47538. * Gets if the system has been started. (Note: this will still be true after stop is called)
  47539. * @returns True if it has been started, otherwise false.
  47540. */
  47541. isStarted(): boolean;
  47542. /**
  47543. * Starts the particle system and begins to emit
  47544. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  47545. */
  47546. start(delay?: number): void;
  47547. /**
  47548. * Stops the particle system.
  47549. */
  47550. stop(): void;
  47551. /**
  47552. * Remove all active particles
  47553. */
  47554. reset(): void;
  47555. /**
  47556. * Returns the string "GPUParticleSystem"
  47557. * @returns a string containing the class name
  47558. */
  47559. getClassName(): string;
  47560. private _colorGradientsTexture;
  47561. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  47562. /**
  47563. * Adds a new color gradient
  47564. * @param gradient defines the gradient to use (between 0 and 1)
  47565. * @param color1 defines the color to affect to the specified gradient
  47566. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  47567. * @returns the current particle system
  47568. */
  47569. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  47570. /**
  47571. * Remove a specific color gradient
  47572. * @param gradient defines the gradient to remove
  47573. * @returns the current particle system
  47574. */
  47575. removeColorGradient(gradient: number): GPUParticleSystem;
  47576. private _angularSpeedGradientsTexture;
  47577. private _sizeGradientsTexture;
  47578. private _velocityGradientsTexture;
  47579. private _limitVelocityGradientsTexture;
  47580. private _dragGradientsTexture;
  47581. private _addFactorGradient;
  47582. /**
  47583. * Adds a new size gradient
  47584. * @param gradient defines the gradient to use (between 0 and 1)
  47585. * @param factor defines the size factor to affect to the specified gradient
  47586. * @returns the current particle system
  47587. */
  47588. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  47589. /**
  47590. * Remove a specific size gradient
  47591. * @param gradient defines the gradient to remove
  47592. * @returns the current particle system
  47593. */
  47594. removeSizeGradient(gradient: number): GPUParticleSystem;
  47595. /**
  47596. * Adds a new angular speed gradient
  47597. * @param gradient defines the gradient to use (between 0 and 1)
  47598. * @param factor defines the angular speed to affect to the specified gradient
  47599. * @returns the current particle system
  47600. */
  47601. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  47602. /**
  47603. * Remove a specific angular speed gradient
  47604. * @param gradient defines the gradient to remove
  47605. * @returns the current particle system
  47606. */
  47607. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  47608. /**
  47609. * Adds a new velocity gradient
  47610. * @param gradient defines the gradient to use (between 0 and 1)
  47611. * @param factor defines the velocity to affect to the specified gradient
  47612. * @returns the current particle system
  47613. */
  47614. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  47615. /**
  47616. * Remove a specific velocity gradient
  47617. * @param gradient defines the gradient to remove
  47618. * @returns the current particle system
  47619. */
  47620. removeVelocityGradient(gradient: number): GPUParticleSystem;
  47621. /**
  47622. * Adds a new limit velocity gradient
  47623. * @param gradient defines the gradient to use (between 0 and 1)
  47624. * @param factor defines the limit velocity value to affect to the specified gradient
  47625. * @returns the current particle system
  47626. */
  47627. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  47628. /**
  47629. * Remove a specific limit velocity gradient
  47630. * @param gradient defines the gradient to remove
  47631. * @returns the current particle system
  47632. */
  47633. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  47634. /**
  47635. * Adds a new drag gradient
  47636. * @param gradient defines the gradient to use (between 0 and 1)
  47637. * @param factor defines the drag value to affect to the specified gradient
  47638. * @returns the current particle system
  47639. */
  47640. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  47641. /**
  47642. * Remove a specific drag gradient
  47643. * @param gradient defines the gradient to remove
  47644. * @returns the current particle system
  47645. */
  47646. removeDragGradient(gradient: number): GPUParticleSystem;
  47647. /**
  47648. * Not supported by GPUParticleSystem
  47649. * @param gradient defines the gradient to use (between 0 and 1)
  47650. * @param factor defines the emit rate value to affect to the specified gradient
  47651. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47652. * @returns the current particle system
  47653. */
  47654. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47655. /**
  47656. * Not supported by GPUParticleSystem
  47657. * @param gradient defines the gradient to remove
  47658. * @returns the current particle system
  47659. */
  47660. removeEmitRateGradient(gradient: number): IParticleSystem;
  47661. /**
  47662. * Not supported by GPUParticleSystem
  47663. * @param gradient defines the gradient to use (between 0 and 1)
  47664. * @param factor defines the start size value to affect to the specified gradient
  47665. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47666. * @returns the current particle system
  47667. */
  47668. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47669. /**
  47670. * Not supported by GPUParticleSystem
  47671. * @param gradient defines the gradient to remove
  47672. * @returns the current particle system
  47673. */
  47674. removeStartSizeGradient(gradient: number): IParticleSystem;
  47675. /**
  47676. * Not supported by GPUParticleSystem
  47677. * @param gradient defines the gradient to use (between 0 and 1)
  47678. * @param min defines the color remap minimal range
  47679. * @param max defines the color remap maximal range
  47680. * @returns the current particle system
  47681. */
  47682. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  47683. /**
  47684. * Not supported by GPUParticleSystem
  47685. * @param gradient defines the gradient to remove
  47686. * @returns the current particle system
  47687. */
  47688. removeColorRemapGradient(): IParticleSystem;
  47689. /**
  47690. * Not supported by GPUParticleSystem
  47691. * @param gradient defines the gradient to use (between 0 and 1)
  47692. * @param min defines the alpha remap minimal range
  47693. * @param max defines the alpha remap maximal range
  47694. * @returns the current particle system
  47695. */
  47696. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  47697. /**
  47698. * Not supported by GPUParticleSystem
  47699. * @param gradient defines the gradient to remove
  47700. * @returns the current particle system
  47701. */
  47702. removeAlphaRemapGradient(): IParticleSystem;
  47703. /**
  47704. * Not supported by GPUParticleSystem
  47705. * @param gradient defines the gradient to use (between 0 and 1)
  47706. * @param color defines the color to affect to the specified gradient
  47707. * @returns the current particle system
  47708. */
  47709. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  47710. /**
  47711. * Not supported by GPUParticleSystem
  47712. * @param gradient defines the gradient to remove
  47713. * @returns the current particle system
  47714. */
  47715. removeRampGradient(): IParticleSystem;
  47716. /**
  47717. * Not supported by GPUParticleSystem
  47718. * @returns the list of ramp gradients
  47719. */
  47720. getRampGradients(): Nullable<Array<Color3Gradient>>;
  47721. /**
  47722. * Not supported by GPUParticleSystem
  47723. * Gets or sets a boolean indicating that ramp gradients must be used
  47724. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  47725. */
  47726. useRampGradients: boolean;
  47727. /**
  47728. * Not supported by GPUParticleSystem
  47729. * @param gradient defines the gradient to use (between 0 and 1)
  47730. * @param factor defines the life time factor to affect to the specified gradient
  47731. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47732. * @returns the current particle system
  47733. */
  47734. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47735. /**
  47736. * Not supported by GPUParticleSystem
  47737. * @param gradient defines the gradient to remove
  47738. * @returns the current particle system
  47739. */
  47740. removeLifeTimeGradient(gradient: number): IParticleSystem;
  47741. /**
  47742. * Instantiates a GPU particle system.
  47743. * 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.
  47744. * @param name The name of the particle system
  47745. * @param options The options used to create the system
  47746. * @param scene The scene the particle system belongs to
  47747. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  47748. */
  47749. constructor(name: string, options: Partial<{
  47750. capacity: number;
  47751. randomTextureSize: number;
  47752. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  47753. protected _reset(): void;
  47754. private _createUpdateVAO;
  47755. private _createRenderVAO;
  47756. private _initialize;
  47757. /** @hidden */ recreateUpdateEffect(): void;
  47758. /** @hidden */ recreateRenderEffect(): void;
  47759. /**
  47760. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  47761. * @param preWarm defines if we are in the pre-warmimg phase
  47762. */
  47763. animate(preWarm?: boolean): void;
  47764. private _createFactorGradientTexture;
  47765. private _createSizeGradientTexture;
  47766. private _createAngularSpeedGradientTexture;
  47767. private _createVelocityGradientTexture;
  47768. private _createLimitVelocityGradientTexture;
  47769. private _createDragGradientTexture;
  47770. private _createColorGradientTexture;
  47771. /**
  47772. * Renders the particle system in its current state
  47773. * @param preWarm defines if the system should only update the particles but not render them
  47774. * @returns the current number of particles
  47775. */
  47776. render(preWarm?: boolean): number;
  47777. /**
  47778. * Rebuilds the particle system
  47779. */
  47780. rebuild(): void;
  47781. private _releaseBuffers;
  47782. private _releaseVAOs;
  47783. /**
  47784. * Disposes the particle system and free the associated resources
  47785. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  47786. */
  47787. dispose(disposeTexture?: boolean): void;
  47788. /**
  47789. * Clones the particle system.
  47790. * @param name The name of the cloned object
  47791. * @param newEmitter The new emitter to use
  47792. * @returns the cloned particle system
  47793. */
  47794. clone(name: string, newEmitter: any): GPUParticleSystem;
  47795. /**
  47796. * Serializes the particle system to a JSON object.
  47797. * @returns the JSON object
  47798. */
  47799. serialize(): any;
  47800. /**
  47801. * Parses a JSON object to create a GPU particle system.
  47802. * @param parsedParticleSystem The JSON object to parse
  47803. * @param scene The scene to create the particle system in
  47804. * @param rootUrl The root url to use to load external dependencies like texture
  47805. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  47806. * @returns the parsed GPU particle system
  47807. */
  47808. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  47809. }
  47810. }
  47811. declare module BABYLON {
  47812. /**
  47813. * Represents a set of particle systems working together to create a specific effect
  47814. */
  47815. export class ParticleSystemSet implements IDisposable {
  47816. private _emitterCreationOptions;
  47817. private _emitterNode;
  47818. /**
  47819. * Gets the particle system list
  47820. */
  47821. systems: IParticleSystem[];
  47822. /**
  47823. * Gets the emitter node used with this set
  47824. */
  47825. readonly emitterNode: Nullable<TransformNode>;
  47826. /**
  47827. * Creates a new emitter mesh as a sphere
  47828. * @param options defines the options used to create the sphere
  47829. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  47830. * @param scene defines the hosting scene
  47831. */
  47832. setEmitterAsSphere(options: {
  47833. diameter: number;
  47834. segments: number;
  47835. color: Color3;
  47836. }, renderingGroupId: number, scene: Scene): void;
  47837. /**
  47838. * Starts all particle systems of the set
  47839. * @param emitter defines an optional mesh to use as emitter for the particle systems
  47840. */
  47841. start(emitter?: AbstractMesh): void;
  47842. /**
  47843. * Release all associated resources
  47844. */
  47845. dispose(): void;
  47846. /**
  47847. * Serialize the set into a JSON compatible object
  47848. * @returns a JSON compatible representation of the set
  47849. */
  47850. serialize(): any;
  47851. /**
  47852. * Parse a new ParticleSystemSet from a serialized source
  47853. * @param data defines a JSON compatible representation of the set
  47854. * @param scene defines the hosting scene
  47855. * @param gpu defines if we want GPU particles or CPU particles
  47856. * @returns a new ParticleSystemSet
  47857. */
  47858. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  47859. }
  47860. }
  47861. declare module BABYLON {
  47862. /**
  47863. * This class is made for on one-liner static method to help creating particle system set.
  47864. */
  47865. export class ParticleHelper {
  47866. /**
  47867. * Gets or sets base Assets URL
  47868. */
  47869. static BaseAssetsUrl: string;
  47870. /**
  47871. * Create a default particle system that you can tweak
  47872. * @param emitter defines the emitter to use
  47873. * @param capacity defines the system capacity (default is 500 particles)
  47874. * @param scene defines the hosting scene
  47875. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  47876. * @returns the new Particle system
  47877. */
  47878. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  47879. /**
  47880. * This is the main static method (one-liner) of this helper to create different particle systems
  47881. * @param type This string represents the type to the particle system to create
  47882. * @param scene The scene where the particle system should live
  47883. * @param gpu If the system will use gpu
  47884. * @returns the ParticleSystemSet created
  47885. */
  47886. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  47887. /**
  47888. * Static function used to export a particle system to a ParticleSystemSet variable.
  47889. * Please note that the emitter shape is not exported
  47890. * @param systems defines the particle systems to export
  47891. * @returns the created particle system set
  47892. */
  47893. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  47894. }
  47895. }
  47896. declare module BABYLON {
  47897. interface Engine {
  47898. /**
  47899. * Create an effect to use with particle systems.
  47900. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  47901. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  47902. * @param uniformsNames defines a list of attribute names
  47903. * @param samplers defines an array of string used to represent textures
  47904. * @param defines defines the string containing the defines to use to compile the shaders
  47905. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  47906. * @param onCompiled defines a function to call when the effect creation is successful
  47907. * @param onError defines a function to call when the effect creation has failed
  47908. * @returns the new Effect
  47909. */
  47910. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  47911. }
  47912. interface Mesh {
  47913. /**
  47914. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  47915. * @returns an array of IParticleSystem
  47916. */
  47917. getEmittedParticleSystems(): IParticleSystem[];
  47918. /**
  47919. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  47920. * @returns an array of IParticleSystem
  47921. */
  47922. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  47923. }
  47924. /**
  47925. * @hidden
  47926. */
  47927. export var _IDoNeedToBeInTheBuild: number;
  47928. }
  47929. declare module BABYLON {
  47930. interface Scene {
  47931. /** @hidden (Backing field) */ physicsEngine: Nullable<IPhysicsEngine>;
  47932. /**
  47933. * Gets the current physics engine
  47934. * @returns a IPhysicsEngine or null if none attached
  47935. */
  47936. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  47937. /**
  47938. * Enables physics to the current scene
  47939. * @param gravity defines the scene's gravity for the physics engine
  47940. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  47941. * @return a boolean indicating if the physics engine was initialized
  47942. */
  47943. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  47944. /**
  47945. * Disables and disposes the physics engine associated with the scene
  47946. */
  47947. disablePhysicsEngine(): void;
  47948. /**
  47949. * Gets a boolean indicating if there is an active physics engine
  47950. * @returns a boolean indicating if there is an active physics engine
  47951. */
  47952. isPhysicsEnabled(): boolean;
  47953. /**
  47954. * Deletes a physics compound impostor
  47955. * @param compound defines the compound to delete
  47956. */
  47957. deleteCompoundImpostor(compound: any): void;
  47958. /**
  47959. * An event triggered when physic simulation is about to be run
  47960. */
  47961. onBeforePhysicsObservable: Observable<Scene>;
  47962. /**
  47963. * An event triggered when physic simulation has been done
  47964. */
  47965. onAfterPhysicsObservable: Observable<Scene>;
  47966. }
  47967. interface AbstractMesh {
  47968. /** @hidden */ physicsImpostor: Nullable<PhysicsImpostor>;
  47969. /**
  47970. * Gets or sets impostor used for physic simulation
  47971. * @see http://doc.babylonjs.com/features/physics_engine
  47972. */
  47973. physicsImpostor: Nullable<PhysicsImpostor>;
  47974. /**
  47975. * Gets the current physics impostor
  47976. * @see http://doc.babylonjs.com/features/physics_engine
  47977. * @returns a physics impostor or null
  47978. */
  47979. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  47980. /** Apply a physic impulse to the mesh
  47981. * @param force defines the force to apply
  47982. * @param contactPoint defines where to apply the force
  47983. * @returns the current mesh
  47984. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47985. */
  47986. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  47987. /**
  47988. * Creates a physic joint between two meshes
  47989. * @param otherMesh defines the other mesh to use
  47990. * @param pivot1 defines the pivot to use on this mesh
  47991. * @param pivot2 defines the pivot to use on the other mesh
  47992. * @param options defines additional options (can be plugin dependent)
  47993. * @returns the current mesh
  47994. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  47995. */
  47996. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  47997. /** @hidden */ disposePhysicsObserver: Nullable<Observer<Node>>;
  47998. }
  47999. /**
  48000. * Defines the physics engine scene component responsible to manage a physics engine
  48001. */
  48002. export class PhysicsEngineSceneComponent implements ISceneComponent {
  48003. /**
  48004. * The component name helpful to identify the component in the list of scene components.
  48005. */
  48006. readonly name: string;
  48007. /**
  48008. * The scene the component belongs to.
  48009. */
  48010. scene: Scene;
  48011. /**
  48012. * Creates a new instance of the component for the given scene
  48013. * @param scene Defines the scene to register the component in
  48014. */
  48015. constructor(scene: Scene);
  48016. /**
  48017. * Registers the component in a given scene
  48018. */
  48019. register(): void;
  48020. /**
  48021. * Rebuilds the elements related to this component in case of
  48022. * context lost for instance.
  48023. */
  48024. rebuild(): void;
  48025. /**
  48026. * Disposes the component and the associated ressources
  48027. */
  48028. dispose(): void;
  48029. }
  48030. }
  48031. declare module BABYLON {
  48032. /**
  48033. * A helper for physics simulations
  48034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48035. */
  48036. export class PhysicsHelper {
  48037. private _scene;
  48038. private _physicsEngine;
  48039. /**
  48040. * Initializes the Physics helper
  48041. * @param scene Babylon.js scene
  48042. */
  48043. constructor(scene: Scene);
  48044. /**
  48045. * Applies a radial explosion impulse
  48046. * @param origin the origin of the explosion
  48047. * @param radius the explosion radius
  48048. * @param strength the explosion strength
  48049. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48050. * @returns A physics radial explosion event, or null
  48051. */
  48052. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48053. /**
  48054. * Applies a radial explosion force
  48055. * @param origin the origin of the explosion
  48056. * @param radius the explosion radius
  48057. * @param strength the explosion strength
  48058. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48059. * @returns A physics radial explosion event, or null
  48060. */
  48061. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48062. /**
  48063. * Creates a gravitational field
  48064. * @param origin the origin of the explosion
  48065. * @param radius the explosion radius
  48066. * @param strength the explosion strength
  48067. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48068. * @returns A physics gravitational field event, or null
  48069. */
  48070. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  48071. /**
  48072. * Creates a physics updraft event
  48073. * @param origin the origin of the updraft
  48074. * @param radius the radius of the updraft
  48075. * @param strength the strength of the updraft
  48076. * @param height the height of the updraft
  48077. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  48078. * @returns A physics updraft event, or null
  48079. */
  48080. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  48081. /**
  48082. * Creates a physics vortex event
  48083. * @param origin the of the vortex
  48084. * @param radius the radius of the vortex
  48085. * @param strength the strength of the vortex
  48086. * @param height the height of the vortex
  48087. * @returns a Physics vortex event, or null
  48088. * A physics vortex event or null
  48089. */
  48090. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  48091. }
  48092. /**
  48093. * Represents a physics radial explosion event
  48094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48095. */
  48096. export class PhysicsRadialExplosionEvent {
  48097. private _scene;
  48098. private _sphere;
  48099. private _sphereOptions;
  48100. private _rays;
  48101. private _dataFetched;
  48102. /**
  48103. * Initializes a radial explosioin event
  48104. * @param scene BabylonJS scene
  48105. */
  48106. constructor(scene: Scene);
  48107. /**
  48108. * Returns the data related to the radial explosion event (sphere & rays).
  48109. * @returns The radial explosion event data
  48110. */
  48111. getData(): PhysicsRadialExplosionEventData;
  48112. /**
  48113. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  48114. * @param impostor A physics imposter
  48115. * @param origin the origin of the explosion
  48116. * @param radius the explosion radius
  48117. * @param strength the explosion strength
  48118. * @param falloff possible options: Constant & Linear
  48119. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  48120. */
  48121. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  48122. /**
  48123. * Disposes the sphere.
  48124. * @param force Specifies if the sphere should be disposed by force
  48125. */
  48126. dispose(force?: boolean): void;
  48127. /*** Helpers ***/
  48128. private _prepareSphere;
  48129. private _intersectsWithSphere;
  48130. }
  48131. /**
  48132. * Represents a gravitational field event
  48133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48134. */
  48135. export class PhysicsGravitationalFieldEvent {
  48136. private _physicsHelper;
  48137. private _scene;
  48138. private _origin;
  48139. private _radius;
  48140. private _strength;
  48141. private _falloff;
  48142. private _tickCallback;
  48143. private _sphere;
  48144. private _dataFetched;
  48145. /**
  48146. * Initializes the physics gravitational field event
  48147. * @param physicsHelper A physics helper
  48148. * @param scene BabylonJS scene
  48149. * @param origin The origin position of the gravitational field event
  48150. * @param radius The radius of the gravitational field event
  48151. * @param strength The strength of the gravitational field event
  48152. * @param falloff The falloff for the gravitational field event
  48153. */
  48154. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  48155. /**
  48156. * Returns the data related to the gravitational field event (sphere).
  48157. * @returns A gravitational field event
  48158. */
  48159. getData(): PhysicsGravitationalFieldEventData;
  48160. /**
  48161. * Enables the gravitational field.
  48162. */
  48163. enable(): void;
  48164. /**
  48165. * Disables the gravitational field.
  48166. */
  48167. disable(): void;
  48168. /**
  48169. * Disposes the sphere.
  48170. * @param force The force to dispose from the gravitational field event
  48171. */
  48172. dispose(force?: boolean): void;
  48173. private _tick;
  48174. }
  48175. /**
  48176. * Represents a physics updraft event
  48177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48178. */
  48179. export class PhysicsUpdraftEvent {
  48180. private _scene;
  48181. private _origin;
  48182. private _radius;
  48183. private _strength;
  48184. private _height;
  48185. private _updraftMode;
  48186. private _physicsEngine;
  48187. private _originTop;
  48188. private _originDirection;
  48189. private _tickCallback;
  48190. private _cylinder;
  48191. private _cylinderPosition;
  48192. private _dataFetched;
  48193. /**
  48194. * Initializes the physics updraft event
  48195. * @param _scene BabylonJS scene
  48196. * @param _origin The origin position of the updraft
  48197. * @param _radius The radius of the updraft
  48198. * @param _strength The strength of the updraft
  48199. * @param _height The height of the updraft
  48200. * @param _updraftMode The mode of the updraft
  48201. */
  48202. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  48203. /**
  48204. * Returns the data related to the updraft event (cylinder).
  48205. * @returns A physics updraft event
  48206. */
  48207. getData(): PhysicsUpdraftEventData;
  48208. /**
  48209. * Enables the updraft.
  48210. */
  48211. enable(): void;
  48212. /**
  48213. * Disables the cortex.
  48214. */
  48215. disable(): void;
  48216. /**
  48217. * Disposes the sphere.
  48218. * @param force Specifies if the updraft should be disposed by force
  48219. */
  48220. dispose(force?: boolean): void;
  48221. private getImpostorForceAndContactPoint;
  48222. private _tick;
  48223. /*** Helpers ***/
  48224. private _prepareCylinder;
  48225. private _intersectsWithCylinder;
  48226. }
  48227. /**
  48228. * Represents a physics vortex event
  48229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48230. */
  48231. export class PhysicsVortexEvent {
  48232. private _scene;
  48233. private _origin;
  48234. private _radius;
  48235. private _strength;
  48236. private _height;
  48237. private _physicsEngine;
  48238. private _originTop;
  48239. private _centripetalForceThreshold;
  48240. private _updraftMultiplier;
  48241. private _tickCallback;
  48242. private _cylinder;
  48243. private _cylinderPosition;
  48244. private _dataFetched;
  48245. /**
  48246. * Initializes the physics vortex event
  48247. * @param _scene The BabylonJS scene
  48248. * @param _origin The origin position of the vortex
  48249. * @param _radius The radius of the vortex
  48250. * @param _strength The strength of the vortex
  48251. * @param _height The height of the vortex
  48252. */
  48253. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  48254. /**
  48255. * Returns the data related to the vortex event (cylinder).
  48256. * @returns The physics vortex event data
  48257. */
  48258. getData(): PhysicsVortexEventData;
  48259. /**
  48260. * Enables the vortex.
  48261. */
  48262. enable(): void;
  48263. /**
  48264. * Disables the cortex.
  48265. */
  48266. disable(): void;
  48267. /**
  48268. * Disposes the sphere.
  48269. * @param force
  48270. */
  48271. dispose(force?: boolean): void;
  48272. private getImpostorForceAndContactPoint;
  48273. private _tick;
  48274. /*** Helpers ***/
  48275. private _prepareCylinder;
  48276. private _intersectsWithCylinder;
  48277. }
  48278. /**
  48279. * The strenght of the force in correspondence to the distance of the affected object
  48280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48281. */
  48282. export enum PhysicsRadialImpulseFalloff {
  48283. /** Defines that impulse is constant in strength across it's whole radius */
  48284. Constant = 0,
  48285. /** DEfines that impulse gets weaker if it's further from the origin */
  48286. Linear = 1
  48287. }
  48288. /**
  48289. * The strength of the force in correspondence to the distance of the affected object
  48290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48291. */
  48292. export enum PhysicsUpdraftMode {
  48293. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  48294. Center = 0,
  48295. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  48296. Perpendicular = 1
  48297. }
  48298. /**
  48299. * Interface for a physics force and contact point
  48300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48301. */
  48302. export interface PhysicsForceAndContactPoint {
  48303. /**
  48304. * The force applied at the contact point
  48305. */
  48306. force: Vector3;
  48307. /**
  48308. * The contact point
  48309. */
  48310. contactPoint: Vector3;
  48311. }
  48312. /**
  48313. * Interface for radial explosion event data
  48314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48315. */
  48316. export interface PhysicsRadialExplosionEventData {
  48317. /**
  48318. * A sphere used for the radial explosion event
  48319. */
  48320. sphere: Mesh;
  48321. /**
  48322. * An array of rays for the radial explosion event
  48323. */
  48324. rays: Array<Ray>;
  48325. }
  48326. /**
  48327. * Interface for gravitational field event data
  48328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48329. */
  48330. export interface PhysicsGravitationalFieldEventData {
  48331. /**
  48332. * A sphere mesh used for the gravitational field event
  48333. */
  48334. sphere: Mesh;
  48335. }
  48336. /**
  48337. * Interface for updraft event data
  48338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48339. */
  48340. export interface PhysicsUpdraftEventData {
  48341. /**
  48342. * A cylinder used for the updraft event
  48343. */
  48344. cylinder: Mesh;
  48345. }
  48346. /**
  48347. * Interface for vortex event data
  48348. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48349. */
  48350. export interface PhysicsVortexEventData {
  48351. /**
  48352. * A cylinder used for the vortex event
  48353. */
  48354. cylinder: Mesh;
  48355. }
  48356. }
  48357. declare module BABYLON {
  48358. /**
  48359. * AmmoJS Physics plugin
  48360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48361. * @see https://github.com/kripken/ammo.js/
  48362. */
  48363. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48364. private _useDeltaForWorldStep;
  48365. /**
  48366. * Reference to the Ammo library
  48367. */
  48368. bjsAMMO: any;
  48369. /**
  48370. * Created ammoJS world which physics bodies are added to
  48371. */
  48372. world: any;
  48373. /**
  48374. * Name of the plugin
  48375. */
  48376. name: string;
  48377. private _timeStep;
  48378. private _fixedTimeStep;
  48379. private _maxSteps;
  48380. private _tmpQuaternion;
  48381. private _tmpAmmoTransform;
  48382. private _tmpAmmoQuaternion;
  48383. private _tmpAmmoConcreteContactResultCallback;
  48384. private _collisionConfiguration;
  48385. private _dispatcher;
  48386. private _overlappingPairCache;
  48387. private _solver;
  48388. private _tmpAmmoVectorA;
  48389. private _tmpAmmoVectorB;
  48390. private _tmpAmmoVectorC;
  48391. private _tmpContactCallbackResult;
  48392. private static readonly DISABLE_COLLISION_FLAG;
  48393. private static readonly KINEMATIC_FLAG;
  48394. private static readonly DISABLE_DEACTIVATION_FLAG;
  48395. /**
  48396. * Initializes the ammoJS plugin
  48397. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48398. * @param ammoInjection can be used to inject your own ammo reference
  48399. */
  48400. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48401. /**
  48402. * Sets the gravity of the physics world (m/(s^2))
  48403. * @param gravity Gravity to set
  48404. */
  48405. setGravity(gravity: Vector3): void;
  48406. /**
  48407. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48408. * @param timeStep timestep to use in seconds
  48409. */
  48410. setTimeStep(timeStep: number): void;
  48411. /**
  48412. * 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)
  48413. * @param fixedTimeStep fixedTimeStep to use in seconds
  48414. */
  48415. setFixedTimeStep(fixedTimeStep: number): void;
  48416. /**
  48417. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48418. * @param maxSteps the maximum number of steps by the physics engine per frame
  48419. */
  48420. setMaxSteps(maxSteps: number): void;
  48421. /**
  48422. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48423. * @returns the current timestep in seconds
  48424. */
  48425. getTimeStep(): number;
  48426. private _isImpostorInContact;
  48427. private _isImpostorPairInContact;
  48428. private _stepSimulation;
  48429. /**
  48430. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48431. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48432. * After the step the babylon meshes are set to the position of the physics imposters
  48433. * @param delta amount of time to step forward
  48434. * @param impostors array of imposters to update before/after the step
  48435. */
  48436. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48437. private _tmpVector;
  48438. private _tmpMatrix;
  48439. /**
  48440. * Applies an implulse on the imposter
  48441. * @param impostor imposter to apply impulse
  48442. * @param force amount of force to be applied to the imposter
  48443. * @param contactPoint the location to apply the impulse on the imposter
  48444. */
  48445. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48446. /**
  48447. * Applies a force on the imposter
  48448. * @param impostor imposter to apply force
  48449. * @param force amount of force to be applied to the imposter
  48450. * @param contactPoint the location to apply the force on the imposter
  48451. */
  48452. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48453. /**
  48454. * Creates a physics body using the plugin
  48455. * @param impostor the imposter to create the physics body on
  48456. */
  48457. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48458. /**
  48459. * Removes the physics body from the imposter and disposes of the body's memory
  48460. * @param impostor imposter to remove the physics body from
  48461. */
  48462. removePhysicsBody(impostor: PhysicsImpostor): void;
  48463. /**
  48464. * Generates a joint
  48465. * @param impostorJoint the imposter joint to create the joint with
  48466. */
  48467. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48468. /**
  48469. * Removes a joint
  48470. * @param impostorJoint the imposter joint to remove the joint from
  48471. */
  48472. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48473. private _addMeshVerts;
  48474. private _createShape;
  48475. /**
  48476. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48477. * @param impostor imposter containing the physics body and babylon object
  48478. */
  48479. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48480. /**
  48481. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48482. * @param impostor imposter containing the physics body and babylon object
  48483. * @param newPosition new position
  48484. * @param newRotation new rotation
  48485. */
  48486. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48487. /**
  48488. * If this plugin is supported
  48489. * @returns true if its supported
  48490. */
  48491. isSupported(): boolean;
  48492. /**
  48493. * Sets the linear velocity of the physics body
  48494. * @param impostor imposter to set the velocity on
  48495. * @param velocity velocity to set
  48496. */
  48497. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48498. /**
  48499. * Sets the angular velocity of the physics body
  48500. * @param impostor imposter to set the velocity on
  48501. * @param velocity velocity to set
  48502. */
  48503. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48504. /**
  48505. * gets the linear velocity
  48506. * @param impostor imposter to get linear velocity from
  48507. * @returns linear velocity
  48508. */
  48509. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48510. /**
  48511. * gets the angular velocity
  48512. * @param impostor imposter to get angular velocity from
  48513. * @returns angular velocity
  48514. */
  48515. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48516. /**
  48517. * Sets the mass of physics body
  48518. * @param impostor imposter to set the mass on
  48519. * @param mass mass to set
  48520. */
  48521. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48522. /**
  48523. * Gets the mass of the physics body
  48524. * @param impostor imposter to get the mass from
  48525. * @returns mass
  48526. */
  48527. getBodyMass(impostor: PhysicsImpostor): number;
  48528. /**
  48529. * Gets friction of the impostor
  48530. * @param impostor impostor to get friction from
  48531. * @returns friction value
  48532. */
  48533. getBodyFriction(impostor: PhysicsImpostor): number;
  48534. /**
  48535. * Sets friction of the impostor
  48536. * @param impostor impostor to set friction on
  48537. * @param friction friction value
  48538. */
  48539. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48540. /**
  48541. * Gets restitution of the impostor
  48542. * @param impostor impostor to get restitution from
  48543. * @returns restitution value
  48544. */
  48545. getBodyRestitution(impostor: PhysicsImpostor): number;
  48546. /**
  48547. * Sets resitution of the impostor
  48548. * @param impostor impostor to set resitution on
  48549. * @param restitution resitution value
  48550. */
  48551. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48552. /**
  48553. * Sleeps the physics body and stops it from being active
  48554. * @param impostor impostor to sleep
  48555. */
  48556. sleepBody(impostor: PhysicsImpostor): void;
  48557. /**
  48558. * Activates the physics body
  48559. * @param impostor impostor to activate
  48560. */
  48561. wakeUpBody(impostor: PhysicsImpostor): void;
  48562. /**
  48563. * Updates the distance parameters of the joint
  48564. * @param joint joint to update
  48565. * @param maxDistance maximum distance of the joint
  48566. * @param minDistance minimum distance of the joint
  48567. */
  48568. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48569. /**
  48570. * Sets a motor on the joint
  48571. * @param joint joint to set motor on
  48572. * @param speed speed of the motor
  48573. * @param maxForce maximum force of the motor
  48574. * @param motorIndex index of the motor
  48575. */
  48576. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48577. /**
  48578. * Sets the motors limit
  48579. * @param joint joint to set limit on
  48580. * @param upperLimit upper limit
  48581. * @param lowerLimit lower limit
  48582. */
  48583. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48584. /**
  48585. * Syncs the position and rotation of a mesh with the impostor
  48586. * @param mesh mesh to sync
  48587. * @param impostor impostor to update the mesh with
  48588. */
  48589. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48590. /**
  48591. * Gets the radius of the impostor
  48592. * @param impostor impostor to get radius from
  48593. * @returns the radius
  48594. */
  48595. getRadius(impostor: PhysicsImpostor): number;
  48596. /**
  48597. * Gets the box size of the impostor
  48598. * @param impostor impostor to get box size from
  48599. * @param result the resulting box size
  48600. */
  48601. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48602. /**
  48603. * Disposes of the impostor
  48604. */
  48605. dispose(): void;
  48606. }
  48607. }
  48608. declare module BABYLON {
  48609. /** @hidden */
  48610. export var blackAndWhitePixelShader: {
  48611. name: string;
  48612. shader: string;
  48613. };
  48614. }
  48615. declare module BABYLON {
  48616. /**
  48617. * Post process used to render in black and white
  48618. */
  48619. export class BlackAndWhitePostProcess extends PostProcess {
  48620. /**
  48621. * Linear about to convert he result to black and white (default: 1)
  48622. */
  48623. degree: number;
  48624. /**
  48625. * Creates a black and white post process
  48626. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  48627. * @param name The name of the effect.
  48628. * @param options The required width/height ratio to downsize to before computing the render pass.
  48629. * @param camera The camera to apply the render pass to.
  48630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48631. * @param engine The engine which the post process will be applied. (default: current engine)
  48632. * @param reusable If the post process can be reused on the same frame. (default: false)
  48633. */
  48634. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  48635. }
  48636. }
  48637. declare module BABYLON {
  48638. /**
  48639. * This represents a set of one or more post processes in Babylon.
  48640. * A post process can be used to apply a shader to a texture after it is rendered.
  48641. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48642. */
  48643. export class PostProcessRenderEffect {
  48644. private _postProcesses;
  48645. private _getPostProcesses;
  48646. private _singleInstance;
  48647. private _cameras;
  48648. private _indicesForCamera;
  48649. /**
  48650. * Name of the effect
  48651. * @hidden
  48652. */ name: string;
  48653. /**
  48654. * Instantiates a post process render effect.
  48655. * A post process can be used to apply a shader to a texture after it is rendered.
  48656. * @param engine The engine the effect is tied to
  48657. * @param name The name of the effect
  48658. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  48659. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  48660. */
  48661. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  48662. /**
  48663. * Checks if all the post processes in the effect are supported.
  48664. */
  48665. readonly isSupported: boolean;
  48666. /**
  48667. * Updates the current state of the effect
  48668. * @hidden
  48669. */ update(): void;
  48670. /**
  48671. * Attaches the effect on cameras
  48672. * @param cameras The camera to attach to.
  48673. * @hidden
  48674. */ attachCameras(cameras: Camera): void;
  48675. /**
  48676. * Attaches the effect on cameras
  48677. * @param cameras The camera to attach to.
  48678. * @hidden
  48679. */ attachCameras(cameras: Camera[]): void;
  48680. /**
  48681. * Detatches the effect on cameras
  48682. * @param cameras The camera to detatch from.
  48683. * @hidden
  48684. */ detachCameras(cameras: Camera): void;
  48685. /**
  48686. * Detatches the effect on cameras
  48687. * @param cameras The camera to detatch from.
  48688. * @hidden
  48689. */ detachCameras(cameras: Camera[]): void;
  48690. /**
  48691. * Enables the effect on given cameras
  48692. * @param cameras The camera to enable.
  48693. * @hidden
  48694. */ enable(cameras: Camera): void;
  48695. /**
  48696. * Enables the effect on given cameras
  48697. * @param cameras The camera to enable.
  48698. * @hidden
  48699. */ enable(cameras: Nullable<Camera[]>): void;
  48700. /**
  48701. * Disables the effect on the given cameras
  48702. * @param cameras The camera to disable.
  48703. * @hidden
  48704. */ disable(cameras: Camera): void;
  48705. /**
  48706. * Disables the effect on the given cameras
  48707. * @param cameras The camera to disable.
  48708. * @hidden
  48709. */ disable(cameras: Nullable<Camera[]>): void;
  48710. /**
  48711. * Gets a list of the post processes contained in the effect.
  48712. * @param camera The camera to get the post processes on.
  48713. * @returns The list of the post processes in the effect.
  48714. */
  48715. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  48716. }
  48717. }
  48718. declare module BABYLON {
  48719. /** @hidden */
  48720. export var extractHighlightsPixelShader: {
  48721. name: string;
  48722. shader: string;
  48723. };
  48724. }
  48725. declare module BABYLON {
  48726. /**
  48727. * 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.
  48728. */
  48729. export class ExtractHighlightsPostProcess extends PostProcess {
  48730. /**
  48731. * The luminance threshold, pixels below this value will be set to black.
  48732. */
  48733. threshold: number;
  48734. /** @hidden */ exposure: number;
  48735. /**
  48736. * Post process which has the input texture to be used when performing highlight extraction
  48737. * @hidden
  48738. */ inputPostProcess: Nullable<PostProcess>;
  48739. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48740. }
  48741. }
  48742. declare module BABYLON {
  48743. /** @hidden */
  48744. export var bloomMergePixelShader: {
  48745. name: string;
  48746. shader: string;
  48747. };
  48748. }
  48749. declare module BABYLON {
  48750. /**
  48751. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  48752. */
  48753. export class BloomMergePostProcess extends PostProcess {
  48754. /** Weight of the bloom to be added to the original input. */
  48755. weight: number;
  48756. /**
  48757. * Creates a new instance of @see BloomMergePostProcess
  48758. * @param name The name of the effect.
  48759. * @param originalFromInput Post process which's input will be used for the merge.
  48760. * @param blurred Blurred highlights post process which's output will be used.
  48761. * @param weight Weight of the bloom to be added to the original input.
  48762. * @param options The required width/height ratio to downsize to before computing the render pass.
  48763. * @param camera The camera to apply the render pass to.
  48764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48765. * @param engine The engine which the post process will be applied. (default: current engine)
  48766. * @param reusable If the post process can be reused on the same frame. (default: false)
  48767. * @param textureType Type of textures used when performing the post process. (default: 0)
  48768. * @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)
  48769. */
  48770. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  48771. /** Weight of the bloom to be added to the original input. */
  48772. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48773. }
  48774. }
  48775. declare module BABYLON {
  48776. /**
  48777. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  48778. */
  48779. export class BloomEffect extends PostProcessRenderEffect {
  48780. private bloomScale;
  48781. /**
  48782. * @hidden Internal
  48783. */ effects: Array<PostProcess>;
  48784. /**
  48785. * @hidden Internal
  48786. */ downscale: ExtractHighlightsPostProcess;
  48787. private _blurX;
  48788. private _blurY;
  48789. private _merge;
  48790. /**
  48791. * The luminance threshold to find bright areas of the image to bloom.
  48792. */
  48793. threshold: number;
  48794. /**
  48795. * The strength of the bloom.
  48796. */
  48797. weight: number;
  48798. /**
  48799. * Specifies the size of the bloom blur kernel, relative to the final output size
  48800. */
  48801. kernel: number;
  48802. /**
  48803. * Creates a new instance of @see BloomEffect
  48804. * @param scene The scene the effect belongs to.
  48805. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  48806. * @param bloomKernel The size of the kernel to be used when applying the blur.
  48807. * @param bloomWeight The the strength of bloom.
  48808. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  48809. * @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)
  48810. */
  48811. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  48812. /**
  48813. * Disposes each of the internal effects for a given camera.
  48814. * @param camera The camera to dispose the effect on.
  48815. */
  48816. disposeEffects(camera: Camera): void;
  48817. /**
  48818. * @hidden Internal
  48819. */ updateEffects(): void;
  48820. /**
  48821. * Internal
  48822. * @returns if all the contained post processes are ready.
  48823. * @hidden
  48824. */ isReady(): boolean;
  48825. }
  48826. }
  48827. declare module BABYLON {
  48828. /** @hidden */
  48829. export var chromaticAberrationPixelShader: {
  48830. name: string;
  48831. shader: string;
  48832. };
  48833. }
  48834. declare module BABYLON {
  48835. /**
  48836. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  48837. */
  48838. export class ChromaticAberrationPostProcess extends PostProcess {
  48839. /**
  48840. * The amount of seperation of rgb channels (default: 30)
  48841. */
  48842. aberrationAmount: number;
  48843. /**
  48844. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  48845. */
  48846. radialIntensity: number;
  48847. /**
  48848. * 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))
  48849. */
  48850. direction: Vector2;
  48851. /**
  48852. * 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))
  48853. */
  48854. centerPosition: Vector2;
  48855. /**
  48856. * Creates a new instance ChromaticAberrationPostProcess
  48857. * @param name The name of the effect.
  48858. * @param screenWidth The width of the screen to apply the effect on.
  48859. * @param screenHeight The height of the screen to apply the effect on.
  48860. * @param options The required width/height ratio to downsize to before computing the render pass.
  48861. * @param camera The camera to apply the render pass to.
  48862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48863. * @param engine The engine which the post process will be applied. (default: current engine)
  48864. * @param reusable If the post process can be reused on the same frame. (default: false)
  48865. * @param textureType Type of textures used when performing the post process. (default: 0)
  48866. * @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)
  48867. */
  48868. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48869. }
  48870. }
  48871. declare module BABYLON {
  48872. /** @hidden */
  48873. export var circleOfConfusionPixelShader: {
  48874. name: string;
  48875. shader: string;
  48876. };
  48877. }
  48878. declare module BABYLON {
  48879. /**
  48880. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  48881. */
  48882. export class CircleOfConfusionPostProcess extends PostProcess {
  48883. /**
  48884. * 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.
  48885. */
  48886. lensSize: number;
  48887. /**
  48888. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  48889. */
  48890. fStop: number;
  48891. /**
  48892. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  48893. */
  48894. focusDistance: number;
  48895. /**
  48896. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  48897. */
  48898. focalLength: number;
  48899. private _depthTexture;
  48900. /**
  48901. * Creates a new instance CircleOfConfusionPostProcess
  48902. * @param name The name of the effect.
  48903. * @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.
  48904. * @param options The required width/height ratio to downsize to before computing the render pass.
  48905. * @param camera The camera to apply the render pass to.
  48906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48907. * @param engine The engine which the post process will be applied. (default: current engine)
  48908. * @param reusable If the post process can be reused on the same frame. (default: false)
  48909. * @param textureType Type of textures used when performing the post process. (default: 0)
  48910. * @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)
  48911. */
  48912. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48913. /**
  48914. * 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.
  48915. */
  48916. depthTexture: RenderTargetTexture;
  48917. }
  48918. }
  48919. declare module BABYLON {
  48920. /** @hidden */
  48921. export var colorCorrectionPixelShader: {
  48922. name: string;
  48923. shader: string;
  48924. };
  48925. }
  48926. declare module BABYLON {
  48927. /**
  48928. *
  48929. * This post-process allows the modification of rendered colors by using
  48930. * a 'look-up table' (LUT). This effect is also called Color Grading.
  48931. *
  48932. * The object needs to be provided an url to a texture containing the color
  48933. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  48934. * Use an image editing software to tweak the LUT to match your needs.
  48935. *
  48936. * For an example of a color LUT, see here:
  48937. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  48938. * For explanations on color grading, see here:
  48939. * @see http://udn.epicgames.com/Three/ColorGrading.html
  48940. *
  48941. */
  48942. export class ColorCorrectionPostProcess extends PostProcess {
  48943. private _colorTableTexture;
  48944. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  48945. }
  48946. }
  48947. declare module BABYLON {
  48948. /** @hidden */
  48949. export var convolutionPixelShader: {
  48950. name: string;
  48951. shader: string;
  48952. };
  48953. }
  48954. declare module BABYLON {
  48955. /**
  48956. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  48957. * input texture to perform effects such as edge detection or sharpening
  48958. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  48959. */
  48960. export class ConvolutionPostProcess extends PostProcess {
  48961. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  48962. kernel: number[];
  48963. /**
  48964. * Creates a new instance ConvolutionPostProcess
  48965. * @param name The name of the effect.
  48966. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  48967. * @param options The required width/height ratio to downsize to before computing the render pass.
  48968. * @param camera The camera to apply the render pass to.
  48969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48970. * @param engine The engine which the post process will be applied. (default: current engine)
  48971. * @param reusable If the post process can be reused on the same frame. (default: false)
  48972. * @param textureType Type of textures used when performing the post process. (default: 0)
  48973. */
  48974. constructor(name: string,
  48975. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  48976. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  48977. /**
  48978. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48979. */
  48980. static EdgeDetect0Kernel: number[];
  48981. /**
  48982. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48983. */
  48984. static EdgeDetect1Kernel: number[];
  48985. /**
  48986. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48987. */
  48988. static EdgeDetect2Kernel: number[];
  48989. /**
  48990. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48991. */
  48992. static SharpenKernel: number[];
  48993. /**
  48994. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48995. */
  48996. static EmbossKernel: number[];
  48997. /**
  48998. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48999. */
  49000. static GaussianKernel: number[];
  49001. }
  49002. }
  49003. declare module BABYLON {
  49004. /**
  49005. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  49006. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  49007. * based on samples that have a large difference in distance than the center pixel.
  49008. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  49009. */
  49010. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  49011. direction: Vector2;
  49012. /**
  49013. * Creates a new instance CircleOfConfusionPostProcess
  49014. * @param name The name of the effect.
  49015. * @param scene The scene the effect belongs to.
  49016. * @param direction The direction the blur should be applied.
  49017. * @param kernel The size of the kernel used to blur.
  49018. * @param options The required width/height ratio to downsize to before computing the render pass.
  49019. * @param camera The camera to apply the render pass to.
  49020. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  49021. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  49022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49023. * @param engine The engine which the post process will be applied. (default: current engine)
  49024. * @param reusable If the post process can be reused on the same frame. (default: false)
  49025. * @param textureType Type of textures used when performing the post process. (default: 0)
  49026. * @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)
  49027. */
  49028. 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);
  49029. }
  49030. }
  49031. declare module BABYLON {
  49032. /** @hidden */
  49033. export var depthOfFieldMergePixelShader: {
  49034. name: string;
  49035. shader: string;
  49036. };
  49037. }
  49038. declare module BABYLON {
  49039. /**
  49040. * Options to be set when merging outputs from the default pipeline.
  49041. */
  49042. export class DepthOfFieldMergePostProcessOptions {
  49043. /**
  49044. * The original image to merge on top of
  49045. */
  49046. originalFromInput: PostProcess;
  49047. /**
  49048. * Parameters to perform the merge of the depth of field effect
  49049. */
  49050. depthOfField?: {
  49051. circleOfConfusion: PostProcess;
  49052. blurSteps: Array<PostProcess>;
  49053. };
  49054. /**
  49055. * Parameters to perform the merge of bloom effect
  49056. */
  49057. bloom?: {
  49058. blurred: PostProcess;
  49059. weight: number;
  49060. };
  49061. }
  49062. /**
  49063. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  49064. */
  49065. export class DepthOfFieldMergePostProcess extends PostProcess {
  49066. private blurSteps;
  49067. /**
  49068. * Creates a new instance of DepthOfFieldMergePostProcess
  49069. * @param name The name of the effect.
  49070. * @param originalFromInput Post process which's input will be used for the merge.
  49071. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  49072. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  49073. * @param options The required width/height ratio to downsize to before computing the render pass.
  49074. * @param camera The camera to apply the render pass to.
  49075. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49076. * @param engine The engine which the post process will be applied. (default: current engine)
  49077. * @param reusable If the post process can be reused on the same frame. (default: false)
  49078. * @param textureType Type of textures used when performing the post process. (default: 0)
  49079. * @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)
  49080. */
  49081. 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);
  49082. /**
  49083. * Updates the effect with the current post process compile time values and recompiles the shader.
  49084. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  49085. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  49086. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  49087. * @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
  49088. * @param onCompiled Called when the shader has been compiled.
  49089. * @param onError Called if there is an error when compiling a shader.
  49090. */
  49091. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  49092. }
  49093. }
  49094. declare module BABYLON {
  49095. /**
  49096. * Specifies the level of max blur that should be applied when using the depth of field effect
  49097. */
  49098. export enum DepthOfFieldEffectBlurLevel {
  49099. /**
  49100. * Subtle blur
  49101. */
  49102. Low = 0,
  49103. /**
  49104. * Medium blur
  49105. */
  49106. Medium = 1,
  49107. /**
  49108. * Large blur
  49109. */
  49110. High = 2
  49111. }
  49112. /**
  49113. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  49114. */
  49115. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  49116. private _circleOfConfusion;
  49117. /**
  49118. * @hidden Internal, blurs from high to low
  49119. */ depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  49120. private _depthOfFieldBlurY;
  49121. private _dofMerge;
  49122. /**
  49123. * @hidden Internal post processes in depth of field effect
  49124. */ effects: Array<PostProcess>;
  49125. /**
  49126. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  49127. */
  49128. focalLength: number;
  49129. /**
  49130. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  49131. */
  49132. fStop: number;
  49133. /**
  49134. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  49135. */
  49136. focusDistance: number;
  49137. /**
  49138. * 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.
  49139. */
  49140. lensSize: number;
  49141. /**
  49142. * Creates a new instance DepthOfFieldEffect
  49143. * @param scene The scene the effect belongs to.
  49144. * @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.
  49145. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  49146. * @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)
  49147. */
  49148. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  49149. /**
  49150. * 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.
  49151. */
  49152. depthTexture: RenderTargetTexture;
  49153. /**
  49154. * Disposes each of the internal effects for a given camera.
  49155. * @param camera The camera to dispose the effect on.
  49156. */
  49157. disposeEffects(camera: Camera): void;
  49158. /**
  49159. * @hidden Internal
  49160. */ updateEffects(): void;
  49161. /**
  49162. * Internal
  49163. * @returns if all the contained post processes are ready.
  49164. * @hidden
  49165. */ isReady(): boolean;
  49166. }
  49167. }
  49168. declare module BABYLON {
  49169. /** @hidden */
  49170. export var displayPassPixelShader: {
  49171. name: string;
  49172. shader: string;
  49173. };
  49174. }
  49175. declare module BABYLON {
  49176. /**
  49177. * DisplayPassPostProcess which produces an output the same as it's input
  49178. */
  49179. export class DisplayPassPostProcess extends PostProcess {
  49180. /**
  49181. * Creates the DisplayPassPostProcess
  49182. * @param name The name of the effect.
  49183. * @param options The required width/height ratio to downsize to before computing the render pass.
  49184. * @param camera The camera to apply the render pass to.
  49185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49186. * @param engine The engine which the post process will be applied. (default: current engine)
  49187. * @param reusable If the post process can be reused on the same frame. (default: false)
  49188. */
  49189. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49190. }
  49191. }
  49192. declare module BABYLON {
  49193. /** @hidden */
  49194. export var filterPixelShader: {
  49195. name: string;
  49196. shader: string;
  49197. };
  49198. }
  49199. declare module BABYLON {
  49200. /**
  49201. * Applies a kernel filter to the image
  49202. */
  49203. export class FilterPostProcess extends PostProcess {
  49204. /** The matrix to be applied to the image */
  49205. kernelMatrix: Matrix;
  49206. /**
  49207. *
  49208. * @param name The name of the effect.
  49209. * @param kernelMatrix The matrix to be applied to the image
  49210. * @param options The required width/height ratio to downsize to before computing the render pass.
  49211. * @param camera The camera to apply the render pass to.
  49212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49213. * @param engine The engine which the post process will be applied. (default: current engine)
  49214. * @param reusable If the post process can be reused on the same frame. (default: false)
  49215. */
  49216. constructor(name: string,
  49217. /** The matrix to be applied to the image */
  49218. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49219. }
  49220. }
  49221. declare module BABYLON {
  49222. /** @hidden */
  49223. export var fxaaPixelShader: {
  49224. name: string;
  49225. shader: string;
  49226. };
  49227. }
  49228. declare module BABYLON {
  49229. /** @hidden */
  49230. export var fxaaVertexShader: {
  49231. name: string;
  49232. shader: string;
  49233. };
  49234. }
  49235. declare module BABYLON {
  49236. /**
  49237. * Fxaa post process
  49238. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  49239. */
  49240. export class FxaaPostProcess extends PostProcess {
  49241. /** @hidden */
  49242. texelWidth: number;
  49243. /** @hidden */
  49244. texelHeight: number;
  49245. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49246. private _getDefines;
  49247. }
  49248. }
  49249. declare module BABYLON {
  49250. /** @hidden */
  49251. export var grainPixelShader: {
  49252. name: string;
  49253. shader: string;
  49254. };
  49255. }
  49256. declare module BABYLON {
  49257. /**
  49258. * The GrainPostProcess adds noise to the image at mid luminance levels
  49259. */
  49260. export class GrainPostProcess extends PostProcess {
  49261. /**
  49262. * The intensity of the grain added (default: 30)
  49263. */
  49264. intensity: number;
  49265. /**
  49266. * If the grain should be randomized on every frame
  49267. */
  49268. animated: boolean;
  49269. /**
  49270. * Creates a new instance of @see GrainPostProcess
  49271. * @param name The name of the effect.
  49272. * @param options The required width/height ratio to downsize to before computing the render pass.
  49273. * @param camera The camera to apply the render pass to.
  49274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49275. * @param engine The engine which the post process will be applied. (default: current engine)
  49276. * @param reusable If the post process can be reused on the same frame. (default: false)
  49277. * @param textureType Type of textures used when performing the post process. (default: 0)
  49278. * @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)
  49279. */
  49280. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49281. }
  49282. }
  49283. declare module BABYLON {
  49284. /** @hidden */
  49285. export var highlightsPixelShader: {
  49286. name: string;
  49287. shader: string;
  49288. };
  49289. }
  49290. declare module BABYLON {
  49291. /**
  49292. * Extracts highlights from the image
  49293. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49294. */
  49295. export class HighlightsPostProcess extends PostProcess {
  49296. /**
  49297. * Extracts highlights from the image
  49298. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49299. * @param name The name of the effect.
  49300. * @param options The required width/height ratio to downsize to before computing the render pass.
  49301. * @param camera The camera to apply the render pass to.
  49302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49303. * @param engine The engine which the post process will be applied. (default: current engine)
  49304. * @param reusable If the post process can be reused on the same frame. (default: false)
  49305. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  49306. */
  49307. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49308. }
  49309. }
  49310. declare module BABYLON {
  49311. /** @hidden */
  49312. export var mrtFragmentDeclaration: {
  49313. name: string;
  49314. shader: string;
  49315. };
  49316. }
  49317. declare module BABYLON {
  49318. /** @hidden */
  49319. export var geometryPixelShader: {
  49320. name: string;
  49321. shader: string;
  49322. };
  49323. }
  49324. declare module BABYLON {
  49325. /** @hidden */
  49326. export var geometryVertexShader: {
  49327. name: string;
  49328. shader: string;
  49329. };
  49330. }
  49331. declare module BABYLON {
  49332. /**
  49333. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  49334. */
  49335. export class GeometryBufferRenderer {
  49336. /**
  49337. * Constant used to retrieve the position texture index in the G-Buffer textures array
  49338. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  49339. */
  49340. static readonly POSITION_TEXTURE_TYPE: number;
  49341. /**
  49342. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  49343. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  49344. */
  49345. static readonly VELOCITY_TEXTURE_TYPE: number;
  49346. /**
  49347. * Dictionary used to store the previous transformation matrices of each rendered mesh
  49348. * in order to compute objects velocities when enableVelocity is set to "true"
  49349. * @hidden
  49350. */ previousTransformationMatrices: {
  49351. [index: number]: Matrix;
  49352. };
  49353. private _scene;
  49354. private _multiRenderTarget;
  49355. private _ratio;
  49356. private _enablePosition;
  49357. private _enableVelocity;
  49358. private _positionIndex;
  49359. private _velocityIndex;
  49360. protected _effect: Effect;
  49361. protected _cachedDefines: string;
  49362. /**
  49363. * Set the render list (meshes to be rendered) used in the G buffer.
  49364. */
  49365. renderList: Mesh[];
  49366. /**
  49367. * Gets wether or not G buffer are supported by the running hardware.
  49368. * This requires draw buffer supports
  49369. */
  49370. readonly isSupported: boolean;
  49371. /**
  49372. * Returns the index of the given texture type in the G-Buffer textures array
  49373. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  49374. * @returns the index of the given texture type in the G-Buffer textures array
  49375. */
  49376. getTextureIndex(textureType: number): number;
  49377. /**
  49378. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  49379. */
  49380. /**
  49381. * Sets whether or not objects positions are enabled for the G buffer.
  49382. */
  49383. enablePosition: boolean;
  49384. /**
  49385. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  49386. */
  49387. /**
  49388. * Sets wether or not objects velocities are enabled for the G buffer.
  49389. */
  49390. enableVelocity: boolean;
  49391. /**
  49392. * Gets the scene associated with the buffer.
  49393. */
  49394. readonly scene: Scene;
  49395. /**
  49396. * Gets the ratio used by the buffer during its creation.
  49397. * How big is the buffer related to the main canvas.
  49398. */
  49399. readonly ratio: number;
  49400. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  49401. /**
  49402. * Creates a new G Buffer for the scene
  49403. * @param scene The scene the buffer belongs to
  49404. * @param ratio How big is the buffer related to the main canvas.
  49405. */
  49406. constructor(scene: Scene, ratio?: number);
  49407. /**
  49408. * Checks wether everything is ready to render a submesh to the G buffer.
  49409. * @param subMesh the submesh to check readiness for
  49410. * @param useInstances is the mesh drawn using instance or not
  49411. * @returns true if ready otherwise false
  49412. */
  49413. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49414. /**
  49415. * Gets the current underlying G Buffer.
  49416. * @returns the buffer
  49417. */
  49418. getGBuffer(): MultiRenderTarget;
  49419. /**
  49420. * Gets the number of samples used to render the buffer (anti aliasing).
  49421. */
  49422. /**
  49423. * Sets the number of samples used to render the buffer (anti aliasing).
  49424. */
  49425. samples: number;
  49426. /**
  49427. * Disposes the renderer and frees up associated resources.
  49428. */
  49429. dispose(): void;
  49430. protected _createRenderTargets(): void;
  49431. }
  49432. }
  49433. declare module BABYLON {
  49434. /** @hidden */
  49435. export var motionBlurPixelShader: {
  49436. name: string;
  49437. shader: string;
  49438. };
  49439. }
  49440. declare module BABYLON {
  49441. /**
  49442. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  49443. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  49444. * As an example, all you have to do is to create the post-process:
  49445. * var mb = new BABYLON.MotionBlurPostProcess(
  49446. * 'mb', // The name of the effect.
  49447. * scene, // The scene containing the objects to blur according to their velocity.
  49448. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  49449. * camera // The camera to apply the render pass to.
  49450. * );
  49451. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  49452. */
  49453. export class MotionBlurPostProcess extends PostProcess {
  49454. /**
  49455. * Defines how much the image is blurred by the movement. Default value is equal to 1
  49456. */
  49457. motionStrength: number;
  49458. /**
  49459. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  49460. */
  49461. /**
  49462. * Sets the number of iterations to be used for motion blur quality
  49463. */
  49464. motionBlurSamples: number;
  49465. private _motionBlurSamples;
  49466. private _geometryBufferRenderer;
  49467. /**
  49468. * Creates a new instance MotionBlurPostProcess
  49469. * @param name The name of the effect.
  49470. * @param scene The scene containing the objects to blur according to their velocity.
  49471. * @param options The required width/height ratio to downsize to before computing the render pass.
  49472. * @param camera The camera to apply the render pass to.
  49473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49474. * @param engine The engine which the post process will be applied. (default: current engine)
  49475. * @param reusable If the post process can be reused on the same frame. (default: false)
  49476. * @param textureType Type of textures used when performing the post process. (default: 0)
  49477. * @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)
  49478. */
  49479. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49480. /**
  49481. * Disposes the post process.
  49482. * @param camera The camera to dispose the post process on.
  49483. */
  49484. dispose(camera?: Camera): void;
  49485. }
  49486. }
  49487. declare module BABYLON {
  49488. /** @hidden */
  49489. export var refractionPixelShader: {
  49490. name: string;
  49491. shader: string;
  49492. };
  49493. }
  49494. declare module BABYLON {
  49495. /**
  49496. * Post process which applies a refractin texture
  49497. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  49498. */
  49499. export class RefractionPostProcess extends PostProcess {
  49500. /** the base color of the refraction (used to taint the rendering) */
  49501. color: Color3;
  49502. /** simulated refraction depth */
  49503. depth: number;
  49504. /** the coefficient of the base color (0 to remove base color tainting) */
  49505. colorLevel: number;
  49506. private _refTexture;
  49507. private _ownRefractionTexture;
  49508. /**
  49509. * Gets or sets the refraction texture
  49510. * Please note that you are responsible for disposing the texture if you set it manually
  49511. */
  49512. refractionTexture: Texture;
  49513. /**
  49514. * Initializes the RefractionPostProcess
  49515. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  49516. * @param name The name of the effect.
  49517. * @param refractionTextureUrl Url of the refraction texture to use
  49518. * @param color the base color of the refraction (used to taint the rendering)
  49519. * @param depth simulated refraction depth
  49520. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  49521. * @param camera The camera to apply the render pass to.
  49522. * @param options The required width/height ratio to downsize to before computing the render pass.
  49523. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49524. * @param engine The engine which the post process will be applied. (default: current engine)
  49525. * @param reusable If the post process can be reused on the same frame. (default: false)
  49526. */
  49527. constructor(name: string, refractionTextureUrl: string,
  49528. /** the base color of the refraction (used to taint the rendering) */
  49529. color: Color3,
  49530. /** simulated refraction depth */
  49531. depth: number,
  49532. /** the coefficient of the base color (0 to remove base color tainting) */
  49533. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49534. /**
  49535. * Disposes of the post process
  49536. * @param camera Camera to dispose post process on
  49537. */
  49538. dispose(camera: Camera): void;
  49539. }
  49540. }
  49541. declare module BABYLON {
  49542. /** @hidden */
  49543. export var sharpenPixelShader: {
  49544. name: string;
  49545. shader: string;
  49546. };
  49547. }
  49548. declare module BABYLON {
  49549. /**
  49550. * The SharpenPostProcess applies a sharpen kernel to every pixel
  49551. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  49552. */
  49553. export class SharpenPostProcess extends PostProcess {
  49554. /**
  49555. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  49556. */
  49557. colorAmount: number;
  49558. /**
  49559. * How much sharpness should be applied (default: 0.3)
  49560. */
  49561. edgeAmount: number;
  49562. /**
  49563. * Creates a new instance ConvolutionPostProcess
  49564. * @param name The name of the effect.
  49565. * @param options The required width/height ratio to downsize to before computing the render pass.
  49566. * @param camera The camera to apply the render pass to.
  49567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49568. * @param engine The engine which the post process will be applied. (default: current engine)
  49569. * @param reusable If the post process can be reused on the same frame. (default: false)
  49570. * @param textureType Type of textures used when performing the post process. (default: 0)
  49571. * @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)
  49572. */
  49573. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49574. }
  49575. }
  49576. declare module BABYLON {
  49577. /**
  49578. * PostProcessRenderPipeline
  49579. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49580. */
  49581. export class PostProcessRenderPipeline {
  49582. private engine;
  49583. private _renderEffects;
  49584. private _renderEffectsForIsolatedPass;
  49585. /**
  49586. * @hidden
  49587. */
  49588. protected _cameras: Camera[];
  49589. /** @hidden */ name: string;
  49590. /**
  49591. * Initializes a PostProcessRenderPipeline
  49592. * @param engine engine to add the pipeline to
  49593. * @param name name of the pipeline
  49594. */
  49595. constructor(engine: Engine, name: string);
  49596. /**
  49597. * "PostProcessRenderPipeline"
  49598. * @returns "PostProcessRenderPipeline"
  49599. */
  49600. getClassName(): string;
  49601. /**
  49602. * If all the render effects in the pipeline are support
  49603. */
  49604. readonly isSupported: boolean;
  49605. /**
  49606. * Adds an effect to the pipeline
  49607. * @param renderEffect the effect to add
  49608. */
  49609. addEffect(renderEffect: PostProcessRenderEffect): void;
  49610. /** @hidden */ rebuild(): void;
  49611. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera): void;
  49612. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49613. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49614. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49615. /** @hidden */ attachCameras(cameras: Camera, unique: boolean): void;
  49616. /** @hidden */ attachCameras(cameras: Camera[], unique: boolean): void;
  49617. /** @hidden */ detachCameras(cameras: Camera): void;
  49618. /** @hidden */ detachCameras(cameras: Nullable<Camera[]>): void;
  49619. /** @hidden */ update(): void;
  49620. /** @hidden */ reset(): void;
  49621. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49622. /**
  49623. * Disposes of the pipeline
  49624. */
  49625. dispose(): void;
  49626. }
  49627. }
  49628. declare module BABYLON {
  49629. /**
  49630. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49631. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49632. */
  49633. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49634. private _scene;
  49635. private _camerasToBeAttached;
  49636. /**
  49637. * ID of the sharpen post process,
  49638. */
  49639. private readonly SharpenPostProcessId;
  49640. /**
  49641. * @ignore
  49642. * ID of the image processing post process;
  49643. */
  49644. readonly ImageProcessingPostProcessId: string;
  49645. /**
  49646. * @ignore
  49647. * ID of the Fast Approximate Anti-Aliasing post process;
  49648. */
  49649. readonly FxaaPostProcessId: string;
  49650. /**
  49651. * ID of the chromatic aberration post process,
  49652. */
  49653. private readonly ChromaticAberrationPostProcessId;
  49654. /**
  49655. * ID of the grain post process
  49656. */
  49657. private readonly GrainPostProcessId;
  49658. /**
  49659. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49660. */
  49661. sharpen: SharpenPostProcess;
  49662. private _sharpenEffect;
  49663. private bloom;
  49664. /**
  49665. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49666. */
  49667. depthOfField: DepthOfFieldEffect;
  49668. /**
  49669. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49670. */
  49671. fxaa: FxaaPostProcess;
  49672. /**
  49673. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49674. */
  49675. imageProcessing: ImageProcessingPostProcess;
  49676. /**
  49677. * Chromatic aberration post process which will shift rgb colors in the image
  49678. */
  49679. chromaticAberration: ChromaticAberrationPostProcess;
  49680. private _chromaticAberrationEffect;
  49681. /**
  49682. * Grain post process which add noise to the image
  49683. */
  49684. grain: GrainPostProcess;
  49685. private _grainEffect;
  49686. /**
  49687. * Glow post process which adds a glow to emmisive areas of the image
  49688. */
  49689. private _glowLayer;
  49690. /**
  49691. * Animations which can be used to tweak settings over a period of time
  49692. */
  49693. animations: Animation[];
  49694. private _imageProcessingConfigurationObserver;
  49695. private _sharpenEnabled;
  49696. private _bloomEnabled;
  49697. private _depthOfFieldEnabled;
  49698. private _depthOfFieldBlurLevel;
  49699. private _fxaaEnabled;
  49700. private _imageProcessingEnabled;
  49701. private _defaultPipelineTextureType;
  49702. private _bloomScale;
  49703. private _chromaticAberrationEnabled;
  49704. private _grainEnabled;
  49705. private _buildAllowed;
  49706. /**
  49707. * Enable or disable the sharpen process from the pipeline
  49708. */
  49709. sharpenEnabled: boolean;
  49710. private _resizeObserver;
  49711. private _hardwareScaleLevel;
  49712. private _bloomKernel;
  49713. /**
  49714. * Specifies the size of the bloom blur kernel, relative to the final output size
  49715. */
  49716. bloomKernel: number;
  49717. /**
  49718. * Specifies the weight of the bloom in the final rendering
  49719. */
  49720. private _bloomWeight;
  49721. /**
  49722. * Specifies the luma threshold for the area that will be blurred by the bloom
  49723. */
  49724. private _bloomThreshold;
  49725. private _hdr;
  49726. /**
  49727. * The strength of the bloom.
  49728. */
  49729. bloomWeight: number;
  49730. /**
  49731. * The strength of the bloom.
  49732. */
  49733. bloomThreshold: number;
  49734. /**
  49735. * The scale of the bloom, lower value will provide better performance.
  49736. */
  49737. bloomScale: number;
  49738. /**
  49739. * Enable or disable the bloom from the pipeline
  49740. */
  49741. bloomEnabled: boolean;
  49742. private _rebuildBloom;
  49743. /**
  49744. * If the depth of field is enabled.
  49745. */
  49746. depthOfFieldEnabled: boolean;
  49747. /**
  49748. * Blur level of the depth of field effect. (Higher blur will effect performance)
  49749. */
  49750. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  49751. /**
  49752. * If the anti aliasing is enabled.
  49753. */
  49754. fxaaEnabled: boolean;
  49755. private _samples;
  49756. /**
  49757. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49758. */
  49759. samples: number;
  49760. /**
  49761. * If image processing is enabled.
  49762. */
  49763. imageProcessingEnabled: boolean;
  49764. /**
  49765. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  49766. */
  49767. glowLayerEnabled: boolean;
  49768. /**
  49769. * Enable or disable the chromaticAberration process from the pipeline
  49770. */
  49771. chromaticAberrationEnabled: boolean;
  49772. /**
  49773. * Enable or disable the grain process from the pipeline
  49774. */
  49775. grainEnabled: boolean;
  49776. /**
  49777. * @constructor
  49778. * @param name - The rendering pipeline name (default: "")
  49779. * @param hdr - If high dynamic range textures should be used (default: true)
  49780. * @param scene - The scene linked to this pipeline (default: the last created scene)
  49781. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  49782. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  49783. */
  49784. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  49785. /**
  49786. * Force the compilation of the entire pipeline.
  49787. */
  49788. prepare(): void;
  49789. private _hasCleared;
  49790. private _prevPostProcess;
  49791. private _prevPrevPostProcess;
  49792. private _setAutoClearAndTextureSharing;
  49793. private _depthOfFieldSceneObserver;
  49794. private _buildPipeline;
  49795. private _disposePostProcesses;
  49796. /**
  49797. * Adds a camera to the pipeline
  49798. * @param camera the camera to be added
  49799. */
  49800. addCamera(camera: Camera): void;
  49801. /**
  49802. * Removes a camera from the pipeline
  49803. * @param camera the camera to remove
  49804. */
  49805. removeCamera(camera: Camera): void;
  49806. /**
  49807. * Dispose of the pipeline and stop all post processes
  49808. */
  49809. dispose(): void;
  49810. /**
  49811. * Serialize the rendering pipeline (Used when exporting)
  49812. * @returns the serialized object
  49813. */
  49814. serialize(): any;
  49815. /**
  49816. * Parse the serialized pipeline
  49817. * @param source Source pipeline.
  49818. * @param scene The scene to load the pipeline to.
  49819. * @param rootUrl The URL of the serialized pipeline.
  49820. * @returns An instantiated pipeline from the serialized object.
  49821. */
  49822. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  49823. }
  49824. }
  49825. declare module BABYLON {
  49826. /** @hidden */
  49827. export var lensHighlightsPixelShader: {
  49828. name: string;
  49829. shader: string;
  49830. };
  49831. }
  49832. declare module BABYLON {
  49833. /** @hidden */
  49834. export var depthOfFieldPixelShader: {
  49835. name: string;
  49836. shader: string;
  49837. };
  49838. }
  49839. declare module BABYLON {
  49840. /**
  49841. * BABYLON.JS Chromatic Aberration GLSL Shader
  49842. * Author: Olivier Guyot
  49843. * Separates very slightly R, G and B colors on the edges of the screen
  49844. * Inspired by Francois Tarlier & Martins Upitis
  49845. */
  49846. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  49847. /**
  49848. * @ignore
  49849. * The chromatic aberration PostProcess id in the pipeline
  49850. */
  49851. LensChromaticAberrationEffect: string;
  49852. /**
  49853. * @ignore
  49854. * The highlights enhancing PostProcess id in the pipeline
  49855. */
  49856. HighlightsEnhancingEffect: string;
  49857. /**
  49858. * @ignore
  49859. * The depth-of-field PostProcess id in the pipeline
  49860. */
  49861. LensDepthOfFieldEffect: string;
  49862. private _scene;
  49863. private _depthTexture;
  49864. private _grainTexture;
  49865. private _chromaticAberrationPostProcess;
  49866. private _highlightsPostProcess;
  49867. private _depthOfFieldPostProcess;
  49868. private _edgeBlur;
  49869. private _grainAmount;
  49870. private _chromaticAberration;
  49871. private _distortion;
  49872. private _highlightsGain;
  49873. private _highlightsThreshold;
  49874. private _dofDistance;
  49875. private _dofAperture;
  49876. private _dofDarken;
  49877. private _dofPentagon;
  49878. private _blurNoise;
  49879. /**
  49880. * @constructor
  49881. *
  49882. * Effect parameters are as follow:
  49883. * {
  49884. * chromatic_aberration: number; // from 0 to x (1 for realism)
  49885. * edge_blur: number; // from 0 to x (1 for realism)
  49886. * distortion: number; // from 0 to x (1 for realism)
  49887. * grain_amount: number; // from 0 to 1
  49888. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  49889. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  49890. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  49891. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  49892. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  49893. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  49894. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  49895. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  49896. * }
  49897. * Note: if an effect parameter is unset, effect is disabled
  49898. *
  49899. * @param name The rendering pipeline name
  49900. * @param parameters - An object containing all parameters (see above)
  49901. * @param scene The scene linked to this pipeline
  49902. * @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)
  49903. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49904. */
  49905. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  49906. /**
  49907. * Sets the amount of blur at the edges
  49908. * @param amount blur amount
  49909. */
  49910. setEdgeBlur(amount: number): void;
  49911. /**
  49912. * Sets edge blur to 0
  49913. */
  49914. disableEdgeBlur(): void;
  49915. /**
  49916. * Sets the amout of grain
  49917. * @param amount Amount of grain
  49918. */
  49919. setGrainAmount(amount: number): void;
  49920. /**
  49921. * Set grain amount to 0
  49922. */
  49923. disableGrain(): void;
  49924. /**
  49925. * Sets the chromatic aberration amount
  49926. * @param amount amount of chromatic aberration
  49927. */
  49928. setChromaticAberration(amount: number): void;
  49929. /**
  49930. * Sets chromatic aberration amount to 0
  49931. */
  49932. disableChromaticAberration(): void;
  49933. /**
  49934. * Sets the EdgeDistortion amount
  49935. * @param amount amount of EdgeDistortion
  49936. */
  49937. setEdgeDistortion(amount: number): void;
  49938. /**
  49939. * Sets edge distortion to 0
  49940. */
  49941. disableEdgeDistortion(): void;
  49942. /**
  49943. * Sets the FocusDistance amount
  49944. * @param amount amount of FocusDistance
  49945. */
  49946. setFocusDistance(amount: number): void;
  49947. /**
  49948. * Disables depth of field
  49949. */
  49950. disableDepthOfField(): void;
  49951. /**
  49952. * Sets the Aperture amount
  49953. * @param amount amount of Aperture
  49954. */
  49955. setAperture(amount: number): void;
  49956. /**
  49957. * Sets the DarkenOutOfFocus amount
  49958. * @param amount amount of DarkenOutOfFocus
  49959. */
  49960. setDarkenOutOfFocus(amount: number): void;
  49961. /**
  49962. * Creates a pentagon bokeh effect
  49963. */
  49964. enablePentagonBokeh(): void;
  49965. /**
  49966. * Disables the pentagon bokeh effect
  49967. */
  49968. disablePentagonBokeh(): void;
  49969. /**
  49970. * Enables noise blur
  49971. */
  49972. enableNoiseBlur(): void;
  49973. /**
  49974. * Disables noise blur
  49975. */
  49976. disableNoiseBlur(): void;
  49977. /**
  49978. * Sets the HighlightsGain amount
  49979. * @param amount amount of HighlightsGain
  49980. */
  49981. setHighlightsGain(amount: number): void;
  49982. /**
  49983. * Sets the HighlightsThreshold amount
  49984. * @param amount amount of HighlightsThreshold
  49985. */
  49986. setHighlightsThreshold(amount: number): void;
  49987. /**
  49988. * Disables highlights
  49989. */
  49990. disableHighlights(): void;
  49991. /**
  49992. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  49993. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  49994. */
  49995. dispose(disableDepthRender?: boolean): void;
  49996. private _createChromaticAberrationPostProcess;
  49997. private _createHighlightsPostProcess;
  49998. private _createDepthOfFieldPostProcess;
  49999. private _createGrainTexture;
  50000. }
  50001. }
  50002. declare module BABYLON {
  50003. /** @hidden */
  50004. export var ssao2PixelShader: {
  50005. name: string;
  50006. shader: string;
  50007. };
  50008. }
  50009. declare module BABYLON {
  50010. /** @hidden */
  50011. export var ssaoCombinePixelShader: {
  50012. name: string;
  50013. shader: string;
  50014. };
  50015. }
  50016. declare module BABYLON {
  50017. /**
  50018. * Render pipeline to produce ssao effect
  50019. */
  50020. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50021. /**
  50022. * @ignore
  50023. * The PassPostProcess id in the pipeline that contains the original scene color
  50024. */
  50025. SSAOOriginalSceneColorEffect: string;
  50026. /**
  50027. * @ignore
  50028. * The SSAO PostProcess id in the pipeline
  50029. */
  50030. SSAORenderEffect: string;
  50031. /**
  50032. * @ignore
  50033. * The horizontal blur PostProcess id in the pipeline
  50034. */
  50035. SSAOBlurHRenderEffect: string;
  50036. /**
  50037. * @ignore
  50038. * The vertical blur PostProcess id in the pipeline
  50039. */
  50040. SSAOBlurVRenderEffect: string;
  50041. /**
  50042. * @ignore
  50043. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50044. */
  50045. SSAOCombineRenderEffect: string;
  50046. /**
  50047. * The output strength of the SSAO post-process. Default value is 1.0.
  50048. */
  50049. totalStrength: number;
  50050. /**
  50051. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50052. */
  50053. maxZ: number;
  50054. /**
  50055. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50056. */
  50057. minZAspect: number;
  50058. private _samples;
  50059. /**
  50060. * Number of samples used for the SSAO calculations. Default value is 8
  50061. */
  50062. samples: number;
  50063. private _textureSamples;
  50064. /**
  50065. * Number of samples to use for antialiasing
  50066. */
  50067. textureSamples: number;
  50068. /**
  50069. * Ratio object used for SSAO ratio and blur ratio
  50070. */
  50071. private _ratio;
  50072. /**
  50073. * Dynamically generated sphere sampler.
  50074. */
  50075. private _sampleSphere;
  50076. /**
  50077. * Blur filter offsets
  50078. */
  50079. private _samplerOffsets;
  50080. private _expensiveBlur;
  50081. /**
  50082. * If bilateral blur should be used
  50083. */
  50084. expensiveBlur: boolean;
  50085. /**
  50086. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50087. */
  50088. radius: number;
  50089. /**
  50090. * The base color of the SSAO post-process
  50091. * The final result is "base + ssao" between [0, 1]
  50092. */
  50093. base: number;
  50094. /**
  50095. * Support test.
  50096. */
  50097. static readonly IsSupported: boolean;
  50098. private _scene;
  50099. private _depthTexture;
  50100. private _normalTexture;
  50101. private _randomTexture;
  50102. private _originalColorPostProcess;
  50103. private _ssaoPostProcess;
  50104. private _blurHPostProcess;
  50105. private _blurVPostProcess;
  50106. private _ssaoCombinePostProcess;
  50107. private _firstUpdate;
  50108. /**
  50109. * @constructor
  50110. * @param name The rendering pipeline name
  50111. * @param scene The scene linked to this pipeline
  50112. * @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 }
  50113. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50114. */
  50115. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50116. /**
  50117. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50118. */
  50119. dispose(disableGeometryBufferRenderer?: boolean): void;
  50120. private _createBlurPostProcess;
  50121. /** @hidden */ rebuild(): void;
  50122. private _bits;
  50123. private _radicalInverse_VdC;
  50124. private _hammersley;
  50125. private _hemisphereSample_uniform;
  50126. private _generateHemisphere;
  50127. private _createSSAOPostProcess;
  50128. private _createSSAOCombinePostProcess;
  50129. private _createRandomTexture;
  50130. /**
  50131. * Serialize the rendering pipeline (Used when exporting)
  50132. * @returns the serialized object
  50133. */
  50134. serialize(): any;
  50135. /**
  50136. * Parse the serialized pipeline
  50137. * @param source Source pipeline.
  50138. * @param scene The scene to load the pipeline to.
  50139. * @param rootUrl The URL of the serialized pipeline.
  50140. * @returns An instantiated pipeline from the serialized object.
  50141. */
  50142. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50143. }
  50144. }
  50145. declare module BABYLON {
  50146. /** @hidden */
  50147. export var ssaoPixelShader: {
  50148. name: string;
  50149. shader: string;
  50150. };
  50151. }
  50152. declare module BABYLON {
  50153. /**
  50154. * Render pipeline to produce ssao effect
  50155. */
  50156. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50157. /**
  50158. * @ignore
  50159. * The PassPostProcess id in the pipeline that contains the original scene color
  50160. */
  50161. SSAOOriginalSceneColorEffect: string;
  50162. /**
  50163. * @ignore
  50164. * The SSAO PostProcess id in the pipeline
  50165. */
  50166. SSAORenderEffect: string;
  50167. /**
  50168. * @ignore
  50169. * The horizontal blur PostProcess id in the pipeline
  50170. */
  50171. SSAOBlurHRenderEffect: string;
  50172. /**
  50173. * @ignore
  50174. * The vertical blur PostProcess id in the pipeline
  50175. */
  50176. SSAOBlurVRenderEffect: string;
  50177. /**
  50178. * @ignore
  50179. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50180. */
  50181. SSAOCombineRenderEffect: string;
  50182. /**
  50183. * The output strength of the SSAO post-process. Default value is 1.0.
  50184. */
  50185. totalStrength: number;
  50186. /**
  50187. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50188. */
  50189. radius: number;
  50190. /**
  50191. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50192. * Must not be equal to fallOff and superior to fallOff.
  50193. * Default value is 0.975
  50194. */
  50195. area: number;
  50196. /**
  50197. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50198. * Must not be equal to area and inferior to area.
  50199. * Default value is 0.0
  50200. */
  50201. fallOff: number;
  50202. /**
  50203. * The base color of the SSAO post-process
  50204. * The final result is "base + ssao" between [0, 1]
  50205. */
  50206. base: number;
  50207. private _scene;
  50208. private _depthTexture;
  50209. private _randomTexture;
  50210. private _originalColorPostProcess;
  50211. private _ssaoPostProcess;
  50212. private _blurHPostProcess;
  50213. private _blurVPostProcess;
  50214. private _ssaoCombinePostProcess;
  50215. private _firstUpdate;
  50216. /**
  50217. * @constructor
  50218. * @param name - The rendering pipeline name
  50219. * @param scene - The scene linked to this pipeline
  50220. * @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 }
  50221. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50222. */
  50223. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50224. /**
  50225. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50226. */
  50227. dispose(disableDepthRender?: boolean): void;
  50228. private _createBlurPostProcess;
  50229. /** @hidden */ rebuild(): void;
  50230. private _createSSAOPostProcess;
  50231. private _createSSAOCombinePostProcess;
  50232. private _createRandomTexture;
  50233. }
  50234. }
  50235. declare module BABYLON {
  50236. /** @hidden */
  50237. export var standardPixelShader: {
  50238. name: string;
  50239. shader: string;
  50240. };
  50241. }
  50242. declare module BABYLON {
  50243. /**
  50244. * Standard rendering pipeline
  50245. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50246. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50247. */
  50248. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50249. /**
  50250. * Public members
  50251. */
  50252. /**
  50253. * Post-process which contains the original scene color before the pipeline applies all the effects
  50254. */
  50255. originalPostProcess: Nullable<PostProcess>;
  50256. /**
  50257. * Post-process used to down scale an image x4
  50258. */
  50259. downSampleX4PostProcess: Nullable<PostProcess>;
  50260. /**
  50261. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50262. */
  50263. brightPassPostProcess: Nullable<PostProcess>;
  50264. /**
  50265. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50266. */
  50267. blurHPostProcesses: PostProcess[];
  50268. /**
  50269. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50270. */
  50271. blurVPostProcesses: PostProcess[];
  50272. /**
  50273. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50274. */
  50275. textureAdderPostProcess: Nullable<PostProcess>;
  50276. /**
  50277. * Post-process used to create volumetric lighting effect
  50278. */
  50279. volumetricLightPostProcess: Nullable<PostProcess>;
  50280. /**
  50281. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50282. */
  50283. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50284. /**
  50285. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50286. */
  50287. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50288. /**
  50289. * Post-process used to merge the volumetric light effect and the real scene color
  50290. */
  50291. volumetricLightMergePostProces: Nullable<PostProcess>;
  50292. /**
  50293. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50294. */
  50295. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50296. /**
  50297. * Base post-process used to calculate the average luminance of the final image for HDR
  50298. */
  50299. luminancePostProcess: Nullable<PostProcess>;
  50300. /**
  50301. * Post-processes used to create down sample post-processes in order to get
  50302. * the average luminance of the final image for HDR
  50303. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50304. */
  50305. luminanceDownSamplePostProcesses: PostProcess[];
  50306. /**
  50307. * Post-process used to create a HDR effect (light adaptation)
  50308. */
  50309. hdrPostProcess: Nullable<PostProcess>;
  50310. /**
  50311. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50312. */
  50313. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50314. /**
  50315. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50316. */
  50317. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50318. /**
  50319. * Post-process used to merge the final HDR post-process and the real scene color
  50320. */
  50321. hdrFinalPostProcess: Nullable<PostProcess>;
  50322. /**
  50323. * Post-process used to create a lens flare effect
  50324. */
  50325. lensFlarePostProcess: Nullable<PostProcess>;
  50326. /**
  50327. * Post-process that merges the result of the lens flare post-process and the real scene color
  50328. */
  50329. lensFlareComposePostProcess: Nullable<PostProcess>;
  50330. /**
  50331. * Post-process used to create a motion blur effect
  50332. */
  50333. motionBlurPostProcess: Nullable<PostProcess>;
  50334. /**
  50335. * Post-process used to create a depth of field effect
  50336. */
  50337. depthOfFieldPostProcess: Nullable<PostProcess>;
  50338. /**
  50339. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50340. */
  50341. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50342. /**
  50343. * Represents the brightness threshold in order to configure the illuminated surfaces
  50344. */
  50345. brightThreshold: number;
  50346. /**
  50347. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50348. */
  50349. blurWidth: number;
  50350. /**
  50351. * Sets if the blur for highlighted surfaces must be only horizontal
  50352. */
  50353. horizontalBlur: boolean;
  50354. /**
  50355. * Sets the overall exposure used by the pipeline
  50356. */
  50357. exposure: number;
  50358. /**
  50359. * Texture used typically to simulate "dirty" on camera lens
  50360. */
  50361. lensTexture: Nullable<Texture>;
  50362. /**
  50363. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50364. */
  50365. volumetricLightCoefficient: number;
  50366. /**
  50367. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50368. */
  50369. volumetricLightPower: number;
  50370. /**
  50371. * Used the set the blur intensity to smooth the volumetric lights
  50372. */
  50373. volumetricLightBlurScale: number;
  50374. /**
  50375. * Light (spot or directional) used to generate the volumetric lights rays
  50376. * The source light must have a shadow generate so the pipeline can get its
  50377. * depth map
  50378. */
  50379. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50380. /**
  50381. * For eye adaptation, represents the minimum luminance the eye can see
  50382. */
  50383. hdrMinimumLuminance: number;
  50384. /**
  50385. * For eye adaptation, represents the decrease luminance speed
  50386. */
  50387. hdrDecreaseRate: number;
  50388. /**
  50389. * For eye adaptation, represents the increase luminance speed
  50390. */
  50391. hdrIncreaseRate: number;
  50392. /**
  50393. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50394. */
  50395. lensColorTexture: Nullable<Texture>;
  50396. /**
  50397. * The overall strengh for the lens flare effect
  50398. */
  50399. lensFlareStrength: number;
  50400. /**
  50401. * Dispersion coefficient for lens flare ghosts
  50402. */
  50403. lensFlareGhostDispersal: number;
  50404. /**
  50405. * Main lens flare halo width
  50406. */
  50407. lensFlareHaloWidth: number;
  50408. /**
  50409. * Based on the lens distortion effect, defines how much the lens flare result
  50410. * is distorted
  50411. */
  50412. lensFlareDistortionStrength: number;
  50413. /**
  50414. * Lens star texture must be used to simulate rays on the flares and is available
  50415. * in the documentation
  50416. */
  50417. lensStarTexture: Nullable<Texture>;
  50418. /**
  50419. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50420. * flare effect by taking account of the dirt texture
  50421. */
  50422. lensFlareDirtTexture: Nullable<Texture>;
  50423. /**
  50424. * Represents the focal length for the depth of field effect
  50425. */
  50426. depthOfFieldDistance: number;
  50427. /**
  50428. * Represents the blur intensity for the blurred part of the depth of field effect
  50429. */
  50430. depthOfFieldBlurWidth: number;
  50431. /**
  50432. * For motion blur, defines how much the image is blurred by the movement
  50433. */
  50434. motionStrength: number;
  50435. /**
  50436. * List of animations for the pipeline (IAnimatable implementation)
  50437. */
  50438. animations: Animation[];
  50439. /**
  50440. * Private members
  50441. */
  50442. private _scene;
  50443. private _currentDepthOfFieldSource;
  50444. private _basePostProcess;
  50445. private _hdrCurrentLuminance;
  50446. private _floatTextureType;
  50447. private _ratio;
  50448. private _bloomEnabled;
  50449. private _depthOfFieldEnabled;
  50450. private _vlsEnabled;
  50451. private _lensFlareEnabled;
  50452. private _hdrEnabled;
  50453. private _motionBlurEnabled;
  50454. private _fxaaEnabled;
  50455. private _motionBlurSamples;
  50456. private _volumetricLightStepsCount;
  50457. private _samples;
  50458. /**
  50459. * @ignore
  50460. * Specifies if the bloom pipeline is enabled
  50461. */
  50462. BloomEnabled: boolean;
  50463. /**
  50464. * @ignore
  50465. * Specifies if the depth of field pipeline is enabed
  50466. */
  50467. DepthOfFieldEnabled: boolean;
  50468. /**
  50469. * @ignore
  50470. * Specifies if the lens flare pipeline is enabed
  50471. */
  50472. LensFlareEnabled: boolean;
  50473. /**
  50474. * @ignore
  50475. * Specifies if the HDR pipeline is enabled
  50476. */
  50477. HDREnabled: boolean;
  50478. /**
  50479. * @ignore
  50480. * Specifies if the volumetric lights scattering effect is enabled
  50481. */
  50482. VLSEnabled: boolean;
  50483. /**
  50484. * @ignore
  50485. * Specifies if the motion blur effect is enabled
  50486. */
  50487. MotionBlurEnabled: boolean;
  50488. /**
  50489. * Specifies if anti-aliasing is enabled
  50490. */
  50491. fxaaEnabled: boolean;
  50492. /**
  50493. * Specifies the number of steps used to calculate the volumetric lights
  50494. * Typically in interval [50, 200]
  50495. */
  50496. volumetricLightStepsCount: number;
  50497. /**
  50498. * Specifies the number of samples used for the motion blur effect
  50499. * Typically in interval [16, 64]
  50500. */
  50501. motionBlurSamples: number;
  50502. /**
  50503. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50504. */
  50505. samples: number;
  50506. /**
  50507. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50508. * @constructor
  50509. * @param name The rendering pipeline name
  50510. * @param scene The scene linked to this pipeline
  50511. * @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)
  50512. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50513. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50514. */
  50515. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50516. private _buildPipeline;
  50517. private _createDownSampleX4PostProcess;
  50518. private _createBrightPassPostProcess;
  50519. private _createBlurPostProcesses;
  50520. private _createTextureAdderPostProcess;
  50521. private _createVolumetricLightPostProcess;
  50522. private _createLuminancePostProcesses;
  50523. private _createHdrPostProcess;
  50524. private _createLensFlarePostProcess;
  50525. private _createDepthOfFieldPostProcess;
  50526. private _createMotionBlurPostProcess;
  50527. private _getDepthTexture;
  50528. private _disposePostProcesses;
  50529. /**
  50530. * Dispose of the pipeline and stop all post processes
  50531. */
  50532. dispose(): void;
  50533. /**
  50534. * Serialize the rendering pipeline (Used when exporting)
  50535. * @returns the serialized object
  50536. */
  50537. serialize(): any;
  50538. /**
  50539. * Parse the serialized pipeline
  50540. * @param source Source pipeline.
  50541. * @param scene The scene to load the pipeline to.
  50542. * @param rootUrl The URL of the serialized pipeline.
  50543. * @returns An instantiated pipeline from the serialized object.
  50544. */
  50545. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50546. /**
  50547. * Luminance steps
  50548. */
  50549. static LuminanceSteps: number;
  50550. }
  50551. }
  50552. declare module BABYLON {
  50553. /**
  50554. * PostProcessRenderPipelineManager class
  50555. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50556. */
  50557. export class PostProcessRenderPipelineManager {
  50558. private _renderPipelines;
  50559. /**
  50560. * Initializes a PostProcessRenderPipelineManager
  50561. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50562. */
  50563. constructor();
  50564. /**
  50565. * Adds a pipeline to the manager
  50566. * @param renderPipeline The pipeline to add
  50567. */
  50568. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  50569. /**
  50570. * Attaches a camera to the pipeline
  50571. * @param renderPipelineName The name of the pipeline to attach to
  50572. * @param cameras the camera to attach
  50573. * @param unique if the camera can be attached multiple times to the pipeline
  50574. */
  50575. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  50576. /**
  50577. * Detaches a camera from the pipeline
  50578. * @param renderPipelineName The name of the pipeline to detach from
  50579. * @param cameras the camera to detach
  50580. */
  50581. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  50582. /**
  50583. * Enables an effect by name on a pipeline
  50584. * @param renderPipelineName the name of the pipeline to enable the effect in
  50585. * @param renderEffectName the name of the effect to enable
  50586. * @param cameras the cameras that the effect should be enabled on
  50587. */
  50588. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  50589. /**
  50590. * Disables an effect by name on a pipeline
  50591. * @param renderPipelineName the name of the pipeline to disable the effect in
  50592. * @param renderEffectName the name of the effect to disable
  50593. * @param cameras the cameras that the effect should be disabled on
  50594. */
  50595. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  50596. /**
  50597. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  50598. */
  50599. update(): void;
  50600. /** @hidden */ rebuild(): void;
  50601. /**
  50602. * Disposes of the manager and pipelines
  50603. */
  50604. dispose(): void;
  50605. }
  50606. }
  50607. declare module BABYLON {
  50608. interface Scene {
  50609. /** @hidden (Backing field) */ postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  50610. /**
  50611. * Gets the postprocess render pipeline manager
  50612. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50613. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50614. */
  50615. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  50616. }
  50617. /**
  50618. * Defines the Render Pipeline scene component responsible to rendering pipelines
  50619. */
  50620. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  50621. /**
  50622. * The component name helpfull to identify the component in the list of scene components.
  50623. */
  50624. readonly name: string;
  50625. /**
  50626. * The scene the component belongs to.
  50627. */
  50628. scene: Scene;
  50629. /**
  50630. * Creates a new instance of the component for the given scene
  50631. * @param scene Defines the scene to register the component in
  50632. */
  50633. constructor(scene: Scene);
  50634. /**
  50635. * Registers the component in a given scene
  50636. */
  50637. register(): void;
  50638. /**
  50639. * Rebuilds the elements related to this component in case of
  50640. * context lost for instance.
  50641. */
  50642. rebuild(): void;
  50643. /**
  50644. * Disposes the component and the associated ressources
  50645. */
  50646. dispose(): void;
  50647. private _gatherRenderTargets;
  50648. }
  50649. }
  50650. declare module BABYLON {
  50651. /** @hidden */
  50652. export var tonemapPixelShader: {
  50653. name: string;
  50654. shader: string;
  50655. };
  50656. }
  50657. declare module BABYLON {
  50658. /** Defines operator used for tonemapping */
  50659. export enum TonemappingOperator {
  50660. /** Hable */
  50661. Hable = 0,
  50662. /** Reinhard */
  50663. Reinhard = 1,
  50664. /** HejiDawson */
  50665. HejiDawson = 2,
  50666. /** Photographic */
  50667. Photographic = 3
  50668. }
  50669. /**
  50670. * Defines a post process to apply tone mapping
  50671. */
  50672. export class TonemapPostProcess extends PostProcess {
  50673. private _operator;
  50674. /** Defines the required exposure adjustement */
  50675. exposureAdjustment: number;
  50676. /**
  50677. * Creates a new TonemapPostProcess
  50678. * @param name defines the name of the postprocess
  50679. * @param _operator defines the operator to use
  50680. * @param exposureAdjustment defines the required exposure adjustement
  50681. * @param camera defines the camera to use (can be null)
  50682. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  50683. * @param engine defines the hosting engine (can be ignore if camera is set)
  50684. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50685. */
  50686. constructor(name: string, _operator: TonemappingOperator,
  50687. /** Defines the required exposure adjustement */
  50688. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  50689. }
  50690. }
  50691. declare module BABYLON {
  50692. /** @hidden */
  50693. export var depthVertexShader: {
  50694. name: string;
  50695. shader: string;
  50696. };
  50697. }
  50698. declare module BABYLON {
  50699. /** @hidden */
  50700. export var volumetricLightScatteringPixelShader: {
  50701. name: string;
  50702. shader: string;
  50703. };
  50704. }
  50705. declare module BABYLON {
  50706. /** @hidden */
  50707. export var volumetricLightScatteringPassPixelShader: {
  50708. name: string;
  50709. shader: string;
  50710. };
  50711. }
  50712. declare module BABYLON {
  50713. /**
  50714. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  50715. */
  50716. export class VolumetricLightScatteringPostProcess extends PostProcess {
  50717. private _volumetricLightScatteringPass;
  50718. private _volumetricLightScatteringRTT;
  50719. private _viewPort;
  50720. private _screenCoordinates;
  50721. private _cachedDefines;
  50722. /**
  50723. * If not undefined, the mesh position is computed from the attached node position
  50724. */
  50725. attachedNode: {
  50726. position: Vector3;
  50727. };
  50728. /**
  50729. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  50730. */
  50731. customMeshPosition: Vector3;
  50732. /**
  50733. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  50734. */
  50735. useCustomMeshPosition: boolean;
  50736. /**
  50737. * If the post-process should inverse the light scattering direction
  50738. */
  50739. invert: boolean;
  50740. /**
  50741. * The internal mesh used by the post-process
  50742. */
  50743. mesh: Mesh;
  50744. /**
  50745. * @hidden
  50746. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  50747. */
  50748. useDiffuseColor: boolean;
  50749. /**
  50750. * Array containing the excluded meshes not rendered in the internal pass
  50751. */
  50752. excludedMeshes: AbstractMesh[];
  50753. /**
  50754. * Controls the overall intensity of the post-process
  50755. */
  50756. exposure: number;
  50757. /**
  50758. * Dissipates each sample's contribution in range [0, 1]
  50759. */
  50760. decay: number;
  50761. /**
  50762. * Controls the overall intensity of each sample
  50763. */
  50764. weight: number;
  50765. /**
  50766. * Controls the density of each sample
  50767. */
  50768. density: number;
  50769. /**
  50770. * @constructor
  50771. * @param name The post-process name
  50772. * @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)
  50773. * @param camera The camera that the post-process will be attached to
  50774. * @param mesh The mesh used to create the light scattering
  50775. * @param samples The post-process quality, default 100
  50776. * @param samplingModeThe post-process filtering mode
  50777. * @param engine The babylon engine
  50778. * @param reusable If the post-process is reusable
  50779. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  50780. */
  50781. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  50782. /**
  50783. * Returns the string "VolumetricLightScatteringPostProcess"
  50784. * @returns "VolumetricLightScatteringPostProcess"
  50785. */
  50786. getClassName(): string;
  50787. private _isReady;
  50788. /**
  50789. * Sets the new light position for light scattering effect
  50790. * @param position The new custom light position
  50791. */
  50792. setCustomMeshPosition(position: Vector3): void;
  50793. /**
  50794. * Returns the light position for light scattering effect
  50795. * @return Vector3 The custom light position
  50796. */
  50797. getCustomMeshPosition(): Vector3;
  50798. /**
  50799. * Disposes the internal assets and detaches the post-process from the camera
  50800. */
  50801. dispose(camera: Camera): void;
  50802. /**
  50803. * Returns the render target texture used by the post-process
  50804. * @return the render target texture used by the post-process
  50805. */
  50806. getPass(): RenderTargetTexture;
  50807. private _meshExcluded;
  50808. private _createPass;
  50809. private _updateMeshScreenCoordinates;
  50810. /**
  50811. * Creates a default mesh for the Volumeric Light Scattering post-process
  50812. * @param name The mesh name
  50813. * @param scene The scene where to create the mesh
  50814. * @return the default mesh
  50815. */
  50816. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  50817. }
  50818. }
  50819. declare module BABYLON {
  50820. interface Scene {
  50821. /** @hidden (Backing field) */ boundingBoxRenderer: BoundingBoxRenderer;
  50822. /** @hidden (Backing field) */ forceShowBoundingBoxes: boolean;
  50823. /**
  50824. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  50825. */
  50826. forceShowBoundingBoxes: boolean;
  50827. /**
  50828. * Gets the bounding box renderer associated with the scene
  50829. * @returns a BoundingBoxRenderer
  50830. */
  50831. getBoundingBoxRenderer(): BoundingBoxRenderer;
  50832. }
  50833. interface AbstractMesh {
  50834. /** @hidden (Backing field) */ showBoundingBox: boolean;
  50835. /**
  50836. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  50837. */
  50838. showBoundingBox: boolean;
  50839. }
  50840. /**
  50841. * Component responsible of rendering the bounding box of the meshes in a scene.
  50842. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  50843. */
  50844. export class BoundingBoxRenderer implements ISceneComponent {
  50845. /**
  50846. * The component name helpfull to identify the component in the list of scene components.
  50847. */
  50848. readonly name: string;
  50849. /**
  50850. * The scene the component belongs to.
  50851. */
  50852. scene: Scene;
  50853. /**
  50854. * Color of the bounding box lines placed in front of an object
  50855. */
  50856. frontColor: Color3;
  50857. /**
  50858. * Color of the bounding box lines placed behind an object
  50859. */
  50860. backColor: Color3;
  50861. /**
  50862. * Defines if the renderer should show the back lines or not
  50863. */
  50864. showBackLines: boolean;
  50865. /**
  50866. * @hidden
  50867. */
  50868. renderList: SmartArray<BoundingBox>;
  50869. private _colorShader;
  50870. private _vertexBuffers;
  50871. private _indexBuffer;
  50872. /**
  50873. * Instantiates a new bounding box renderer in a scene.
  50874. * @param scene the scene the renderer renders in
  50875. */
  50876. constructor(scene: Scene);
  50877. /**
  50878. * Registers the component in a given scene
  50879. */
  50880. register(): void;
  50881. private _evaluateSubMesh;
  50882. private _activeMesh;
  50883. private _prepareRessources;
  50884. private _createIndexBuffer;
  50885. /**
  50886. * Rebuilds the elements related to this component in case of
  50887. * context lost for instance.
  50888. */
  50889. rebuild(): void;
  50890. /**
  50891. * @hidden
  50892. */
  50893. reset(): void;
  50894. /**
  50895. * Render the bounding boxes of a specific rendering group
  50896. * @param renderingGroupId defines the rendering group to render
  50897. */
  50898. render(renderingGroupId: number): void;
  50899. /**
  50900. * In case of occlusion queries, we can render the occlusion bounding box through this method
  50901. * @param mesh Define the mesh to render the occlusion bounding box for
  50902. */
  50903. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  50904. /**
  50905. * Dispose and release the resources attached to this renderer.
  50906. */
  50907. dispose(): void;
  50908. }
  50909. }
  50910. declare module BABYLON {
  50911. /** @hidden */
  50912. export var depthPixelShader: {
  50913. name: string;
  50914. shader: string;
  50915. };
  50916. }
  50917. declare module BABYLON {
  50918. /**
  50919. * This represents a depth renderer in Babylon.
  50920. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  50921. */
  50922. export class DepthRenderer {
  50923. private _scene;
  50924. private _depthMap;
  50925. private _effect;
  50926. private _cachedDefines;
  50927. private _camera;
  50928. /**
  50929. * Specifiess that the depth renderer will only be used within
  50930. * the camera it is created for.
  50931. * This can help forcing its rendering during the camera processing.
  50932. */
  50933. useOnlyInActiveCamera: boolean;
  50934. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  50935. /**
  50936. * Instantiates a depth renderer
  50937. * @param scene The scene the renderer belongs to
  50938. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  50939. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  50940. */
  50941. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  50942. /**
  50943. * Creates the depth rendering effect and checks if the effect is ready.
  50944. * @param subMesh The submesh to be used to render the depth map of
  50945. * @param useInstances If multiple world instances should be used
  50946. * @returns if the depth renderer is ready to render the depth map
  50947. */
  50948. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50949. /**
  50950. * Gets the texture which the depth map will be written to.
  50951. * @returns The depth map texture
  50952. */
  50953. getDepthMap(): RenderTargetTexture;
  50954. /**
  50955. * Disposes of the depth renderer.
  50956. */
  50957. dispose(): void;
  50958. }
  50959. }
  50960. declare module BABYLON {
  50961. interface Scene {
  50962. /** @hidden (Backing field) */ depthRenderer: {
  50963. [id: string]: DepthRenderer;
  50964. };
  50965. /**
  50966. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  50967. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  50968. * @returns the created depth renderer
  50969. */
  50970. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  50971. /**
  50972. * Disables a depth renderer for a given camera
  50973. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  50974. */
  50975. disableDepthRenderer(camera?: Nullable<Camera>): void;
  50976. }
  50977. /**
  50978. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  50979. * in several rendering techniques.
  50980. */
  50981. export class DepthRendererSceneComponent implements ISceneComponent {
  50982. /**
  50983. * The component name helpfull to identify the component in the list of scene components.
  50984. */
  50985. readonly name: string;
  50986. /**
  50987. * The scene the component belongs to.
  50988. */
  50989. scene: Scene;
  50990. /**
  50991. * Creates a new instance of the component for the given scene
  50992. * @param scene Defines the scene to register the component in
  50993. */
  50994. constructor(scene: Scene);
  50995. /**
  50996. * Registers the component in a given scene
  50997. */
  50998. register(): void;
  50999. /**
  51000. * Rebuilds the elements related to this component in case of
  51001. * context lost for instance.
  51002. */
  51003. rebuild(): void;
  51004. /**
  51005. * Disposes the component and the associated ressources
  51006. */
  51007. dispose(): void;
  51008. private _gatherRenderTargets;
  51009. private _gatherActiveCameraRenderTargets;
  51010. }
  51011. }
  51012. declare module BABYLON {
  51013. interface Scene {
  51014. /** @hidden (Backing field) */ geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51015. /**
  51016. * Gets or Sets the current geometry buffer associated to the scene.
  51017. */
  51018. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51019. /**
  51020. * Enables a GeometryBufferRender and associates it with the scene
  51021. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  51022. * @returns the GeometryBufferRenderer
  51023. */
  51024. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  51025. /**
  51026. * Disables the GeometryBufferRender associated with the scene
  51027. */
  51028. disableGeometryBufferRenderer(): void;
  51029. }
  51030. /**
  51031. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  51032. * in several rendering techniques.
  51033. */
  51034. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  51035. /**
  51036. * The component name helpful to identify the component in the list of scene components.
  51037. */
  51038. readonly name: string;
  51039. /**
  51040. * The scene the component belongs to.
  51041. */
  51042. scene: Scene;
  51043. /**
  51044. * Creates a new instance of the component for the given scene
  51045. * @param scene Defines the scene to register the component in
  51046. */
  51047. constructor(scene: Scene);
  51048. /**
  51049. * Registers the component in a given scene
  51050. */
  51051. register(): void;
  51052. /**
  51053. * Rebuilds the elements related to this component in case of
  51054. * context lost for instance.
  51055. */
  51056. rebuild(): void;
  51057. /**
  51058. * Disposes the component and the associated ressources
  51059. */
  51060. dispose(): void;
  51061. private _gatherRenderTargets;
  51062. }
  51063. }
  51064. declare module BABYLON {
  51065. /** @hidden */
  51066. export var outlinePixelShader: {
  51067. name: string;
  51068. shader: string;
  51069. };
  51070. }
  51071. declare module BABYLON {
  51072. /** @hidden */
  51073. export var outlineVertexShader: {
  51074. name: string;
  51075. shader: string;
  51076. };
  51077. }
  51078. declare module BABYLON {
  51079. interface Scene {
  51080. /** @hidden */ outlineRenderer: OutlineRenderer;
  51081. /**
  51082. * Gets the outline renderer associated with the scene
  51083. * @returns a OutlineRenderer
  51084. */
  51085. getOutlineRenderer(): OutlineRenderer;
  51086. }
  51087. interface AbstractMesh {
  51088. /** @hidden (Backing field) */ renderOutline: boolean;
  51089. /**
  51090. * Gets or sets a boolean indicating if the outline must be rendered as well
  51091. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  51092. */
  51093. renderOutline: boolean;
  51094. /** @hidden (Backing field) */ renderOverlay: boolean;
  51095. /**
  51096. * Gets or sets a boolean indicating if the overlay must be rendered as well
  51097. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  51098. */
  51099. renderOverlay: boolean;
  51100. }
  51101. /**
  51102. * This class is responsible to draw bothe outline/overlay of meshes.
  51103. * It should not be used directly but through the available method on mesh.
  51104. */
  51105. export class OutlineRenderer implements ISceneComponent {
  51106. /**
  51107. * The name of the component. Each component must have a unique name.
  51108. */
  51109. name: string;
  51110. /**
  51111. * The scene the component belongs to.
  51112. */
  51113. scene: Scene;
  51114. /**
  51115. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  51116. */
  51117. zOffset: number;
  51118. private _engine;
  51119. private _effect;
  51120. private _cachedDefines;
  51121. private _savedDepthWrite;
  51122. /**
  51123. * Instantiates a new outline renderer. (There could be only one per scene).
  51124. * @param scene Defines the scene it belongs to
  51125. */
  51126. constructor(scene: Scene);
  51127. /**
  51128. * Register the component to one instance of a scene.
  51129. */
  51130. register(): void;
  51131. /**
  51132. * Rebuilds the elements related to this component in case of
  51133. * context lost for instance.
  51134. */
  51135. rebuild(): void;
  51136. /**
  51137. * Disposes the component and the associated ressources.
  51138. */
  51139. dispose(): void;
  51140. /**
  51141. * Renders the outline in the canvas.
  51142. * @param subMesh Defines the sumesh to render
  51143. * @param batch Defines the batch of meshes in case of instances
  51144. * @param useOverlay Defines if the rendering is for the overlay or the outline
  51145. */
  51146. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  51147. /**
  51148. * Returns whether or not the outline renderer is ready for a given submesh.
  51149. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  51150. * @param subMesh Defines the submesh to check readyness for
  51151. * @param useInstances Defines wheter wee are trying to render instances or not
  51152. * @returns true if ready otherwise false
  51153. */
  51154. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51155. private _beforeRenderingMesh;
  51156. private _afterRenderingMesh;
  51157. }
  51158. }
  51159. declare module BABYLON {
  51160. /**
  51161. * Defines the list of states available for a task inside a AssetsManager
  51162. */
  51163. export enum AssetTaskState {
  51164. /**
  51165. * Initialization
  51166. */
  51167. INIT = 0,
  51168. /**
  51169. * Running
  51170. */
  51171. RUNNING = 1,
  51172. /**
  51173. * Done
  51174. */
  51175. DONE = 2,
  51176. /**
  51177. * Error
  51178. */
  51179. ERROR = 3
  51180. }
  51181. /**
  51182. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  51183. */
  51184. export abstract class AbstractAssetTask {
  51185. /**
  51186. * Task name
  51187. */ name: string;
  51188. /**
  51189. * Callback called when the task is successful
  51190. */
  51191. onSuccess: (task: any) => void;
  51192. /**
  51193. * Callback called when the task is not successful
  51194. */
  51195. onError: (task: any, message?: string, exception?: any) => void;
  51196. /**
  51197. * Creates a new AssetsManager
  51198. * @param name defines the name of the task
  51199. */
  51200. constructor(
  51201. /**
  51202. * Task name
  51203. */ name: string);
  51204. private _isCompleted;
  51205. private _taskState;
  51206. private _errorObject;
  51207. /**
  51208. * Get if the task is completed
  51209. */
  51210. readonly isCompleted: boolean;
  51211. /**
  51212. * Gets the current state of the task
  51213. */
  51214. readonly taskState: AssetTaskState;
  51215. /**
  51216. * Gets the current error object (if task is in error)
  51217. */
  51218. readonly errorObject: {
  51219. message?: string;
  51220. exception?: any;
  51221. };
  51222. /**
  51223. * Internal only
  51224. * @hidden
  51225. */ setErrorObject(message?: string, exception?: any): void;
  51226. /**
  51227. * Execute the current task
  51228. * @param scene defines the scene where you want your assets to be loaded
  51229. * @param onSuccess is a callback called when the task is successfully executed
  51230. * @param onError is a callback called if an error occurs
  51231. */
  51232. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51233. /**
  51234. * Execute the current task
  51235. * @param scene defines the scene where you want your assets to be loaded
  51236. * @param onSuccess is a callback called when the task is successfully executed
  51237. * @param onError is a callback called if an error occurs
  51238. */
  51239. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51240. /**
  51241. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  51242. * This can be used with failed tasks that have the reason for failure fixed.
  51243. */
  51244. reset(): void;
  51245. private onErrorCallback;
  51246. private onDoneCallback;
  51247. }
  51248. /**
  51249. * Define the interface used by progress events raised during assets loading
  51250. */
  51251. export interface IAssetsProgressEvent {
  51252. /**
  51253. * Defines the number of remaining tasks to process
  51254. */
  51255. remainingCount: number;
  51256. /**
  51257. * Defines the total number of tasks
  51258. */
  51259. totalCount: number;
  51260. /**
  51261. * Defines the task that was just processed
  51262. */
  51263. task: AbstractAssetTask;
  51264. }
  51265. /**
  51266. * Class used to share progress information about assets loading
  51267. */
  51268. export class AssetsProgressEvent implements IAssetsProgressEvent {
  51269. /**
  51270. * Defines the number of remaining tasks to process
  51271. */
  51272. remainingCount: number;
  51273. /**
  51274. * Defines the total number of tasks
  51275. */
  51276. totalCount: number;
  51277. /**
  51278. * Defines the task that was just processed
  51279. */
  51280. task: AbstractAssetTask;
  51281. /**
  51282. * Creates a AssetsProgressEvent
  51283. * @param remainingCount defines the number of remaining tasks to process
  51284. * @param totalCount defines the total number of tasks
  51285. * @param task defines the task that was just processed
  51286. */
  51287. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  51288. }
  51289. /**
  51290. * Define a task used by AssetsManager to load meshes
  51291. */
  51292. export class MeshAssetTask extends AbstractAssetTask {
  51293. /**
  51294. * Defines the name of the task
  51295. */
  51296. name: string;
  51297. /**
  51298. * Defines the list of mesh's names you want to load
  51299. */
  51300. meshesNames: any;
  51301. /**
  51302. * Defines the root url to use as a base to load your meshes and associated resources
  51303. */
  51304. rootUrl: string;
  51305. /**
  51306. * Defines the filename of the scene to load from
  51307. */
  51308. sceneFilename: string;
  51309. /**
  51310. * Gets the list of loaded meshes
  51311. */
  51312. loadedMeshes: Array<AbstractMesh>;
  51313. /**
  51314. * Gets the list of loaded particle systems
  51315. */
  51316. loadedParticleSystems: Array<IParticleSystem>;
  51317. /**
  51318. * Gets the list of loaded skeletons
  51319. */
  51320. loadedSkeletons: Array<Skeleton>;
  51321. /**
  51322. * Gets the list of loaded animation groups
  51323. */
  51324. loadedAnimationGroups: Array<AnimationGroup>;
  51325. /**
  51326. * Callback called when the task is successful
  51327. */
  51328. onSuccess: (task: MeshAssetTask) => void;
  51329. /**
  51330. * Callback called when the task is successful
  51331. */
  51332. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  51333. /**
  51334. * Creates a new MeshAssetTask
  51335. * @param name defines the name of the task
  51336. * @param meshesNames defines the list of mesh's names you want to load
  51337. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  51338. * @param sceneFilename defines the filename of the scene to load from
  51339. */
  51340. constructor(
  51341. /**
  51342. * Defines the name of the task
  51343. */
  51344. name: string,
  51345. /**
  51346. * Defines the list of mesh's names you want to load
  51347. */
  51348. meshesNames: any,
  51349. /**
  51350. * Defines the root url to use as a base to load your meshes and associated resources
  51351. */
  51352. rootUrl: string,
  51353. /**
  51354. * Defines the filename of the scene to load from
  51355. */
  51356. sceneFilename: string);
  51357. /**
  51358. * Execute the current task
  51359. * @param scene defines the scene where you want your assets to be loaded
  51360. * @param onSuccess is a callback called when the task is successfully executed
  51361. * @param onError is a callback called if an error occurs
  51362. */
  51363. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51364. }
  51365. /**
  51366. * Define a task used by AssetsManager to load text content
  51367. */
  51368. export class TextFileAssetTask extends AbstractAssetTask {
  51369. /**
  51370. * Defines the name of the task
  51371. */
  51372. name: string;
  51373. /**
  51374. * Defines the location of the file to load
  51375. */
  51376. url: string;
  51377. /**
  51378. * Gets the loaded text string
  51379. */
  51380. text: string;
  51381. /**
  51382. * Callback called when the task is successful
  51383. */
  51384. onSuccess: (task: TextFileAssetTask) => void;
  51385. /**
  51386. * Callback called when the task is successful
  51387. */
  51388. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  51389. /**
  51390. * Creates a new TextFileAssetTask object
  51391. * @param name defines the name of the task
  51392. * @param url defines the location of the file to load
  51393. */
  51394. constructor(
  51395. /**
  51396. * Defines the name of the task
  51397. */
  51398. name: string,
  51399. /**
  51400. * Defines the location of the file to load
  51401. */
  51402. url: string);
  51403. /**
  51404. * Execute the current task
  51405. * @param scene defines the scene where you want your assets to be loaded
  51406. * @param onSuccess is a callback called when the task is successfully executed
  51407. * @param onError is a callback called if an error occurs
  51408. */
  51409. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51410. }
  51411. /**
  51412. * Define a task used by AssetsManager to load binary data
  51413. */
  51414. export class BinaryFileAssetTask extends AbstractAssetTask {
  51415. /**
  51416. * Defines the name of the task
  51417. */
  51418. name: string;
  51419. /**
  51420. * Defines the location of the file to load
  51421. */
  51422. url: string;
  51423. /**
  51424. * Gets the lodaded data (as an array buffer)
  51425. */
  51426. data: ArrayBuffer;
  51427. /**
  51428. * Callback called when the task is successful
  51429. */
  51430. onSuccess: (task: BinaryFileAssetTask) => void;
  51431. /**
  51432. * Callback called when the task is successful
  51433. */
  51434. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  51435. /**
  51436. * Creates a new BinaryFileAssetTask object
  51437. * @param name defines the name of the new task
  51438. * @param url defines the location of the file to load
  51439. */
  51440. constructor(
  51441. /**
  51442. * Defines the name of the task
  51443. */
  51444. name: string,
  51445. /**
  51446. * Defines the location of the file to load
  51447. */
  51448. url: string);
  51449. /**
  51450. * Execute the current task
  51451. * @param scene defines the scene where you want your assets to be loaded
  51452. * @param onSuccess is a callback called when the task is successfully executed
  51453. * @param onError is a callback called if an error occurs
  51454. */
  51455. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51456. }
  51457. /**
  51458. * Define a task used by AssetsManager to load images
  51459. */
  51460. export class ImageAssetTask extends AbstractAssetTask {
  51461. /**
  51462. * Defines the name of the task
  51463. */
  51464. name: string;
  51465. /**
  51466. * Defines the location of the image to load
  51467. */
  51468. url: string;
  51469. /**
  51470. * Gets the loaded images
  51471. */
  51472. image: HTMLImageElement;
  51473. /**
  51474. * Callback called when the task is successful
  51475. */
  51476. onSuccess: (task: ImageAssetTask) => void;
  51477. /**
  51478. * Callback called when the task is successful
  51479. */
  51480. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  51481. /**
  51482. * Creates a new ImageAssetTask
  51483. * @param name defines the name of the task
  51484. * @param url defines the location of the image to load
  51485. */
  51486. constructor(
  51487. /**
  51488. * Defines the name of the task
  51489. */
  51490. name: string,
  51491. /**
  51492. * Defines the location of the image to load
  51493. */
  51494. url: string);
  51495. /**
  51496. * Execute the current task
  51497. * @param scene defines the scene where you want your assets to be loaded
  51498. * @param onSuccess is a callback called when the task is successfully executed
  51499. * @param onError is a callback called if an error occurs
  51500. */
  51501. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51502. }
  51503. /**
  51504. * Defines the interface used by texture loading tasks
  51505. */
  51506. export interface ITextureAssetTask<TEX extends BaseTexture> {
  51507. /**
  51508. * Gets the loaded texture
  51509. */
  51510. texture: TEX;
  51511. }
  51512. /**
  51513. * Define a task used by AssetsManager to load 2D textures
  51514. */
  51515. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  51516. /**
  51517. * Defines the name of the task
  51518. */
  51519. name: string;
  51520. /**
  51521. * Defines the location of the file to load
  51522. */
  51523. url: string;
  51524. /**
  51525. * Defines if mipmap should not be generated (default is false)
  51526. */
  51527. noMipmap?: boolean | undefined;
  51528. /**
  51529. * Defines if texture must be inverted on Y axis (default is false)
  51530. */
  51531. invertY?: boolean | undefined;
  51532. /**
  51533. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51534. */
  51535. samplingMode: number;
  51536. /**
  51537. * Gets the loaded texture
  51538. */
  51539. texture: Texture;
  51540. /**
  51541. * Callback called when the task is successful
  51542. */
  51543. onSuccess: (task: TextureAssetTask) => void;
  51544. /**
  51545. * Callback called when the task is successful
  51546. */
  51547. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  51548. /**
  51549. * Creates a new TextureAssetTask object
  51550. * @param name defines the name of the task
  51551. * @param url defines the location of the file to load
  51552. * @param noMipmap defines if mipmap should not be generated (default is false)
  51553. * @param invertY defines if texture must be inverted on Y axis (default is false)
  51554. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51555. */
  51556. constructor(
  51557. /**
  51558. * Defines the name of the task
  51559. */
  51560. name: string,
  51561. /**
  51562. * Defines the location of the file to load
  51563. */
  51564. url: string,
  51565. /**
  51566. * Defines if mipmap should not be generated (default is false)
  51567. */
  51568. noMipmap?: boolean | undefined,
  51569. /**
  51570. * Defines if texture must be inverted on Y axis (default is false)
  51571. */
  51572. invertY?: boolean | undefined,
  51573. /**
  51574. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51575. */
  51576. samplingMode?: number);
  51577. /**
  51578. * Execute the current task
  51579. * @param scene defines the scene where you want your assets to be loaded
  51580. * @param onSuccess is a callback called when the task is successfully executed
  51581. * @param onError is a callback called if an error occurs
  51582. */
  51583. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51584. }
  51585. /**
  51586. * Define a task used by AssetsManager to load cube textures
  51587. */
  51588. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  51589. /**
  51590. * Defines the name of the task
  51591. */
  51592. name: string;
  51593. /**
  51594. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51595. */
  51596. url: string;
  51597. /**
  51598. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51599. */
  51600. extensions?: string[] | undefined;
  51601. /**
  51602. * Defines if mipmaps should not be generated (default is false)
  51603. */
  51604. noMipmap?: boolean | undefined;
  51605. /**
  51606. * Defines the explicit list of files (undefined by default)
  51607. */
  51608. files?: string[] | undefined;
  51609. /**
  51610. * Gets the loaded texture
  51611. */
  51612. texture: CubeTexture;
  51613. /**
  51614. * Callback called when the task is successful
  51615. */
  51616. onSuccess: (task: CubeTextureAssetTask) => void;
  51617. /**
  51618. * Callback called when the task is successful
  51619. */
  51620. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  51621. /**
  51622. * Creates a new CubeTextureAssetTask
  51623. * @param name defines the name of the task
  51624. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51625. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51626. * @param noMipmap defines if mipmaps should not be generated (default is false)
  51627. * @param files defines the explicit list of files (undefined by default)
  51628. */
  51629. constructor(
  51630. /**
  51631. * Defines the name of the task
  51632. */
  51633. name: string,
  51634. /**
  51635. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51636. */
  51637. url: string,
  51638. /**
  51639. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51640. */
  51641. extensions?: string[] | undefined,
  51642. /**
  51643. * Defines if mipmaps should not be generated (default is false)
  51644. */
  51645. noMipmap?: boolean | undefined,
  51646. /**
  51647. * Defines the explicit list of files (undefined by default)
  51648. */
  51649. files?: string[] | undefined);
  51650. /**
  51651. * Execute the current task
  51652. * @param scene defines the scene where you want your assets to be loaded
  51653. * @param onSuccess is a callback called when the task is successfully executed
  51654. * @param onError is a callback called if an error occurs
  51655. */
  51656. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51657. }
  51658. /**
  51659. * Define a task used by AssetsManager to load HDR cube textures
  51660. */
  51661. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  51662. /**
  51663. * Defines the name of the task
  51664. */
  51665. name: string;
  51666. /**
  51667. * Defines the location of the file to load
  51668. */
  51669. url: string;
  51670. /**
  51671. * Defines the desired size (the more it increases the longer the generation will be)
  51672. */
  51673. size: number;
  51674. /**
  51675. * Defines if mipmaps should not be generated (default is false)
  51676. */
  51677. noMipmap: boolean;
  51678. /**
  51679. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  51680. */
  51681. generateHarmonics: boolean;
  51682. /**
  51683. * 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)
  51684. */
  51685. gammaSpace: boolean;
  51686. /**
  51687. * Internal Use Only
  51688. */
  51689. reserved: boolean;
  51690. /**
  51691. * Gets the loaded texture
  51692. */
  51693. texture: HDRCubeTexture;
  51694. /**
  51695. * Callback called when the task is successful
  51696. */
  51697. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  51698. /**
  51699. * Callback called when the task is successful
  51700. */
  51701. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  51702. /**
  51703. * Creates a new HDRCubeTextureAssetTask object
  51704. * @param name defines the name of the task
  51705. * @param url defines the location of the file to load
  51706. * @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.
  51707. * @param noMipmap defines if mipmaps should not be generated (default is false)
  51708. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  51709. * @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)
  51710. * @param reserved Internal use only
  51711. */
  51712. constructor(
  51713. /**
  51714. * Defines the name of the task
  51715. */
  51716. name: string,
  51717. /**
  51718. * Defines the location of the file to load
  51719. */
  51720. url: string,
  51721. /**
  51722. * Defines the desired size (the more it increases the longer the generation will be)
  51723. */
  51724. size: number,
  51725. /**
  51726. * Defines if mipmaps should not be generated (default is false)
  51727. */
  51728. noMipmap?: boolean,
  51729. /**
  51730. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  51731. */
  51732. generateHarmonics?: boolean,
  51733. /**
  51734. * 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)
  51735. */
  51736. gammaSpace?: boolean,
  51737. /**
  51738. * Internal Use Only
  51739. */
  51740. reserved?: boolean);
  51741. /**
  51742. * Execute the current task
  51743. * @param scene defines the scene where you want your assets to be loaded
  51744. * @param onSuccess is a callback called when the task is successfully executed
  51745. * @param onError is a callback called if an error occurs
  51746. */
  51747. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51748. }
  51749. /**
  51750. * This class can be used to easily import assets into a scene
  51751. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  51752. */
  51753. export class AssetsManager {
  51754. private _scene;
  51755. private _isLoading;
  51756. protected _tasks: AbstractAssetTask[];
  51757. protected _waitingTasksCount: number;
  51758. protected _totalTasksCount: number;
  51759. /**
  51760. * Callback called when all tasks are processed
  51761. */
  51762. onFinish: (tasks: AbstractAssetTask[]) => void;
  51763. /**
  51764. * Callback called when a task is successful
  51765. */
  51766. onTaskSuccess: (task: AbstractAssetTask) => void;
  51767. /**
  51768. * Callback called when a task had an error
  51769. */
  51770. onTaskError: (task: AbstractAssetTask) => void;
  51771. /**
  51772. * Callback called when a task is done (whatever the result is)
  51773. */
  51774. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  51775. /**
  51776. * Observable called when all tasks are processed
  51777. */
  51778. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  51779. /**
  51780. * Observable called when a task had an error
  51781. */
  51782. onTaskErrorObservable: Observable<AbstractAssetTask>;
  51783. /**
  51784. * Observable called when a task is successful
  51785. */
  51786. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  51787. /**
  51788. * Observable called when a task is done (whatever the result is)
  51789. */
  51790. onProgressObservable: Observable<IAssetsProgressEvent>;
  51791. /**
  51792. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  51793. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  51794. */
  51795. useDefaultLoadingScreen: boolean;
  51796. /**
  51797. * Creates a new AssetsManager
  51798. * @param scene defines the scene to work on
  51799. */
  51800. constructor(scene: Scene);
  51801. /**
  51802. * Add a MeshAssetTask to the list of active tasks
  51803. * @param taskName defines the name of the new task
  51804. * @param meshesNames defines the name of meshes to load
  51805. * @param rootUrl defines the root url to use to locate files
  51806. * @param sceneFilename defines the filename of the scene file
  51807. * @returns a new MeshAssetTask object
  51808. */
  51809. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  51810. /**
  51811. * Add a TextFileAssetTask to the list of active tasks
  51812. * @param taskName defines the name of the new task
  51813. * @param url defines the url of the file to load
  51814. * @returns a new TextFileAssetTask object
  51815. */
  51816. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  51817. /**
  51818. * Add a BinaryFileAssetTask to the list of active tasks
  51819. * @param taskName defines the name of the new task
  51820. * @param url defines the url of the file to load
  51821. * @returns a new BinaryFileAssetTask object
  51822. */
  51823. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  51824. /**
  51825. * Add a ImageAssetTask to the list of active tasks
  51826. * @param taskName defines the name of the new task
  51827. * @param url defines the url of the file to load
  51828. * @returns a new ImageAssetTask object
  51829. */
  51830. addImageTask(taskName: string, url: string): ImageAssetTask;
  51831. /**
  51832. * Add a TextureAssetTask to the list of active tasks
  51833. * @param taskName defines the name of the new task
  51834. * @param url defines the url of the file to load
  51835. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  51836. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  51837. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51838. * @returns a new TextureAssetTask object
  51839. */
  51840. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  51841. /**
  51842. * Add a CubeTextureAssetTask to the list of active tasks
  51843. * @param taskName defines the name of the new task
  51844. * @param url defines the url of the file to load
  51845. * @param extensions defines the extension to use to load the cube map (can be null)
  51846. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  51847. * @param files defines the list of files to load (can be null)
  51848. * @returns a new CubeTextureAssetTask object
  51849. */
  51850. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  51851. /**
  51852. *
  51853. * Add a HDRCubeTextureAssetTask to the list of active tasks
  51854. * @param taskName defines the name of the new task
  51855. * @param url defines the url of the file to load
  51856. * @param size defines the size you want for the cubemap (can be null)
  51857. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  51858. * @param generateHarmonics defines if you want to automatically generate (true by default)
  51859. * @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)
  51860. * @param reserved Internal use only
  51861. * @returns a new HDRCubeTextureAssetTask object
  51862. */
  51863. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  51864. /**
  51865. * Remove a task from the assets manager.
  51866. * @param task the task to remove
  51867. */
  51868. removeTask(task: AbstractAssetTask): void;
  51869. private _decreaseWaitingTasksCount;
  51870. private _runTask;
  51871. /**
  51872. * Reset the AssetsManager and remove all tasks
  51873. * @return the current instance of the AssetsManager
  51874. */
  51875. reset(): AssetsManager;
  51876. /**
  51877. * Start the loading process
  51878. * @return the current instance of the AssetsManager
  51879. */
  51880. load(): AssetsManager;
  51881. }
  51882. }
  51883. declare module BABYLON {
  51884. /**
  51885. * Wrapper class for promise with external resolve and reject.
  51886. */
  51887. export class Deferred<T> {
  51888. /**
  51889. * The promise associated with this deferred object.
  51890. */
  51891. readonly promise: Promise<T>;
  51892. private _resolve;
  51893. private _reject;
  51894. /**
  51895. * The resolve method of the promise associated with this deferred object.
  51896. */
  51897. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  51898. /**
  51899. * The reject method of the promise associated with this deferred object.
  51900. */
  51901. readonly reject: (reason?: any) => void;
  51902. /**
  51903. * Constructor for this deferred object.
  51904. */
  51905. constructor();
  51906. }
  51907. }
  51908. declare module BABYLON {
  51909. /**
  51910. * Class used to help managing file picking and drag'n'drop
  51911. */
  51912. export class FilesInput {
  51913. /**
  51914. * List of files ready to be loaded
  51915. */
  51916. static readonly FilesToLoad: {
  51917. [key: string]: File;
  51918. };
  51919. /**
  51920. * Callback called when a file is processed
  51921. */
  51922. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  51923. private _engine;
  51924. private _currentScene;
  51925. private _sceneLoadedCallback;
  51926. private _progressCallback;
  51927. private _additionalRenderLoopLogicCallback;
  51928. private _textureLoadingCallback;
  51929. private _startingProcessingFilesCallback;
  51930. private _onReloadCallback;
  51931. private _errorCallback;
  51932. private _elementToMonitor;
  51933. private _sceneFileToLoad;
  51934. private _filesToLoad;
  51935. /**
  51936. * Creates a new FilesInput
  51937. * @param engine defines the rendering engine
  51938. * @param scene defines the hosting scene
  51939. * @param sceneLoadedCallback callback called when scene is loaded
  51940. * @param progressCallback callback called to track progress
  51941. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  51942. * @param textureLoadingCallback callback called when a texture is loading
  51943. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  51944. * @param onReloadCallback callback called when a reload is requested
  51945. * @param errorCallback callback call if an error occurs
  51946. */
  51947. 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);
  51948. private _dragEnterHandler;
  51949. private _dragOverHandler;
  51950. private _dropHandler;
  51951. /**
  51952. * Calls this function to listen to drag'n'drop events on a specific DOM element
  51953. * @param elementToMonitor defines the DOM element to track
  51954. */
  51955. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  51956. /**
  51957. * Release all associated resources
  51958. */
  51959. dispose(): void;
  51960. private renderFunction;
  51961. private drag;
  51962. private drop;
  51963. private _traverseFolder;
  51964. private _processFiles;
  51965. /**
  51966. * Load files from a drop event
  51967. * @param event defines the drop event to use as source
  51968. */
  51969. loadFiles(event: any): void;
  51970. private _processReload;
  51971. /**
  51972. * Reload the current scene from the loaded files
  51973. */
  51974. reload(): void;
  51975. }
  51976. }
  51977. declare module BABYLON {
  51978. /**
  51979. * Defines the root class used to create scene optimization to use with SceneOptimizer
  51980. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  51981. */
  51982. export class SceneOptimization {
  51983. /**
  51984. * Defines the priority of this optimization (0 by default which means first in the list)
  51985. */
  51986. priority: number;
  51987. /**
  51988. * Gets a string describing the action executed by the current optimization
  51989. * @returns description string
  51990. */
  51991. getDescription(): string;
  51992. /**
  51993. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  51994. * @param scene defines the current scene where to apply this optimization
  51995. * @param optimizer defines the current optimizer
  51996. * @returns true if everything that can be done was applied
  51997. */
  51998. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  51999. /**
  52000. * Creates the SceneOptimization object
  52001. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52002. * @param desc defines the description associated with the optimization
  52003. */
  52004. constructor(
  52005. /**
  52006. * Defines the priority of this optimization (0 by default which means first in the list)
  52007. */
  52008. priority?: number);
  52009. }
  52010. /**
  52011. * Defines an optimization used to reduce the size of render target textures
  52012. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52013. */
  52014. export class TextureOptimization extends SceneOptimization {
  52015. /**
  52016. * Defines the priority of this optimization (0 by default which means first in the list)
  52017. */
  52018. priority: number;
  52019. /**
  52020. * 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
  52021. */
  52022. maximumSize: number;
  52023. /**
  52024. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52025. */
  52026. step: number;
  52027. /**
  52028. * Gets a string describing the action executed by the current optimization
  52029. * @returns description string
  52030. */
  52031. getDescription(): string;
  52032. /**
  52033. * Creates the TextureOptimization object
  52034. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52035. * @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
  52036. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52037. */
  52038. constructor(
  52039. /**
  52040. * Defines the priority of this optimization (0 by default which means first in the list)
  52041. */
  52042. priority?: number,
  52043. /**
  52044. * 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
  52045. */
  52046. maximumSize?: number,
  52047. /**
  52048. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52049. */
  52050. step?: number);
  52051. /**
  52052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52053. * @param scene defines the current scene where to apply this optimization
  52054. * @param optimizer defines the current optimizer
  52055. * @returns true if everything that can be done was applied
  52056. */
  52057. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52058. }
  52059. /**
  52060. * Defines an optimization used to increase or decrease the rendering resolution
  52061. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52062. */
  52063. export class HardwareScalingOptimization extends SceneOptimization {
  52064. /**
  52065. * Defines the priority of this optimization (0 by default which means first in the list)
  52066. */
  52067. priority: number;
  52068. /**
  52069. * Defines the maximum scale to use (2 by default)
  52070. */
  52071. maximumScale: number;
  52072. /**
  52073. * Defines the step to use between two passes (0.5 by default)
  52074. */
  52075. step: number;
  52076. private _currentScale;
  52077. private _directionOffset;
  52078. /**
  52079. * Gets a string describing the action executed by the current optimization
  52080. * @return description string
  52081. */
  52082. getDescription(): string;
  52083. /**
  52084. * Creates the HardwareScalingOptimization object
  52085. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52086. * @param maximumScale defines the maximum scale to use (2 by default)
  52087. * @param step defines the step to use between two passes (0.5 by default)
  52088. */
  52089. constructor(
  52090. /**
  52091. * Defines the priority of this optimization (0 by default which means first in the list)
  52092. */
  52093. priority?: number,
  52094. /**
  52095. * Defines the maximum scale to use (2 by default)
  52096. */
  52097. maximumScale?: number,
  52098. /**
  52099. * Defines the step to use between two passes (0.5 by default)
  52100. */
  52101. step?: number);
  52102. /**
  52103. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52104. * @param scene defines the current scene where to apply this optimization
  52105. * @param optimizer defines the current optimizer
  52106. * @returns true if everything that can be done was applied
  52107. */
  52108. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52109. }
  52110. /**
  52111. * Defines an optimization used to remove shadows
  52112. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52113. */
  52114. export class ShadowsOptimization extends SceneOptimization {
  52115. /**
  52116. * Gets a string describing the action executed by the current optimization
  52117. * @return description string
  52118. */
  52119. getDescription(): string;
  52120. /**
  52121. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52122. * @param scene defines the current scene where to apply this optimization
  52123. * @param optimizer defines the current optimizer
  52124. * @returns true if everything that can be done was applied
  52125. */
  52126. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52127. }
  52128. /**
  52129. * Defines an optimization used to turn post-processes off
  52130. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52131. */
  52132. export class PostProcessesOptimization extends SceneOptimization {
  52133. /**
  52134. * Gets a string describing the action executed by the current optimization
  52135. * @return description string
  52136. */
  52137. getDescription(): string;
  52138. /**
  52139. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52140. * @param scene defines the current scene where to apply this optimization
  52141. * @param optimizer defines the current optimizer
  52142. * @returns true if everything that can be done was applied
  52143. */
  52144. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52145. }
  52146. /**
  52147. * Defines an optimization used to turn lens flares off
  52148. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52149. */
  52150. export class LensFlaresOptimization extends SceneOptimization {
  52151. /**
  52152. * Gets a string describing the action executed by the current optimization
  52153. * @return description string
  52154. */
  52155. getDescription(): string;
  52156. /**
  52157. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52158. * @param scene defines the current scene where to apply this optimization
  52159. * @param optimizer defines the current optimizer
  52160. * @returns true if everything that can be done was applied
  52161. */
  52162. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52163. }
  52164. /**
  52165. * Defines an optimization based on user defined callback.
  52166. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52167. */
  52168. export class CustomOptimization extends SceneOptimization {
  52169. /**
  52170. * Callback called to apply the custom optimization.
  52171. */
  52172. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  52173. /**
  52174. * Callback called to get custom description
  52175. */
  52176. onGetDescription: () => string;
  52177. /**
  52178. * Gets a string describing the action executed by the current optimization
  52179. * @returns description string
  52180. */
  52181. getDescription(): string;
  52182. /**
  52183. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52184. * @param scene defines the current scene where to apply this optimization
  52185. * @param optimizer defines the current optimizer
  52186. * @returns true if everything that can be done was applied
  52187. */
  52188. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52189. }
  52190. /**
  52191. * Defines an optimization used to turn particles off
  52192. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52193. */
  52194. export class ParticlesOptimization extends SceneOptimization {
  52195. /**
  52196. * Gets a string describing the action executed by the current optimization
  52197. * @return description string
  52198. */
  52199. getDescription(): string;
  52200. /**
  52201. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52202. * @param scene defines the current scene where to apply this optimization
  52203. * @param optimizer defines the current optimizer
  52204. * @returns true if everything that can be done was applied
  52205. */
  52206. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52207. }
  52208. /**
  52209. * Defines an optimization used to turn render targets off
  52210. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52211. */
  52212. export class RenderTargetsOptimization extends SceneOptimization {
  52213. /**
  52214. * Gets a string describing the action executed by the current optimization
  52215. * @return description string
  52216. */
  52217. getDescription(): string;
  52218. /**
  52219. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52220. * @param scene defines the current scene where to apply this optimization
  52221. * @param optimizer defines the current optimizer
  52222. * @returns true if everything that can be done was applied
  52223. */
  52224. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52225. }
  52226. /**
  52227. * Defines an optimization used to merge meshes with compatible materials
  52228. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52229. */
  52230. export class MergeMeshesOptimization extends SceneOptimization {
  52231. private static _UpdateSelectionTree;
  52232. /**
  52233. * Gets or sets a boolean which defines if optimization octree has to be updated
  52234. */
  52235. /**
  52236. * Gets or sets a boolean which defines if optimization octree has to be updated
  52237. */
  52238. static UpdateSelectionTree: boolean;
  52239. /**
  52240. * Gets a string describing the action executed by the current optimization
  52241. * @return description string
  52242. */
  52243. getDescription(): string;
  52244. private _canBeMerged;
  52245. /**
  52246. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52247. * @param scene defines the current scene where to apply this optimization
  52248. * @param optimizer defines the current optimizer
  52249. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  52250. * @returns true if everything that can be done was applied
  52251. */
  52252. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  52253. }
  52254. /**
  52255. * Defines a list of options used by SceneOptimizer
  52256. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52257. */
  52258. export class SceneOptimizerOptions {
  52259. /**
  52260. * Defines the target frame rate to reach (60 by default)
  52261. */
  52262. targetFrameRate: number;
  52263. /**
  52264. * Defines the interval between two checkes (2000ms by default)
  52265. */
  52266. trackerDuration: number;
  52267. /**
  52268. * Gets the list of optimizations to apply
  52269. */
  52270. optimizations: SceneOptimization[];
  52271. /**
  52272. * Creates a new list of options used by SceneOptimizer
  52273. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  52274. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  52275. */
  52276. constructor(
  52277. /**
  52278. * Defines the target frame rate to reach (60 by default)
  52279. */
  52280. targetFrameRate?: number,
  52281. /**
  52282. * Defines the interval between two checkes (2000ms by default)
  52283. */
  52284. trackerDuration?: number);
  52285. /**
  52286. * Add a new optimization
  52287. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  52288. * @returns the current SceneOptimizerOptions
  52289. */
  52290. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  52291. /**
  52292. * Add a new custom optimization
  52293. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  52294. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  52295. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52296. * @returns the current SceneOptimizerOptions
  52297. */
  52298. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  52299. /**
  52300. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  52301. * @param targetFrameRate defines the target frame rate (60 by default)
  52302. * @returns a SceneOptimizerOptions object
  52303. */
  52304. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52305. /**
  52306. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  52307. * @param targetFrameRate defines the target frame rate (60 by default)
  52308. * @returns a SceneOptimizerOptions object
  52309. */
  52310. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52311. /**
  52312. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  52313. * @param targetFrameRate defines the target frame rate (60 by default)
  52314. * @returns a SceneOptimizerOptions object
  52315. */
  52316. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52317. }
  52318. /**
  52319. * Class used to run optimizations in order to reach a target frame rate
  52320. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52321. */
  52322. export class SceneOptimizer implements IDisposable {
  52323. private _isRunning;
  52324. private _options;
  52325. private _scene;
  52326. private _currentPriorityLevel;
  52327. private _targetFrameRate;
  52328. private _trackerDuration;
  52329. private _currentFrameRate;
  52330. private _sceneDisposeObserver;
  52331. private _improvementMode;
  52332. /**
  52333. * Defines an observable called when the optimizer reaches the target frame rate
  52334. */
  52335. onSuccessObservable: Observable<SceneOptimizer>;
  52336. /**
  52337. * Defines an observable called when the optimizer enables an optimization
  52338. */
  52339. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  52340. /**
  52341. * Defines an observable called when the optimizer is not able to reach the target frame rate
  52342. */
  52343. onFailureObservable: Observable<SceneOptimizer>;
  52344. /**
  52345. * Gets a boolean indicating if the optimizer is in improvement mode
  52346. */
  52347. readonly isInImprovementMode: boolean;
  52348. /**
  52349. * Gets the current priority level (0 at start)
  52350. */
  52351. readonly currentPriorityLevel: number;
  52352. /**
  52353. * Gets the current frame rate checked by the SceneOptimizer
  52354. */
  52355. readonly currentFrameRate: number;
  52356. /**
  52357. * Gets or sets the current target frame rate (60 by default)
  52358. */
  52359. /**
  52360. * Gets or sets the current target frame rate (60 by default)
  52361. */
  52362. targetFrameRate: number;
  52363. /**
  52364. * Gets or sets the current interval between two checks (every 2000ms by default)
  52365. */
  52366. /**
  52367. * Gets or sets the current interval between two checks (every 2000ms by default)
  52368. */
  52369. trackerDuration: number;
  52370. /**
  52371. * Gets the list of active optimizations
  52372. */
  52373. readonly optimizations: SceneOptimization[];
  52374. /**
  52375. * Creates a new SceneOptimizer
  52376. * @param scene defines the scene to work on
  52377. * @param options defines the options to use with the SceneOptimizer
  52378. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  52379. * @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)
  52380. */
  52381. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  52382. /**
  52383. * Stops the current optimizer
  52384. */
  52385. stop(): void;
  52386. /**
  52387. * Reset the optimizer to initial step (current priority level = 0)
  52388. */
  52389. reset(): void;
  52390. /**
  52391. * Start the optimizer. By default it will try to reach a specific framerate
  52392. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  52393. */
  52394. start(): void;
  52395. private _checkCurrentState;
  52396. /**
  52397. * Release all resources
  52398. */
  52399. dispose(): void;
  52400. /**
  52401. * Helper function to create a SceneOptimizer with one single line of code
  52402. * @param scene defines the scene to work on
  52403. * @param options defines the options to use with the SceneOptimizer
  52404. * @param onSuccess defines a callback to call on success
  52405. * @param onFailure defines a callback to call on failure
  52406. * @returns the new SceneOptimizer object
  52407. */
  52408. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  52409. }
  52410. }
  52411. declare module BABYLON {
  52412. /**
  52413. * Class used to serialize a scene into a string
  52414. */
  52415. export class SceneSerializer {
  52416. /**
  52417. * Clear cache used by a previous serialization
  52418. */
  52419. static ClearCache(): void;
  52420. /**
  52421. * Serialize a scene into a JSON compatible object
  52422. * @param scene defines the scene to serialize
  52423. * @returns a JSON compatible object
  52424. */
  52425. static Serialize(scene: Scene): any;
  52426. /**
  52427. * Serialize a mesh into a JSON compatible object
  52428. * @param toSerialize defines the mesh to serialize
  52429. * @param withParents defines if parents must be serialized as well
  52430. * @param withChildren defines if children must be serialized as well
  52431. * @returns a JSON compatible object
  52432. */
  52433. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  52434. }
  52435. }
  52436. declare module BABYLON {
  52437. /**
  52438. * This represents the different options avilable for the video capture.
  52439. */
  52440. export interface VideoRecorderOptions {
  52441. /** Defines the mime type of the video */
  52442. mimeType: string;
  52443. /** Defines the video the video should be recorded at */
  52444. fps: number;
  52445. /** Defines the chunk size for the recording data */
  52446. recordChunckSize: number;
  52447. }
  52448. /**
  52449. * This can helps recording videos from BabylonJS.
  52450. * This is based on the available WebRTC functionalities of the browser.
  52451. *
  52452. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  52453. */
  52454. export class VideoRecorder {
  52455. private static readonly _defaultOptions;
  52456. /**
  52457. * Returns wehther or not the VideoRecorder is available in your browser.
  52458. * @param engine Defines the Babylon Engine to check the support for
  52459. * @returns true if supported otherwise false
  52460. */
  52461. static IsSupported(engine: Engine): boolean;
  52462. private readonly _options;
  52463. private _canvas;
  52464. private _mediaRecorder;
  52465. private _recordedChunks;
  52466. private _fileName;
  52467. private _resolve;
  52468. private _reject;
  52469. /**
  52470. * True wether a recording is already in progress.
  52471. */
  52472. readonly isRecording: boolean;
  52473. /**
  52474. * Create a new VideoCapture object which can help converting what you see in Babylon to
  52475. * a video file.
  52476. * @param engine Defines the BabylonJS Engine you wish to record
  52477. * @param options Defines options that can be used to customized the capture
  52478. */
  52479. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  52480. /**
  52481. * Stops the current recording before the default capture timeout passed in the startRecording
  52482. * functions.
  52483. */
  52484. stopRecording(): void;
  52485. /**
  52486. * Starts recording the canvas for a max duration specified in parameters.
  52487. * @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.
  52488. * @param maxDuration Defines the maximum recording time in seconds.
  52489. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  52490. * @return a promise callback at the end of the recording with the video data in Blob.
  52491. */
  52492. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  52493. /**
  52494. * Releases internal resources used during the recording.
  52495. */
  52496. dispose(): void;
  52497. private _handleDataAvailable;
  52498. private _handleError;
  52499. private _handleStop;
  52500. }
  52501. }
  52502. declare module BABYLON {
  52503. /**
  52504. * Helper class to push actions to a pool of workers.
  52505. */
  52506. export class WorkerPool implements IDisposable {
  52507. private _workerInfos;
  52508. private _pendingActions;
  52509. /**
  52510. * Constructor
  52511. * @param workers Array of workers to use for actions
  52512. */
  52513. constructor(workers: Array<Worker>);
  52514. /**
  52515. * Terminates all workers and clears any pending actions.
  52516. */
  52517. dispose(): void;
  52518. /**
  52519. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52520. * pended until a worker has completed its action.
  52521. * @param action The action to perform. Call onComplete when the action is complete.
  52522. */
  52523. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52524. private _execute;
  52525. }
  52526. }
  52527. declare module BABYLON {
  52528. /**
  52529. * Class containing a set of static utilities functions for screenshots
  52530. */
  52531. export class ScreenshotTools {
  52532. /**
  52533. * Captures a screenshot of the current rendering
  52534. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  52535. * @param engine defines the rendering engine
  52536. * @param camera defines the source camera
  52537. * @param size This parameter can be set to a single number or to an object with the
  52538. * following (optional) properties: precision, width, height. If a single number is passed,
  52539. * it will be used for both width and height. If an object is passed, the screenshot size
  52540. * will be derived from the parameters. The precision property is a multiplier allowing
  52541. * rendering at a higher or lower resolution
  52542. * @param successCallback defines the callback receives a single parameter which contains the
  52543. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  52544. * src parameter of an <img> to display it
  52545. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  52546. * Check your browser for supported MIME types
  52547. */
  52548. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  52549. /**
  52550. * Generates an image screenshot from the specified camera.
  52551. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  52552. * @param engine The engine to use for rendering
  52553. * @param camera The camera to use for rendering
  52554. * @param size This parameter can be set to a single number or to an object with the
  52555. * following (optional) properties: precision, width, height. If a single number is passed,
  52556. * it will be used for both width and height. If an object is passed, the screenshot size
  52557. * will be derived from the parameters. The precision property is a multiplier allowing
  52558. * rendering at a higher or lower resolution
  52559. * @param successCallback The callback receives a single parameter which contains the
  52560. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  52561. * src parameter of an <img> to display it
  52562. * @param mimeType The MIME type of the screenshot image (default: image/png).
  52563. * Check your browser for supported MIME types
  52564. * @param samples Texture samples (default: 1)
  52565. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  52566. * @param fileName A name for for the downloaded file.
  52567. */
  52568. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  52569. }
  52570. }
  52571. declare module BABYLON {
  52572. /**
  52573. * A cursor which tracks a point on a path
  52574. */
  52575. export class PathCursor {
  52576. private path;
  52577. /**
  52578. * Stores path cursor callbacks for when an onchange event is triggered
  52579. */
  52580. private _onchange;
  52581. /**
  52582. * The value of the path cursor
  52583. */
  52584. value: number;
  52585. /**
  52586. * The animation array of the path cursor
  52587. */
  52588. animations: Animation[];
  52589. /**
  52590. * Initializes the path cursor
  52591. * @param path The path to track
  52592. */
  52593. constructor(path: Path2);
  52594. /**
  52595. * Gets the cursor point on the path
  52596. * @returns A point on the path cursor at the cursor location
  52597. */
  52598. getPoint(): Vector3;
  52599. /**
  52600. * Moves the cursor ahead by the step amount
  52601. * @param step The amount to move the cursor forward
  52602. * @returns This path cursor
  52603. */
  52604. moveAhead(step?: number): PathCursor;
  52605. /**
  52606. * Moves the cursor behind by the step amount
  52607. * @param step The amount to move the cursor back
  52608. * @returns This path cursor
  52609. */
  52610. moveBack(step?: number): PathCursor;
  52611. /**
  52612. * Moves the cursor by the step amount
  52613. * If the step amount is greater than one, an exception is thrown
  52614. * @param step The amount to move the cursor
  52615. * @returns This path cursor
  52616. */
  52617. move(step: number): PathCursor;
  52618. /**
  52619. * Ensures that the value is limited between zero and one
  52620. * @returns This path cursor
  52621. */
  52622. private ensureLimits;
  52623. /**
  52624. * Runs onchange callbacks on change (used by the animation engine)
  52625. * @returns This path cursor
  52626. */
  52627. private raiseOnChange;
  52628. /**
  52629. * Executes a function on change
  52630. * @param f A path cursor onchange callback
  52631. * @returns This path cursor
  52632. */
  52633. onchange(f: (cursor: PathCursor) => void): PathCursor;
  52634. }
  52635. }
  52636. declare module BABYLON {
  52637. /** @hidden */
  52638. export var blurPixelShader: {
  52639. name: string;
  52640. shader: string;
  52641. };
  52642. }
  52643. declare module BABYLON {
  52644. /** @hidden */
  52645. export var bones300Declaration: {
  52646. name: string;
  52647. shader: string;
  52648. };
  52649. }
  52650. declare module BABYLON {
  52651. /** @hidden */
  52652. export var instances300Declaration: {
  52653. name: string;
  52654. shader: string;
  52655. };
  52656. }
  52657. declare module BABYLON {
  52658. /** @hidden */
  52659. export var pointCloudVertexDeclaration: {
  52660. name: string;
  52661. shader: string;
  52662. };
  52663. }
  52664. // Mixins
  52665. interface Window {
  52666. mozIndexedDB: IDBFactory;
  52667. webkitIndexedDB: IDBFactory;
  52668. msIndexedDB: IDBFactory;
  52669. webkitURL: typeof URL;
  52670. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  52671. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  52672. WebGLRenderingContext: WebGLRenderingContext;
  52673. MSGesture: MSGesture;
  52674. CANNON: any;
  52675. AudioContext: AudioContext;
  52676. webkitAudioContext: AudioContext;
  52677. PointerEvent: any;
  52678. Math: Math;
  52679. Uint8Array: Uint8ArrayConstructor;
  52680. Float32Array: Float32ArrayConstructor;
  52681. mozURL: typeof URL;
  52682. msURL: typeof URL;
  52683. VRFrameData: any; // WebVR, from specs 1.1
  52684. DracoDecoderModule: any;
  52685. setImmediate(handler: (...args: any[]) => void): number;
  52686. }
  52687. interface Document {
  52688. mozCancelFullScreen(): void;
  52689. msCancelFullScreen(): void;
  52690. webkitCancelFullScreen(): void;
  52691. requestPointerLock(): void;
  52692. exitPointerLock(): void;
  52693. mozFullScreen: boolean;
  52694. msIsFullScreen: boolean;
  52695. readonly webkitIsFullScreen: boolean;
  52696. readonly pointerLockElement: Element;
  52697. mozPointerLockElement: HTMLElement;
  52698. msPointerLockElement: HTMLElement;
  52699. webkitPointerLockElement: HTMLElement;
  52700. }
  52701. interface HTMLCanvasElement {
  52702. requestPointerLock(): void;
  52703. msRequestPointerLock?(): void;
  52704. mozRequestPointerLock?(): void;
  52705. webkitRequestPointerLock?(): void;
  52706. /** Track wether a record is in progress */
  52707. isRecording: boolean;
  52708. /** Capture Stream method defined by some browsers */
  52709. captureStream(fps?: number): MediaStream;
  52710. }
  52711. interface CanvasRenderingContext2D {
  52712. msImageSmoothingEnabled: boolean;
  52713. }
  52714. interface MouseEvent {
  52715. mozMovementX: number;
  52716. mozMovementY: number;
  52717. webkitMovementX: number;
  52718. webkitMovementY: number;
  52719. msMovementX: number;
  52720. msMovementY: number;
  52721. }
  52722. interface Navigator {
  52723. mozGetVRDevices: (any: any) => any;
  52724. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52725. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52726. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52727. webkitGetGamepads(): Gamepad[];
  52728. msGetGamepads(): Gamepad[];
  52729. webkitGamepads(): Gamepad[];
  52730. }
  52731. interface HTMLVideoElement {
  52732. mozSrcObject: any;
  52733. }
  52734. interface Math {
  52735. fround(x: number): number;
  52736. imul(a: number, b: number): number;
  52737. }
  52738. interface WebGLProgram {
  52739. context?: WebGLRenderingContext;
  52740. vertexShader?: WebGLShader;
  52741. fragmentShader?: WebGLShader;
  52742. isParallelCompiled: boolean;
  52743. onCompiled?: () => void;
  52744. }
  52745. interface WebGLRenderingContext {
  52746. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  52747. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  52748. vertexAttribDivisor(index: number, divisor: number): void;
  52749. createVertexArray(): any;
  52750. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  52751. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  52752. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  52753. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  52754. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  52755. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  52756. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  52757. // Queries
  52758. createQuery(): WebGLQuery;
  52759. deleteQuery(query: WebGLQuery): void;
  52760. beginQuery(target: number, query: WebGLQuery): void;
  52761. endQuery(target: number): void;
  52762. getQueryParameter(query: WebGLQuery, pname: number): any;
  52763. getQuery(target: number, pname: number): any;
  52764. MAX_SAMPLES: number;
  52765. RGBA8: number;
  52766. READ_FRAMEBUFFER: number;
  52767. DRAW_FRAMEBUFFER: number;
  52768. UNIFORM_BUFFER: number;
  52769. HALF_FLOAT_OES: number;
  52770. RGBA16F: number;
  52771. RGBA32F: number;
  52772. R32F: number;
  52773. RG32F: number;
  52774. RGB32F: number;
  52775. R16F: number;
  52776. RG16F: number;
  52777. RGB16F: number;
  52778. RED: number;
  52779. RG: number;
  52780. R8: number;
  52781. RG8: number;
  52782. UNSIGNED_INT_24_8: number;
  52783. DEPTH24_STENCIL8: number;
  52784. /* Multiple Render Targets */
  52785. drawBuffers(buffers: number[]): void;
  52786. readBuffer(src: number): void;
  52787. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  52788. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  52789. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  52790. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  52791. // Occlusion Query
  52792. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  52793. ANY_SAMPLES_PASSED: number;
  52794. QUERY_RESULT_AVAILABLE: number;
  52795. QUERY_RESULT: number;
  52796. }
  52797. interface WebGLBuffer {
  52798. references: number;
  52799. capacity: number;
  52800. is32Bits: boolean;
  52801. }
  52802. interface WebGLProgram {
  52803. transformFeedback?: WebGLTransformFeedback | null; private _SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  52804. }
  52805. interface EXT_disjoint_timer_query {
  52806. QUERY_COUNTER_BITS_EXT: number;
  52807. TIME_ELAPSED_EXT: number;
  52808. TIMESTAMP_EXT: number;
  52809. GPU_DISJOINT_EXT: number;
  52810. QUERY_RESULT_EXT: number;
  52811. QUERY_RESULT_AVAILABLE_EXT: number;
  52812. queryCounterEXT(query: WebGLQuery, target: number): void;
  52813. createQueryEXT(): WebGLQuery;
  52814. beginQueryEXT(target: number, query: WebGLQuery): void;
  52815. endQueryEXT(target: number): void;
  52816. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  52817. deleteQueryEXT(query: WebGLQuery): void;
  52818. }
  52819. interface WebGLUniformLocation { currentState: any;
  52820. }
  52821. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  52822. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  52823. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  52824. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  52825. interface WebGLRenderingContext {
  52826. readonly RASTERIZER_DISCARD: number;
  52827. readonly DEPTH_COMPONENT24: number;
  52828. readonly TEXTURE_3D: number;
  52829. readonly TEXTURE_2D_ARRAY: number;
  52830. readonly TEXTURE_COMPARE_FUNC: number;
  52831. readonly TEXTURE_COMPARE_MODE: number;
  52832. readonly COMPARE_REF_TO_TEXTURE: number;
  52833. readonly TEXTURE_WRAP_R: number;
  52834. readonly HALF_FLOAT: number;
  52835. readonly RGB8: number;
  52836. readonly RED_INTEGER: number;
  52837. readonly RG_INTEGER: number;
  52838. readonly RGB_INTEGER: number;
  52839. readonly RGBA_INTEGER: number;
  52840. readonly R8_SNORM: number;
  52841. readonly RG8_SNORM: number;
  52842. readonly RGB8_SNORM: number;
  52843. readonly RGBA8_SNORM: number;
  52844. readonly R8I: number;
  52845. readonly RG8I: number;
  52846. readonly RGB8I: number;
  52847. readonly RGBA8I: number;
  52848. readonly R8UI: number;
  52849. readonly RG8UI: number;
  52850. readonly RGB8UI: number;
  52851. readonly RGBA8UI: number;
  52852. readonly R16I: number;
  52853. readonly RG16I: number;
  52854. readonly RGB16I: number;
  52855. readonly RGBA16I: number;
  52856. readonly R16UI: number;
  52857. readonly RG16UI: number;
  52858. readonly RGB16UI: number;
  52859. readonly RGBA16UI: number;
  52860. readonly R32I: number;
  52861. readonly RG32I: number;
  52862. readonly RGB32I: number;
  52863. readonly RGBA32I: number;
  52864. readonly R32UI: number;
  52865. readonly RG32UI: number;
  52866. readonly RGB32UI: number;
  52867. readonly RGBA32UI: number;
  52868. readonly RGB10_A2UI: number;
  52869. readonly R11F_G11F_B10F: number;
  52870. readonly RGB9_E5: number;
  52871. readonly RGB10_A2: number;
  52872. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  52873. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  52874. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  52875. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  52876. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  52877. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  52878. 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;
  52879. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  52880. readonly TRANSFORM_FEEDBACK: number;
  52881. readonly INTERLEAVED_ATTRIBS: number;
  52882. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  52883. createTransformFeedback(): WebGLTransformFeedback;
  52884. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  52885. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  52886. beginTransformFeedback(primitiveMode: number): void;
  52887. endTransformFeedback(): void;
  52888. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  52889. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  52890. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  52891. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  52892. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  52893. }
  52894. interface ImageBitmap {
  52895. readonly width: number;
  52896. readonly height: number;
  52897. close(): void;
  52898. }
  52899. interface WebGLQuery extends WebGLObject {
  52900. }
  52901. declare var WebGLQuery: {
  52902. prototype: WebGLQuery;
  52903. new(): WebGLQuery;
  52904. };
  52905. interface WebGLSampler extends WebGLObject {
  52906. }
  52907. declare var WebGLSampler: {
  52908. prototype: WebGLSampler;
  52909. new(): WebGLSampler;
  52910. };
  52911. interface WebGLSync extends WebGLObject {
  52912. }
  52913. declare var WebGLSync: {
  52914. prototype: WebGLSync;
  52915. new(): WebGLSync;
  52916. };
  52917. interface WebGLTransformFeedback extends WebGLObject {
  52918. }
  52919. declare var WebGLTransformFeedback: {
  52920. prototype: WebGLTransformFeedback;
  52921. new(): WebGLTransformFeedback;
  52922. };
  52923. interface WebGLVertexArrayObject extends WebGLObject {
  52924. }
  52925. declare var WebGLVertexArrayObject: {
  52926. prototype: WebGLVertexArrayObject;
  52927. new(): WebGLVertexArrayObject;
  52928. };
  52929. // Type definitions for WebVR API
  52930. // Project: https://w3c.github.io/webvr/
  52931. // Definitions by: six a <https://github.com/lostfictions>
  52932. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  52933. interface VRDisplay extends EventTarget {
  52934. /**
  52935. * Dictionary of capabilities describing the VRDisplay.
  52936. */
  52937. readonly capabilities: VRDisplayCapabilities;
  52938. /**
  52939. * z-depth defining the far plane of the eye view frustum
  52940. * enables mapping of values in the render target depth
  52941. * attachment to scene coordinates. Initially set to 10000.0.
  52942. */
  52943. depthFar: number;
  52944. /**
  52945. * z-depth defining the near plane of the eye view frustum
  52946. * enables mapping of values in the render target depth
  52947. * attachment to scene coordinates. Initially set to 0.01.
  52948. */
  52949. depthNear: number;
  52950. /**
  52951. * An identifier for this distinct VRDisplay. Used as an
  52952. * association point in the Gamepad API.
  52953. */
  52954. readonly displayId: number;
  52955. /**
  52956. * A display name, a user-readable name identifying it.
  52957. */
  52958. readonly displayName: string;
  52959. readonly isConnected: boolean;
  52960. readonly isPresenting: boolean;
  52961. /**
  52962. * If this VRDisplay supports room-scale experiences, the optional
  52963. * stage attribute contains details on the room-scale parameters.
  52964. */
  52965. readonly stageParameters: VRStageParameters | null;
  52966. /**
  52967. * Passing the value returned by `requestAnimationFrame` to
  52968. * `cancelAnimationFrame` will unregister the callback.
  52969. * @param handle Define the hanle of the request to cancel
  52970. */
  52971. cancelAnimationFrame(handle: number): void;
  52972. /**
  52973. * Stops presenting to the VRDisplay.
  52974. * @returns a promise to know when it stopped
  52975. */
  52976. exitPresent(): Promise<void>;
  52977. /**
  52978. * Return the current VREyeParameters for the given eye.
  52979. * @param whichEye Define the eye we want the parameter for
  52980. * @returns the eye parameters
  52981. */
  52982. getEyeParameters(whichEye: string): VREyeParameters;
  52983. /**
  52984. * Populates the passed VRFrameData with the information required to render
  52985. * the current frame.
  52986. * @param frameData Define the data structure to populate
  52987. * @returns true if ok otherwise false
  52988. */
  52989. getFrameData(frameData: VRFrameData): boolean;
  52990. /**
  52991. * Get the layers currently being presented.
  52992. * @returns the list of VR layers
  52993. */
  52994. getLayers(): VRLayer[];
  52995. /**
  52996. * Return a VRPose containing the future predicted pose of the VRDisplay
  52997. * when the current frame will be presented. The value returned will not
  52998. * change until JavaScript has returned control to the browser.
  52999. *
  53000. * The VRPose will contain the position, orientation, velocity,
  53001. * and acceleration of each of these properties.
  53002. * @returns the pose object
  53003. */
  53004. getPose(): VRPose;
  53005. /**
  53006. * Return the current instantaneous pose of the VRDisplay, with no
  53007. * prediction applied.
  53008. * @returns the current instantaneous pose
  53009. */
  53010. getImmediatePose(): VRPose;
  53011. /**
  53012. * The callback passed to `requestAnimationFrame` will be called
  53013. * any time a new frame should be rendered. When the VRDisplay is
  53014. * presenting the callback will be called at the native refresh
  53015. * rate of the HMD. When not presenting this function acts
  53016. * identically to how window.requestAnimationFrame acts. Content should
  53017. * make no assumptions of frame rate or vsync behavior as the HMD runs
  53018. * asynchronously from other displays and at differing refresh rates.
  53019. * @param callback Define the eaction to run next frame
  53020. * @returns the request handle it
  53021. */
  53022. requestAnimationFrame(callback: FrameRequestCallback): number;
  53023. /**
  53024. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  53025. * Repeat calls while already presenting will update the VRLayers being displayed.
  53026. * @param layers Define the list of layer to present
  53027. * @returns a promise to know when the request has been fulfilled
  53028. */
  53029. requestPresent(layers: VRLayer[]): Promise<void>;
  53030. /**
  53031. * Reset the pose for this display, treating its current position and
  53032. * orientation as the "origin/zero" values. VRPose.position,
  53033. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  53034. * updated when calling resetPose(). This should be called in only
  53035. * sitting-space experiences.
  53036. */
  53037. resetPose(): void;
  53038. /**
  53039. * The VRLayer provided to the VRDisplay will be captured and presented
  53040. * in the HMD. Calling this function has the same effect on the source
  53041. * canvas as any other operation that uses its source image, and canvases
  53042. * created without preserveDrawingBuffer set to true will be cleared.
  53043. * @param pose Define the pose to submit
  53044. */
  53045. submitFrame(pose?: VRPose): void;
  53046. }
  53047. declare var VRDisplay: {
  53048. prototype: VRDisplay;
  53049. new(): VRDisplay;
  53050. };
  53051. interface VRLayer {
  53052. leftBounds?: number[] | Float32Array | null;
  53053. rightBounds?: number[] | Float32Array | null;
  53054. source?: HTMLCanvasElement | null;
  53055. }
  53056. interface VRDisplayCapabilities {
  53057. readonly canPresent: boolean;
  53058. readonly hasExternalDisplay: boolean;
  53059. readonly hasOrientation: boolean;
  53060. readonly hasPosition: boolean;
  53061. readonly maxLayers: number;
  53062. }
  53063. interface VREyeParameters {
  53064. /** @deprecated */
  53065. readonly fieldOfView: VRFieldOfView;
  53066. readonly offset: Float32Array;
  53067. readonly renderHeight: number;
  53068. readonly renderWidth: number;
  53069. }
  53070. interface VRFieldOfView {
  53071. readonly downDegrees: number;
  53072. readonly leftDegrees: number;
  53073. readonly rightDegrees: number;
  53074. readonly upDegrees: number;
  53075. }
  53076. interface VRFrameData {
  53077. readonly leftProjectionMatrix: Float32Array;
  53078. readonly leftViewMatrix: Float32Array;
  53079. readonly pose: VRPose;
  53080. readonly rightProjectionMatrix: Float32Array;
  53081. readonly rightViewMatrix: Float32Array;
  53082. readonly timestamp: number;
  53083. }
  53084. interface VRPose {
  53085. readonly angularAcceleration: Float32Array | null;
  53086. readonly angularVelocity: Float32Array | null;
  53087. readonly linearAcceleration: Float32Array | null;
  53088. readonly linearVelocity: Float32Array | null;
  53089. readonly orientation: Float32Array | null;
  53090. readonly position: Float32Array | null;
  53091. readonly timestamp: number;
  53092. }
  53093. interface VRStageParameters {
  53094. sittingToStandingTransform?: Float32Array;
  53095. sizeX?: number;
  53096. sizeY?: number;
  53097. }
  53098. interface Navigator {
  53099. getVRDisplays(): Promise<VRDisplay[]>;
  53100. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  53101. }
  53102. interface Window {
  53103. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  53104. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  53105. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  53106. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53107. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53108. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  53109. }
  53110. interface Gamepad {
  53111. readonly displayId: number;
  53112. }
  53113. interface XRDevice {
  53114. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  53115. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  53116. }
  53117. interface XRSession {
  53118. getInputSources(): Array<any>;
  53119. baseLayer: XRWebGLLayer;
  53120. requestFrameOfReference(type: string): Promise<void>;
  53121. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  53122. end(): Promise<void>;
  53123. requestAnimationFrame: Function;
  53124. addEventListener: Function;
  53125. }
  53126. interface XRSessionCreationOptions {
  53127. outputContext?: WebGLRenderingContext | null;
  53128. immersive?: boolean;
  53129. environmentIntegration?: boolean;
  53130. }
  53131. interface XRLayer {
  53132. getViewport: Function;
  53133. framebufferWidth: number;
  53134. framebufferHeight: number;
  53135. }
  53136. interface XRView {
  53137. projectionMatrix: Float32Array;
  53138. }
  53139. interface XRFrame {
  53140. getDevicePose: Function;
  53141. getInputPose: Function;
  53142. views: Array<XRView>;
  53143. baseLayer: XRLayer;
  53144. }
  53145. interface XRFrameOfReference {
  53146. }
  53147. interface XRWebGLLayer extends XRLayer {
  53148. framebuffer: WebGLFramebuffer;
  53149. }
  53150. declare var XRWebGLLayer: {
  53151. prototype: XRWebGLLayer;
  53152. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  53153. };
  53154. declare module BABYLON.GUI {
  53155. /**
  53156. * Class used to specific a value and its associated unit
  53157. */
  53158. export class ValueAndUnit {
  53159. /** defines the unit to store */
  53160. unit: number;
  53161. /** defines a boolean indicating if the value can be negative */
  53162. negativeValueAllowed: boolean;
  53163. private _value;
  53164. private _originalUnit;
  53165. /**
  53166. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  53167. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53168. */
  53169. ignoreAdaptiveScaling: boolean;
  53170. /**
  53171. * Creates a new ValueAndUnit
  53172. * @param value defines the value to store
  53173. * @param unit defines the unit to store
  53174. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  53175. */
  53176. constructor(value: number,
  53177. /** defines the unit to store */
  53178. unit?: number,
  53179. /** defines a boolean indicating if the value can be negative */
  53180. negativeValueAllowed?: boolean);
  53181. /** Gets a boolean indicating if the value is a percentage */
  53182. readonly isPercentage: boolean;
  53183. /** Gets a boolean indicating if the value is store as pixel */
  53184. readonly isPixel: boolean;
  53185. /** Gets direct internal value */
  53186. readonly internalValue: number;
  53187. /**
  53188. * Gets value as pixel
  53189. * @param host defines the root host
  53190. * @param refValue defines the reference value for percentages
  53191. * @returns the value as pixel
  53192. */
  53193. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  53194. /**
  53195. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  53196. * @param value defines the value to store
  53197. * @param unit defines the unit to store
  53198. * @returns the current ValueAndUnit
  53199. */
  53200. updateInPlace(value: number, unit?: number): ValueAndUnit;
  53201. /**
  53202. * Gets the value accordingly to its unit
  53203. * @param host defines the root host
  53204. * @returns the value
  53205. */
  53206. getValue(host: AdvancedDynamicTexture): number;
  53207. /**
  53208. * Gets a string representation of the value
  53209. * @param host defines the root host
  53210. * @returns a string
  53211. */
  53212. toString(host: AdvancedDynamicTexture): string;
  53213. /**
  53214. * Store a value parsed from a string
  53215. * @param source defines the source string
  53216. * @returns true if the value was successfully parsed
  53217. */
  53218. fromString(source: string | number): boolean;
  53219. private static _Regex;
  53220. private static _UNITMODE_PERCENTAGE;
  53221. private static _UNITMODE_PIXEL;
  53222. /** UNITMODE_PERCENTAGE */
  53223. static readonly UNITMODE_PERCENTAGE: number;
  53224. /** UNITMODE_PIXEL */
  53225. static readonly UNITMODE_PIXEL: number;
  53226. }
  53227. }
  53228. declare module BABYLON.GUI {
  53229. /**
  53230. * Define a style used by control to automatically setup properties based on a template.
  53231. * Only support font related properties so far
  53232. */
  53233. export class Style implements BABYLON.IDisposable {
  53234. private _fontFamily;
  53235. private _fontStyle;
  53236. private _fontWeight;
  53237. /** @hidden */ host: AdvancedDynamicTexture;
  53238. /** @hidden */ fontSize: ValueAndUnit;
  53239. /**
  53240. * BABYLON.Observable raised when the style values are changed
  53241. */
  53242. onChangedObservable: BABYLON.Observable<Style>;
  53243. /**
  53244. * Creates a new style object
  53245. * @param host defines the AdvancedDynamicTexture which hosts this style
  53246. */
  53247. constructor(host: AdvancedDynamicTexture);
  53248. /**
  53249. * Gets or sets the font size
  53250. */
  53251. fontSize: string | number;
  53252. /**
  53253. * Gets or sets the font family
  53254. */
  53255. fontFamily: string;
  53256. /**
  53257. * Gets or sets the font style
  53258. */
  53259. fontStyle: string;
  53260. /** Gets or sets font weight */
  53261. fontWeight: string;
  53262. /** Dispose all associated resources */
  53263. dispose(): void;
  53264. }
  53265. }
  53266. declare module BABYLON.GUI {
  53267. /**
  53268. * Class used to transport BABYLON.Vector2 information for pointer events
  53269. */
  53270. export class Vector2WithInfo extends BABYLON.Vector2 {
  53271. /** defines the current mouse button index */
  53272. buttonIndex: number;
  53273. /**
  53274. * Creates a new Vector2WithInfo
  53275. * @param source defines the vector2 data to transport
  53276. * @param buttonIndex defines the current mouse button index
  53277. */
  53278. constructor(source: BABYLON.Vector2,
  53279. /** defines the current mouse button index */
  53280. buttonIndex?: number);
  53281. }
  53282. /** Class used to provide 2D matrix features */
  53283. export class Matrix2D {
  53284. /** Gets the internal array of 6 floats used to store matrix data */
  53285. m: Float32Array;
  53286. /**
  53287. * Creates a new matrix
  53288. * @param m00 defines value for (0, 0)
  53289. * @param m01 defines value for (0, 1)
  53290. * @param m10 defines value for (1, 0)
  53291. * @param m11 defines value for (1, 1)
  53292. * @param m20 defines value for (2, 0)
  53293. * @param m21 defines value for (2, 1)
  53294. */
  53295. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  53296. /**
  53297. * Fills the matrix from direct values
  53298. * @param m00 defines value for (0, 0)
  53299. * @param m01 defines value for (0, 1)
  53300. * @param m10 defines value for (1, 0)
  53301. * @param m11 defines value for (1, 1)
  53302. * @param m20 defines value for (2, 0)
  53303. * @param m21 defines value for (2, 1)
  53304. * @returns the current modified matrix
  53305. */
  53306. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  53307. /**
  53308. * Gets matrix determinant
  53309. * @returns the determinant
  53310. */
  53311. determinant(): number;
  53312. /**
  53313. * Inverses the matrix and stores it in a target matrix
  53314. * @param result defines the target matrix
  53315. * @returns the current matrix
  53316. */
  53317. invertToRef(result: Matrix2D): Matrix2D;
  53318. /**
  53319. * Multiplies the current matrix with another one
  53320. * @param other defines the second operand
  53321. * @param result defines the target matrix
  53322. * @returns the current matrix
  53323. */
  53324. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  53325. /**
  53326. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  53327. * @param x defines the x coordinate to transform
  53328. * @param y defines the x coordinate to transform
  53329. * @param result defines the target vector2
  53330. * @returns the current matrix
  53331. */
  53332. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  53333. /**
  53334. * Creates an identity matrix
  53335. * @returns a new matrix
  53336. */
  53337. static Identity(): Matrix2D;
  53338. /**
  53339. * Creates a translation matrix and stores it in a target matrix
  53340. * @param x defines the x coordinate of the translation
  53341. * @param y defines the y coordinate of the translation
  53342. * @param result defines the target matrix
  53343. */
  53344. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  53345. /**
  53346. * Creates a scaling matrix and stores it in a target matrix
  53347. * @param x defines the x coordinate of the scaling
  53348. * @param y defines the y coordinate of the scaling
  53349. * @param result defines the target matrix
  53350. */
  53351. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  53352. /**
  53353. * Creates a rotation matrix and stores it in a target matrix
  53354. * @param angle defines the rotation angle
  53355. * @param result defines the target matrix
  53356. */
  53357. static RotationToRef(angle: number, result: Matrix2D): void;
  53358. private static _TempPreTranslationMatrix;
  53359. private static _TempPostTranslationMatrix;
  53360. private static _TempRotationMatrix;
  53361. private static _TempScalingMatrix;
  53362. private static _TempCompose0;
  53363. private static _TempCompose1;
  53364. private static _TempCompose2;
  53365. /**
  53366. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  53367. * @param tx defines the x coordinate of the translation
  53368. * @param ty defines the y coordinate of the translation
  53369. * @param angle defines the rotation angle
  53370. * @param scaleX defines the x coordinate of the scaling
  53371. * @param scaleY defines the y coordinate of the scaling
  53372. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  53373. * @param result defines the target matrix
  53374. */
  53375. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  53376. }
  53377. }
  53378. declare module BABYLON.GUI {
  53379. /**
  53380. * Class used to store 2D control sizes
  53381. */
  53382. export class Measure {
  53383. /** defines left coordinate */
  53384. left: number;
  53385. /** defines top coordinate */
  53386. top: number;
  53387. /** defines width dimension */
  53388. width: number;
  53389. /** defines height dimension */
  53390. height: number;
  53391. /**
  53392. * Creates a new measure
  53393. * @param left defines left coordinate
  53394. * @param top defines top coordinate
  53395. * @param width defines width dimension
  53396. * @param height defines height dimension
  53397. */
  53398. constructor(
  53399. /** defines left coordinate */
  53400. left: number,
  53401. /** defines top coordinate */
  53402. top: number,
  53403. /** defines width dimension */
  53404. width: number,
  53405. /** defines height dimension */
  53406. height: number);
  53407. /**
  53408. * Copy from another measure
  53409. * @param other defines the other measure to copy from
  53410. */
  53411. copyFrom(other: Measure): void;
  53412. /**
  53413. * Copy from a group of 4 floats
  53414. * @param left defines left coordinate
  53415. * @param top defines top coordinate
  53416. * @param width defines width dimension
  53417. * @param height defines height dimension
  53418. */
  53419. copyFromFloats(left: number, top: number, width: number, height: number): void;
  53420. /**
  53421. * Computes the axis aligned bounding box measure for two given measures
  53422. * @param a Input measure
  53423. * @param b Input measure
  53424. * @param result the resulting bounding measure
  53425. */
  53426. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  53427. /**
  53428. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  53429. * @param transform the matrix to transform the measure before computing the AABB
  53430. * @param result the resulting AABB
  53431. */
  53432. transformToRef(transform: Matrix2D, result: Measure): void;
  53433. /**
  53434. * Check equality between this measure and another one
  53435. * @param other defines the other measures
  53436. * @returns true if both measures are equals
  53437. */
  53438. isEqualsTo(other: Measure): boolean;
  53439. /**
  53440. * Creates an empty measure
  53441. * @returns a new measure
  53442. */
  53443. static Empty(): Measure;
  53444. }
  53445. }
  53446. declare module BABYLON.GUI {
  53447. /**
  53448. * Interface used to define a control that can receive focus
  53449. */
  53450. export interface IFocusableControl {
  53451. /**
  53452. * Function called when the control receives the focus
  53453. */
  53454. onFocus(): void;
  53455. /**
  53456. * Function called when the control loses the focus
  53457. */
  53458. onBlur(): void;
  53459. /**
  53460. * Function called to let the control handle keyboard events
  53461. * @param evt defines the current keyboard event
  53462. */
  53463. processKeyboard(evt: KeyboardEvent): void;
  53464. /**
  53465. * Function called to get the list of controls that should not steal the focus from this control
  53466. * @returns an array of controls
  53467. */
  53468. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  53469. }
  53470. /**
  53471. * Class used to create texture to support 2D GUI elements
  53472. * @see http://doc.babylonjs.com/how_to/gui
  53473. */
  53474. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  53475. private _isDirty;
  53476. private _renderObserver;
  53477. private _resizeObserver;
  53478. private _preKeyboardObserver;
  53479. private _pointerMoveObserver;
  53480. private _pointerObserver;
  53481. private _canvasPointerOutObserver;
  53482. private _background;
  53483. /** @hidden */ rootContainer: Container;
  53484. /** @hidden */ lastPickedControl: Control;
  53485. /** @hidden */ lastControlOver: {
  53486. [pointerId: number]: Control;
  53487. };
  53488. /** @hidden */ lastControlDown: {
  53489. [pointerId: number]: Control;
  53490. };
  53491. /** @hidden */ capturingControl: {
  53492. [pointerId: number]: Control;
  53493. };
  53494. /** @hidden */ shouldBlockPointer: boolean;
  53495. /** @hidden */ layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  53496. /** @hidden */ linkedControls: Control[];
  53497. private _isFullscreen;
  53498. private _fullscreenViewport;
  53499. private _idealWidth;
  53500. private _idealHeight;
  53501. private _useSmallestIdeal;
  53502. private _renderAtIdealSize;
  53503. private _focusedControl;
  53504. private _blockNextFocusCheck;
  53505. private _renderScale;
  53506. private _rootCanvas;
  53507. /**
  53508. * Define type to string to ensure compatibility across browsers
  53509. * Safari doesn't support DataTransfer constructor
  53510. */
  53511. private _clipboardData;
  53512. /**
  53513. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  53514. */
  53515. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  53516. /**
  53517. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  53518. */
  53519. onControlPickedObservable: BABYLON.Observable<Control>;
  53520. /**
  53521. * BABYLON.Observable event triggered before layout is evaluated
  53522. */
  53523. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  53524. /**
  53525. * BABYLON.Observable event triggered after the layout was evaluated
  53526. */
  53527. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  53528. /**
  53529. * BABYLON.Observable event triggered before the texture is rendered
  53530. */
  53531. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  53532. /**
  53533. * BABYLON.Observable event triggered after the texture was rendered
  53534. */
  53535. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  53536. /**
  53537. * Gets or sets a boolean defining if alpha is stored as premultiplied
  53538. */
  53539. premulAlpha: boolean;
  53540. /**
  53541. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  53542. * Useful when you want more antialiasing
  53543. */
  53544. renderScale: number;
  53545. /** Gets or sets the background color */
  53546. background: string;
  53547. /**
  53548. * Gets or sets the ideal width used to design controls.
  53549. * The GUI will then rescale everything accordingly
  53550. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53551. */
  53552. idealWidth: number;
  53553. /**
  53554. * Gets or sets the ideal height used to design controls.
  53555. * The GUI will then rescale everything accordingly
  53556. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53557. */
  53558. idealHeight: number;
  53559. /**
  53560. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  53561. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53562. */
  53563. useSmallestIdeal: boolean;
  53564. /**
  53565. * Gets or sets a boolean indicating if adaptive scaling must be used
  53566. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53567. */
  53568. renderAtIdealSize: boolean;
  53569. /**
  53570. * Gets the underlying layer used to render the texture when in fullscreen mode
  53571. */
  53572. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  53573. /**
  53574. * Gets the root container control
  53575. */
  53576. readonly rootContainer: Container;
  53577. /**
  53578. * Returns an array containing the root container.
  53579. * This is mostly used to let the Inspector introspects the ADT
  53580. * @returns an array containing the rootContainer
  53581. */
  53582. getChildren(): Array<Container>;
  53583. /**
  53584. * Will return all controls that are inside this texture
  53585. * @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
  53586. * @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
  53587. * @return all child controls
  53588. */
  53589. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  53590. /**
  53591. * Gets or sets the current focused control
  53592. */
  53593. focusedControl: BABYLON.Nullable<IFocusableControl>;
  53594. /**
  53595. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  53596. */
  53597. isForeground: boolean;
  53598. /**
  53599. * Gets or set information about clipboardData
  53600. */
  53601. clipboardData: string;
  53602. /**
  53603. * Creates a new AdvancedDynamicTexture
  53604. * @param name defines the name of the texture
  53605. * @param width defines the width of the texture
  53606. * @param height defines the height of the texture
  53607. * @param scene defines the hosting scene
  53608. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  53609. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  53610. */
  53611. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  53612. /**
  53613. * Get the current class name of the texture useful for serialization or dynamic coding.
  53614. * @returns "AdvancedDynamicTexture"
  53615. */
  53616. getClassName(): string;
  53617. /**
  53618. * Function used to execute a function on all controls
  53619. * @param func defines the function to execute
  53620. * @param container defines the container where controls belong. If null the root container will be used
  53621. */
  53622. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  53623. private _useInvalidateRectOptimization;
  53624. /**
  53625. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  53626. */
  53627. useInvalidateRectOptimization: boolean;
  53628. private _invalidatedRectangle;
  53629. /**
  53630. * Invalidates a rectangle area on the gui texture
  53631. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  53632. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  53633. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  53634. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  53635. */
  53636. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  53637. /**
  53638. * Marks the texture as dirty forcing a complete update
  53639. */
  53640. markAsDirty(): void;
  53641. /**
  53642. * Helper function used to create a new style
  53643. * @returns a new style
  53644. * @see http://doc.babylonjs.com/how_to/gui#styles
  53645. */
  53646. createStyle(): Style;
  53647. /**
  53648. * Adds a new control to the root container
  53649. * @param control defines the control to add
  53650. * @returns the current texture
  53651. */
  53652. addControl(control: Control): AdvancedDynamicTexture;
  53653. /**
  53654. * Removes a control from the root container
  53655. * @param control defines the control to remove
  53656. * @returns the current texture
  53657. */
  53658. removeControl(control: Control): AdvancedDynamicTexture;
  53659. /**
  53660. * Release all resources
  53661. */
  53662. dispose(): void;
  53663. private _onResize;
  53664. /** @hidden */ getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  53665. /**
  53666. * Get screen coordinates for a vector3
  53667. * @param position defines the position to project
  53668. * @param worldMatrix defines the world matrix to use
  53669. * @returns the projected position
  53670. */
  53671. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  53672. private _checkUpdate;
  53673. private _clearMeasure;
  53674. private _render;
  53675. /** @hidden */ changeCursor(cursor: string): void;
  53676. /** @hidden */ registerLastControlDown(control: Control, pointerId: number): void;
  53677. private _doPicking;
  53678. /** @hidden */ cleanControlAfterRemovalFromList(list: {
  53679. [pointerId: number]: Control;
  53680. }, control: Control): void;
  53681. /** @hidden */ cleanControlAfterRemoval(control: Control): void;
  53682. /** Attach to all scene events required to support pointer events */
  53683. attach(): void;
  53684. /** @hidden */
  53685. private onClipboardCopy;
  53686. /** @hidden */
  53687. private onClipboardCut;
  53688. /** @hidden */
  53689. private onClipboardPaste;
  53690. /**
  53691. * Register the clipboard Events onto the canvas
  53692. */
  53693. registerClipboardEvents(): void;
  53694. /**
  53695. * Unregister the clipboard Events from the canvas
  53696. */
  53697. unRegisterClipboardEvents(): void;
  53698. /**
  53699. * Connect the texture to a hosting mesh to enable interactions
  53700. * @param mesh defines the mesh to attach to
  53701. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  53702. */
  53703. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  53704. /**
  53705. * Move the focus to a specific control
  53706. * @param control defines the control which will receive the focus
  53707. */
  53708. moveFocusToControl(control: IFocusableControl): void;
  53709. private _manageFocus;
  53710. private _attachToOnPointerOut;
  53711. /**
  53712. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  53713. * @param mesh defines the mesh which will receive the texture
  53714. * @param width defines the texture width (1024 by default)
  53715. * @param height defines the texture height (1024 by default)
  53716. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  53717. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  53718. * @returns a new AdvancedDynamicTexture
  53719. */
  53720. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  53721. /**
  53722. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  53723. * In this mode the texture will rely on a layer for its rendering.
  53724. * This allows it to be treated like any other layer.
  53725. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  53726. * LayerMask is set through advancedTexture.layer.layerMask
  53727. * @param name defines name for the texture
  53728. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  53729. * @param scene defines the hsoting scene
  53730. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  53731. * @returns a new AdvancedDynamicTexture
  53732. */
  53733. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  53734. }
  53735. }
  53736. declare module BABYLON.GUI {
  53737. /**
  53738. * Root class used for all 2D controls
  53739. * @see http://doc.babylonjs.com/how_to/gui#controls
  53740. */
  53741. export class Control {
  53742. /** defines the name of the control */
  53743. name?: string | undefined;
  53744. /**
  53745. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  53746. */
  53747. static AllowAlphaInheritance: boolean;
  53748. private _alpha;
  53749. private _alphaSet;
  53750. private _zIndex;
  53751. /** @hidden */ host: AdvancedDynamicTexture;
  53752. /** Gets or sets the control parent */
  53753. parent: BABYLON.Nullable<Container>;
  53754. /** @hidden */ currentMeasure: Measure;
  53755. private _fontFamily;
  53756. private _fontStyle;
  53757. private _fontWeight;
  53758. private _fontSize;
  53759. private _font;
  53760. /** @hidden */ width: ValueAndUnit;
  53761. /** @hidden */ height: ValueAndUnit;
  53762. /** @hidden */
  53763. protected _fontOffset: {
  53764. ascent: number;
  53765. height: number;
  53766. descent: number;
  53767. };
  53768. private _color;
  53769. private _style;
  53770. private _styleObserver;
  53771. /** @hidden */
  53772. protected _horizontalAlignment: number;
  53773. /** @hidden */
  53774. protected _verticalAlignment: number;
  53775. /** @hidden */
  53776. protected _isDirty: boolean;
  53777. /** @hidden */
  53778. protected _wasDirty: boolean;
  53779. /** @hidden */ tempParentMeasure: Measure;
  53780. /** @hidden */ prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  53781. /** @hidden */
  53782. protected _cachedParentMeasure: Measure;
  53783. private _paddingLeft;
  53784. private _paddingRight;
  53785. private _paddingTop;
  53786. private _paddingBottom;
  53787. /** @hidden */ left: ValueAndUnit;
  53788. /** @hidden */ top: ValueAndUnit;
  53789. private _scaleX;
  53790. private _scaleY;
  53791. private _rotation;
  53792. private _transformCenterX;
  53793. private _transformCenterY;
  53794. /** @hidden */ transformMatrix: Matrix2D;
  53795. /** @hidden */
  53796. protected _invertTransformMatrix: Matrix2D;
  53797. /** @hidden */
  53798. protected _transformedPosition: BABYLON.Vector2;
  53799. private _isMatrixDirty;
  53800. private _cachedOffsetX;
  53801. private _cachedOffsetY;
  53802. private _isVisible;
  53803. private _isHighlighted;
  53804. /** @hidden */ linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  53805. private _fontSet;
  53806. private _dummyVector2;
  53807. private _downCount;
  53808. private _enterCount;
  53809. private _doNotRender;
  53810. private _downPointerIds;
  53811. protected _isEnabled: boolean;
  53812. protected _disabledColor: string;
  53813. /** @hidden */
  53814. protected _rebuildLayout: boolean;
  53815. /** @hidden */ isClipped: boolean;
  53816. /** @hidden */ tag: any;
  53817. /**
  53818. * 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
  53819. */
  53820. uniqueId: number;
  53821. /**
  53822. * Gets or sets an object used to store user defined information for the node
  53823. */
  53824. metadata: any;
  53825. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  53826. isHitTestVisible: boolean;
  53827. /** Gets or sets a boolean indicating if the control can block pointer events */
  53828. isPointerBlocker: boolean;
  53829. /** Gets or sets a boolean indicating if the control can be focusable */
  53830. isFocusInvisible: boolean;
  53831. /**
  53832. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  53833. * 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
  53834. */
  53835. clipChildren: boolean;
  53836. /**
  53837. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  53838. */
  53839. useBitmapCache: boolean;
  53840. private _cacheData;
  53841. private _shadowOffsetX;
  53842. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  53843. shadowOffsetX: number;
  53844. private _shadowOffsetY;
  53845. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  53846. shadowOffsetY: number;
  53847. private _shadowBlur;
  53848. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  53849. shadowBlur: number;
  53850. private _shadowColor;
  53851. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  53852. shadowColor: string;
  53853. /** Gets or sets the cursor to use when the control is hovered */
  53854. hoverCursor: string;
  53855. /** @hidden */
  53856. protected _linkOffsetX: ValueAndUnit;
  53857. /** @hidden */
  53858. protected _linkOffsetY: ValueAndUnit;
  53859. /** Gets the control type name */
  53860. readonly typeName: string;
  53861. /**
  53862. * Get the current class name of the control.
  53863. * @returns current class name
  53864. */
  53865. getClassName(): string;
  53866. /**
  53867. * An event triggered when the pointer move over the control.
  53868. */
  53869. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  53870. /**
  53871. * An event triggered when the pointer move out of the control.
  53872. */
  53873. onPointerOutObservable: BABYLON.Observable<Control>;
  53874. /**
  53875. * An event triggered when the pointer taps the control
  53876. */
  53877. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  53878. /**
  53879. * An event triggered when pointer up
  53880. */
  53881. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  53882. /**
  53883. * An event triggered when a control is clicked on
  53884. */
  53885. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  53886. /**
  53887. * An event triggered when pointer enters the control
  53888. */
  53889. onPointerEnterObservable: BABYLON.Observable<Control>;
  53890. /**
  53891. * An event triggered when the control is marked as dirty
  53892. */
  53893. onDirtyObservable: BABYLON.Observable<Control>;
  53894. /**
  53895. * An event triggered before drawing the control
  53896. */
  53897. onBeforeDrawObservable: BABYLON.Observable<Control>;
  53898. /**
  53899. * An event triggered after the control was drawn
  53900. */
  53901. onAfterDrawObservable: BABYLON.Observable<Control>;
  53902. /**
  53903. * Get the hosting AdvancedDynamicTexture
  53904. */
  53905. readonly host: AdvancedDynamicTexture;
  53906. /** Gets or set information about font offsets (used to render and align text) */
  53907. fontOffset: {
  53908. ascent: number;
  53909. height: number;
  53910. descent: number;
  53911. };
  53912. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  53913. alpha: number;
  53914. /**
  53915. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  53916. */
  53917. isHighlighted: boolean;
  53918. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  53919. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53920. */
  53921. scaleX: number;
  53922. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  53923. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53924. */
  53925. scaleY: number;
  53926. /** Gets or sets the rotation angle (0 by default)
  53927. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53928. */
  53929. rotation: number;
  53930. /** Gets or sets the transformation center on Y axis (0 by default)
  53931. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53932. */
  53933. transformCenterY: number;
  53934. /** Gets or sets the transformation center on X axis (0 by default)
  53935. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53936. */
  53937. transformCenterX: number;
  53938. /**
  53939. * Gets or sets the horizontal alignment
  53940. * @see http://doc.babylonjs.com/how_to/gui#alignments
  53941. */
  53942. horizontalAlignment: number;
  53943. /**
  53944. * Gets or sets the vertical alignment
  53945. * @see http://doc.babylonjs.com/how_to/gui#alignments
  53946. */
  53947. verticalAlignment: number;
  53948. /**
  53949. * Gets or sets control width
  53950. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53951. */
  53952. width: string | number;
  53953. /**
  53954. * Gets control width in pixel
  53955. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53956. */
  53957. readonly widthInPixels: number;
  53958. /**
  53959. * Gets or sets control height
  53960. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53961. */
  53962. height: string | number;
  53963. /**
  53964. * Gets control height in pixel
  53965. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53966. */
  53967. readonly heightInPixels: number;
  53968. /** Gets or set font family */
  53969. fontFamily: string;
  53970. /** Gets or sets font style */
  53971. fontStyle: string;
  53972. /** Gets or sets font weight */
  53973. fontWeight: string;
  53974. /**
  53975. * Gets or sets style
  53976. * @see http://doc.babylonjs.com/how_to/gui#styles
  53977. */
  53978. style: BABYLON.Nullable<Style>;
  53979. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  53980. /** Gets font size in pixels */
  53981. readonly fontSizeInPixels: number;
  53982. /** Gets or sets font size */
  53983. fontSize: string | number;
  53984. /** Gets or sets foreground color */
  53985. color: string;
  53986. /** Gets or sets z index which is used to reorder controls on the z axis */
  53987. zIndex: number;
  53988. /** Gets or sets a boolean indicating if the control can be rendered */
  53989. notRenderable: boolean;
  53990. /** Gets or sets a boolean indicating if the control is visible */
  53991. isVisible: boolean;
  53992. /** Gets a boolean indicating that the control needs to update its rendering */
  53993. readonly isDirty: boolean;
  53994. /**
  53995. * Gets the current linked mesh (or null if none)
  53996. */
  53997. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  53998. /**
  53999. * Gets or sets a value indicating the padding to use on the left of the control
  54000. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54001. */
  54002. paddingLeft: string | number;
  54003. /**
  54004. * Gets a value indicating the padding in pixels to use on the left of the control
  54005. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54006. */
  54007. readonly paddingLeftInPixels: number;
  54008. /**
  54009. * Gets or sets a value indicating the padding to use on the right of the control
  54010. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54011. */
  54012. paddingRight: string | number;
  54013. /**
  54014. * Gets a value indicating the padding in pixels to use on the right of the control
  54015. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54016. */
  54017. readonly paddingRightInPixels: number;
  54018. /**
  54019. * Gets or sets a value indicating the padding to use on the top of the control
  54020. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54021. */
  54022. paddingTop: string | number;
  54023. /**
  54024. * Gets a value indicating the padding in pixels to use on the top of the control
  54025. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54026. */
  54027. readonly paddingTopInPixels: number;
  54028. /**
  54029. * Gets or sets a value indicating the padding to use on the bottom of the control
  54030. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54031. */
  54032. paddingBottom: string | number;
  54033. /**
  54034. * Gets a value indicating the padding in pixels to use on the bottom of the control
  54035. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54036. */
  54037. readonly paddingBottomInPixels: number;
  54038. /**
  54039. * Gets or sets a value indicating the left coordinate of the control
  54040. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54041. */
  54042. left: string | number;
  54043. /**
  54044. * Gets a value indicating the left coordinate in pixels of the control
  54045. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54046. */
  54047. readonly leftInPixels: number;
  54048. /**
  54049. * Gets or sets a value indicating the top coordinate of the control
  54050. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54051. */
  54052. top: string | number;
  54053. /**
  54054. * Gets a value indicating the top coordinate in pixels of the control
  54055. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54056. */
  54057. readonly topInPixels: number;
  54058. /**
  54059. * Gets or sets a value indicating the offset on X axis to the linked mesh
  54060. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  54061. */
  54062. linkOffsetX: string | number;
  54063. /**
  54064. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  54065. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  54066. */
  54067. readonly linkOffsetXInPixels: number;
  54068. /**
  54069. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  54070. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  54071. */
  54072. linkOffsetY: string | number;
  54073. /**
  54074. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  54075. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  54076. */
  54077. readonly linkOffsetYInPixels: number;
  54078. /** Gets the center coordinate on X axis */
  54079. readonly centerX: number;
  54080. /** Gets the center coordinate on Y axis */
  54081. readonly centerY: number;
  54082. /** Gets or sets if control is Enabled*/
  54083. isEnabled: boolean;
  54084. /** Gets or sets background color of control if it's disabled*/
  54085. disabledColor: string;
  54086. /**
  54087. * Creates a new control
  54088. * @param name defines the name of the control
  54089. */
  54090. constructor(
  54091. /** defines the name of the control */
  54092. name?: string | undefined);
  54093. /** @hidden */
  54094. protected _getTypeName(): string;
  54095. /**
  54096. * Gets the first ascendant in the hierarchy of the given type
  54097. * @param className defines the required type
  54098. * @returns the ascendant or null if not found
  54099. */
  54100. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  54101. /** @hidden */ resetFontCache(): void;
  54102. /**
  54103. * Determines if a container is an ascendant of the current control
  54104. * @param container defines the container to look for
  54105. * @returns true if the container is one of the ascendant of the control
  54106. */
  54107. isAscendant(container: Control): boolean;
  54108. /**
  54109. * Gets coordinates in local control space
  54110. * @param globalCoordinates defines the coordinates to transform
  54111. * @returns the new coordinates in local space
  54112. */
  54113. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  54114. /**
  54115. * Gets coordinates in local control space
  54116. * @param globalCoordinates defines the coordinates to transform
  54117. * @param result defines the target vector2 where to store the result
  54118. * @returns the current control
  54119. */
  54120. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  54121. /**
  54122. * Gets coordinates in parent local control space
  54123. * @param globalCoordinates defines the coordinates to transform
  54124. * @returns the new coordinates in parent local space
  54125. */
  54126. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  54127. /**
  54128. * Move the current control to a vector3 position projected onto the screen.
  54129. * @param position defines the target position
  54130. * @param scene defines the hosting scene
  54131. */
  54132. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  54133. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  54134. /**
  54135. * Will return all controls that have this control as ascendant
  54136. * @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
  54137. * @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
  54138. * @return all child controls
  54139. */
  54140. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  54141. /**
  54142. * Link current control with a target mesh
  54143. * @param mesh defines the mesh to link with
  54144. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  54145. */
  54146. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  54147. /** @hidden */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  54148. /** @hidden */ offsetLeft(offset: number): void;
  54149. /** @hidden */ offsetTop(offset: number): void;
  54150. /** @hidden */ markMatrixAsDirty(): void;
  54151. /** @hidden */ flagDescendantsAsMatrixDirty(): void;
  54152. /** @hidden */ intersectsRect(rect: Measure): boolean;
  54153. /** @hidden */
  54154. protected invalidateRect(): void;
  54155. /** @hidden */ markAsDirty(force?: boolean): void;
  54156. /** @hidden */ markAllAsDirty(): void;
  54157. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  54158. /** @hidden */
  54159. protected _transform(context?: CanvasRenderingContext2D): void;
  54160. /** @hidden */ renderHighlight(context: CanvasRenderingContext2D): void;
  54161. /** @hidden */ renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  54162. /** @hidden */
  54163. protected _applyStates(context: CanvasRenderingContext2D): void;
  54164. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  54165. /** @hidden */
  54166. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54167. protected _evaluateClippingState(parentMeasure: Measure): void;
  54168. /** @hidden */ measure(): void;
  54169. /** @hidden */
  54170. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54171. /** @hidden */
  54172. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54173. /** @hidden */
  54174. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54175. /** @hidden */
  54176. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  54177. private static _ClipMeasure;
  54178. private _tmpMeasureA;
  54179. private _clip;
  54180. /** @hidden */ render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  54181. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  54182. /**
  54183. * Tests if a given coordinates belong to the current control
  54184. * @param x defines x coordinate to test
  54185. * @param y defines y coordinate to test
  54186. * @returns true if the coordinates are inside the control
  54187. */
  54188. contains(x: number, y: number): boolean;
  54189. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  54190. /** @hidden */ onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
  54191. /** @hidden */ onPointerEnter(target: Control): boolean;
  54192. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  54193. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  54194. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  54195. /** @hidden */ forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  54196. /** @hidden */ processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  54197. private _prepareFont;
  54198. /** Releases associated resources */
  54199. dispose(): void;
  54200. private static _HORIZONTAL_ALIGNMENT_LEFT;
  54201. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  54202. private static _HORIZONTAL_ALIGNMENT_CENTER;
  54203. private static _VERTICAL_ALIGNMENT_TOP;
  54204. private static _VERTICAL_ALIGNMENT_BOTTOM;
  54205. private static _VERTICAL_ALIGNMENT_CENTER;
  54206. /** HORIZONTAL_ALIGNMENT_LEFT */
  54207. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  54208. /** HORIZONTAL_ALIGNMENT_RIGHT */
  54209. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  54210. /** HORIZONTAL_ALIGNMENT_CENTER */
  54211. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  54212. /** VERTICAL_ALIGNMENT_TOP */
  54213. static readonly VERTICAL_ALIGNMENT_TOP: number;
  54214. /** VERTICAL_ALIGNMENT_BOTTOM */
  54215. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  54216. /** VERTICAL_ALIGNMENT_CENTER */
  54217. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  54218. private static _FontHeightSizes;
  54219. /** @hidden */ private static _GetFontOffset(font: string): {
  54220. ascent: number;
  54221. height: number;
  54222. descent: number;
  54223. };
  54224. /**
  54225. * Creates a stack panel that can be used to render headers
  54226. * @param control defines the control to associate with the header
  54227. * @param text defines the text of the header
  54228. * @param size defines the size of the header
  54229. * @param options defines options used to configure the header
  54230. * @returns a new StackPanel
  54231. * @ignore
  54232. * @hidden
  54233. */
  54234. static AddHeader: (control: Control, text: string, size: string | number, options: {
  54235. isHorizontal: boolean;
  54236. controlFirst: boolean;
  54237. }) => any;
  54238. /** @hidden */
  54239. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  54240. }
  54241. }
  54242. declare module BABYLON.GUI {
  54243. /**
  54244. * Root class for 2D containers
  54245. * @see http://doc.babylonjs.com/how_to/gui#containers
  54246. */
  54247. export class Container extends Control {
  54248. name?: string | undefined;
  54249. /** @hidden */
  54250. protected _children: Control[];
  54251. /** @hidden */
  54252. protected _measureForChildren: Measure;
  54253. /** @hidden */
  54254. protected _background: string;
  54255. /** @hidden */
  54256. protected _adaptWidthToChildren: boolean;
  54257. /** @hidden */
  54258. protected _adaptHeightToChildren: boolean;
  54259. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  54260. adaptHeightToChildren: boolean;
  54261. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  54262. adaptWidthToChildren: boolean;
  54263. /** Gets or sets background color */
  54264. background: string;
  54265. /** Gets the list of children */
  54266. readonly children: Control[];
  54267. /**
  54268. * Creates a new Container
  54269. * @param name defines the name of the container
  54270. */
  54271. constructor(name?: string | undefined);
  54272. protected _getTypeName(): string; flagDescendantsAsMatrixDirty(): void;
  54273. /**
  54274. * Gets a child using its name
  54275. * @param name defines the child name to look for
  54276. * @returns the child control if found
  54277. */
  54278. getChildByName(name: string): BABYLON.Nullable<Control>;
  54279. /**
  54280. * Gets a child using its type and its name
  54281. * @param name defines the child name to look for
  54282. * @param type defines the child type to look for
  54283. * @returns the child control if found
  54284. */
  54285. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  54286. /**
  54287. * Search for a specific control in children
  54288. * @param control defines the control to look for
  54289. * @returns true if the control is in child list
  54290. */
  54291. containsControl(control: Control): boolean;
  54292. /**
  54293. * Adds a new control to the current container
  54294. * @param control defines the control to add
  54295. * @returns the current container
  54296. */
  54297. addControl(control: BABYLON.Nullable<Control>): Container;
  54298. /**
  54299. * Removes all controls from the current container
  54300. * @returns the current container
  54301. */
  54302. clearControls(): Container;
  54303. /**
  54304. * Removes a control from the current container
  54305. * @param control defines the control to remove
  54306. * @returns the current container
  54307. */
  54308. removeControl(control: Control): Container;
  54309. /** @hidden */ reOrderControl(control: Control): void;
  54310. /** @hidden */ offsetLeft(offset: number): void;
  54311. /** @hidden */ offsetTop(offset: number): void;
  54312. /** @hidden */ markAllAsDirty(): void;
  54313. /** @hidden */
  54314. protected _localDraw(context: CanvasRenderingContext2D): void;
  54315. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  54316. /** @hidden */
  54317. protected _beforeLayout(): void;
  54318. /** @hidden */
  54319. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54320. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  54321. protected _postMeasure(): void;
  54322. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  54323. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  54324. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  54325. /** @hidden */
  54326. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54327. /** Releases associated resources */
  54328. dispose(): void;
  54329. }
  54330. }
  54331. declare module BABYLON.GUI {
  54332. /** Class used to create rectangle container */
  54333. export class Rectangle extends Container {
  54334. name?: string | undefined;
  54335. private _thickness;
  54336. private _cornerRadius;
  54337. /** Gets or sets border thickness */
  54338. thickness: number;
  54339. /** Gets or sets the corner radius angle */
  54340. cornerRadius: number;
  54341. /**
  54342. * Creates a new Rectangle
  54343. * @param name defines the control name
  54344. */
  54345. constructor(name?: string | undefined);
  54346. protected _getTypeName(): string;
  54347. protected _localDraw(context: CanvasRenderingContext2D): void;
  54348. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54349. private _drawRoundedRect;
  54350. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  54351. }
  54352. }
  54353. declare module BABYLON.GUI {
  54354. /**
  54355. * Enum that determines the text-wrapping mode to use.
  54356. */
  54357. export enum TextWrapping {
  54358. /**
  54359. * Clip the text when it's larger than Control.width; this is the default mode.
  54360. */
  54361. Clip = 0,
  54362. /**
  54363. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  54364. */
  54365. WordWrap = 1,
  54366. /**
  54367. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  54368. */
  54369. Ellipsis = 2
  54370. }
  54371. /**
  54372. * Class used to create text block control
  54373. */
  54374. export class TextBlock extends Control {
  54375. /**
  54376. * Defines the name of the control
  54377. */
  54378. name?: string | undefined;
  54379. private _text;
  54380. private _textWrapping;
  54381. private _textHorizontalAlignment;
  54382. private _textVerticalAlignment;
  54383. private _lines;
  54384. private _resizeToFit;
  54385. private _lineSpacing;
  54386. private _outlineWidth;
  54387. private _outlineColor;
  54388. /**
  54389. * An event triggered after the text is changed
  54390. */
  54391. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  54392. /**
  54393. * An event triggered after the text was broken up into lines
  54394. */
  54395. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  54396. /**
  54397. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  54398. */
  54399. readonly lines: any[];
  54400. /**
  54401. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  54402. */
  54403. /**
  54404. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  54405. */
  54406. resizeToFit: boolean;
  54407. /**
  54408. * Gets or sets a boolean indicating if text must be wrapped
  54409. */
  54410. /**
  54411. * Gets or sets a boolean indicating if text must be wrapped
  54412. */
  54413. textWrapping: TextWrapping | boolean;
  54414. /**
  54415. * Gets or sets text to display
  54416. */
  54417. /**
  54418. * Gets or sets text to display
  54419. */
  54420. text: string;
  54421. /**
  54422. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  54423. */
  54424. /**
  54425. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  54426. */
  54427. textHorizontalAlignment: number;
  54428. /**
  54429. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  54430. */
  54431. /**
  54432. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  54433. */
  54434. textVerticalAlignment: number;
  54435. /**
  54436. * Gets or sets line spacing value
  54437. */
  54438. /**
  54439. * Gets or sets line spacing value
  54440. */
  54441. lineSpacing: string | number;
  54442. /**
  54443. * Gets or sets outlineWidth of the text to display
  54444. */
  54445. /**
  54446. * Gets or sets outlineWidth of the text to display
  54447. */
  54448. outlineWidth: number;
  54449. /**
  54450. * Gets or sets outlineColor of the text to display
  54451. */
  54452. /**
  54453. * Gets or sets outlineColor of the text to display
  54454. */
  54455. outlineColor: string;
  54456. /**
  54457. * Creates a new TextBlock object
  54458. * @param name defines the name of the control
  54459. * @param text defines the text to display (emptry string by default)
  54460. */
  54461. constructor(
  54462. /**
  54463. * Defines the name of the control
  54464. */
  54465. name?: string | undefined, text?: string);
  54466. protected _getTypeName(): string;
  54467. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54468. private _drawText;
  54469. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  54470. protected _applyStates(context: CanvasRenderingContext2D): void;
  54471. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  54472. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  54473. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  54474. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  54475. protected _renderLines(context: CanvasRenderingContext2D): void;
  54476. /**
  54477. * Given a width constraint applied on the text block, find the expected height
  54478. * @returns expected height
  54479. */
  54480. computeExpectedHeight(): number;
  54481. dispose(): void;
  54482. }
  54483. }
  54484. declare module BABYLON.GUI {
  54485. /**
  54486. * Class used to create 2D images
  54487. */
  54488. export class Image extends Control {
  54489. name?: string | undefined;
  54490. private static _WorkingCanvas;
  54491. private _domImage;
  54492. private _imageWidth;
  54493. private _imageHeight;
  54494. private _loaded;
  54495. private _stretch;
  54496. private _source;
  54497. private _autoScale;
  54498. private _sourceLeft;
  54499. private _sourceTop;
  54500. private _sourceWidth;
  54501. private _sourceHeight;
  54502. private _cellWidth;
  54503. private _cellHeight;
  54504. private _cellId;
  54505. private _populateNinePatchSlicesFromImage;
  54506. private _sliceLeft;
  54507. private _sliceRight;
  54508. private _sliceTop;
  54509. private _sliceBottom;
  54510. private _detectPointerOnOpaqueOnly;
  54511. /**
  54512. * BABYLON.Observable notified when the content is loaded
  54513. */
  54514. onImageLoadedObservable: BABYLON.Observable<Image>;
  54515. /**
  54516. * Gets a boolean indicating that the content is loaded
  54517. */
  54518. readonly isLoaded: boolean;
  54519. /**
  54520. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  54521. */
  54522. populateNinePatchSlicesFromImage: boolean;
  54523. /**
  54524. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  54525. * Beware using this as this will comsume more memory as the image has to be stored twice
  54526. */
  54527. detectPointerOnOpaqueOnly: boolean;
  54528. /**
  54529. * Gets or sets the left value for slicing (9-patch)
  54530. */
  54531. sliceLeft: number;
  54532. /**
  54533. * Gets or sets the right value for slicing (9-patch)
  54534. */
  54535. sliceRight: number;
  54536. /**
  54537. * Gets or sets the top value for slicing (9-patch)
  54538. */
  54539. sliceTop: number;
  54540. /**
  54541. * Gets or sets the bottom value for slicing (9-patch)
  54542. */
  54543. sliceBottom: number;
  54544. /**
  54545. * Gets or sets the left coordinate in the source image
  54546. */
  54547. sourceLeft: number;
  54548. /**
  54549. * Gets or sets the top coordinate in the source image
  54550. */
  54551. sourceTop: number;
  54552. /**
  54553. * Gets or sets the width to capture in the source image
  54554. */
  54555. sourceWidth: number;
  54556. /**
  54557. * Gets or sets the height to capture in the source image
  54558. */
  54559. sourceHeight: number;
  54560. /**
  54561. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  54562. * @see http://doc.babylonjs.com/how_to/gui#image
  54563. */
  54564. autoScale: boolean;
  54565. /** Gets or sets the streching mode used by the image */
  54566. stretch: number;
  54567. /**
  54568. * Gets or sets the internal DOM image used to render the control
  54569. */
  54570. domImage: HTMLImageElement;
  54571. private _onImageLoaded;
  54572. private _extractNinePatchSliceDataFromImage;
  54573. /**
  54574. * Gets or sets image source url
  54575. */
  54576. source: BABYLON.Nullable<string>;
  54577. /**
  54578. * Gets or sets the cell width to use when animation sheet is enabled
  54579. * @see http://doc.babylonjs.com/how_to/gui#image
  54580. */
  54581. cellWidth: number;
  54582. /**
  54583. * Gets or sets the cell height to use when animation sheet is enabled
  54584. * @see http://doc.babylonjs.com/how_to/gui#image
  54585. */
  54586. cellHeight: number;
  54587. /**
  54588. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  54589. * @see http://doc.babylonjs.com/how_to/gui#image
  54590. */
  54591. cellId: number;
  54592. /**
  54593. * Creates a new Image
  54594. * @param name defines the control name
  54595. * @param url defines the image url
  54596. */
  54597. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  54598. /**
  54599. * Tests if a given coordinates belong to the current control
  54600. * @param x defines x coordinate to test
  54601. * @param y defines y coordinate to test
  54602. * @returns true if the coordinates are inside the control
  54603. */
  54604. contains(x: number, y: number): boolean;
  54605. protected _getTypeName(): string;
  54606. /** Force the control to synchronize with its content */
  54607. synchronizeSizeWithContent(): void;
  54608. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54609. private _prepareWorkingCanvasForOpaqueDetection;
  54610. private _drawImage; draw(context: CanvasRenderingContext2D): void;
  54611. private _renderCornerPatch;
  54612. private _renderNinePatch;
  54613. dispose(): void;
  54614. /** STRETCH_NONE */
  54615. static readonly STRETCH_NONE: number;
  54616. /** STRETCH_FILL */
  54617. static readonly STRETCH_FILL: number;
  54618. /** STRETCH_UNIFORM */
  54619. static readonly STRETCH_UNIFORM: number;
  54620. /** STRETCH_EXTEND */
  54621. static readonly STRETCH_EXTEND: number;
  54622. /** NINE_PATCH */
  54623. static readonly STRETCH_NINE_PATCH: number;
  54624. }
  54625. }
  54626. declare module BABYLON.GUI {
  54627. /**
  54628. * Class used to create 2D buttons
  54629. */
  54630. export class Button extends Rectangle {
  54631. name?: string | undefined;
  54632. /**
  54633. * Function called to generate a pointer enter animation
  54634. */
  54635. pointerEnterAnimation: () => void;
  54636. /**
  54637. * Function called to generate a pointer out animation
  54638. */
  54639. pointerOutAnimation: () => void;
  54640. /**
  54641. * Function called to generate a pointer down animation
  54642. */
  54643. pointerDownAnimation: () => void;
  54644. /**
  54645. * Function called to generate a pointer up animation
  54646. */
  54647. pointerUpAnimation: () => void;
  54648. private _image;
  54649. /**
  54650. * Returns the image part of the button (if any)
  54651. */
  54652. readonly image: BABYLON.Nullable<Image>;
  54653. private _textBlock;
  54654. /**
  54655. * Returns the image part of the button (if any)
  54656. */
  54657. readonly textBlock: BABYLON.Nullable<TextBlock>;
  54658. /**
  54659. * Creates a new Button
  54660. * @param name defines the name of the button
  54661. */
  54662. constructor(name?: string | undefined);
  54663. protected _getTypeName(): string;
  54664. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  54665. /** @hidden */ onPointerEnter(target: Control): boolean;
  54666. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  54667. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  54668. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  54669. /**
  54670. * Creates a new button made with an image and a text
  54671. * @param name defines the name of the button
  54672. * @param text defines the text of the button
  54673. * @param imageUrl defines the url of the image
  54674. * @returns a new Button
  54675. */
  54676. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  54677. /**
  54678. * Creates a new button made with an image
  54679. * @param name defines the name of the button
  54680. * @param imageUrl defines the url of the image
  54681. * @returns a new Button
  54682. */
  54683. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  54684. /**
  54685. * Creates a new button made with a text
  54686. * @param name defines the name of the button
  54687. * @param text defines the text of the button
  54688. * @returns a new Button
  54689. */
  54690. static CreateSimpleButton(name: string, text: string): Button;
  54691. /**
  54692. * Creates a new button made with an image and a centered text
  54693. * @param name defines the name of the button
  54694. * @param text defines the text of the button
  54695. * @param imageUrl defines the url of the image
  54696. * @returns a new Button
  54697. */
  54698. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  54699. }
  54700. }
  54701. declare module BABYLON.GUI {
  54702. /**
  54703. * Class used to create a 2D stack panel container
  54704. */
  54705. export class StackPanel extends Container {
  54706. name?: string | undefined;
  54707. private _isVertical;
  54708. private _manualWidth;
  54709. private _manualHeight;
  54710. private _doNotTrackManualChanges;
  54711. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  54712. isVertical: boolean;
  54713. /**
  54714. * Gets or sets panel width.
  54715. * This value should not be set when in horizontal mode as it will be computed automatically
  54716. */
  54717. width: string | number;
  54718. /**
  54719. * Gets or sets panel height.
  54720. * This value should not be set when in vertical mode as it will be computed automatically
  54721. */
  54722. height: string | number;
  54723. /**
  54724. * Creates a new StackPanel
  54725. * @param name defines control name
  54726. */
  54727. constructor(name?: string | undefined);
  54728. protected _getTypeName(): string;
  54729. /** @hidden */
  54730. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54731. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54732. protected _postMeasure(): void;
  54733. }
  54734. }
  54735. declare module BABYLON.GUI {
  54736. /**
  54737. * Class used to represent a 2D checkbox
  54738. */
  54739. export class Checkbox extends Control {
  54740. name?: string | undefined;
  54741. private _isChecked;
  54742. private _background;
  54743. private _checkSizeRatio;
  54744. private _thickness;
  54745. /** Gets or sets border thickness */
  54746. thickness: number;
  54747. /**
  54748. * BABYLON.Observable raised when isChecked property changes
  54749. */
  54750. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  54751. /** Gets or sets a value indicating the ratio between overall size and check size */
  54752. checkSizeRatio: number;
  54753. /** Gets or sets background color */
  54754. background: string;
  54755. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  54756. isChecked: boolean;
  54757. /**
  54758. * Creates a new CheckBox
  54759. * @param name defines the control name
  54760. */
  54761. constructor(name?: string | undefined);
  54762. protected _getTypeName(): string;
  54763. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  54764. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  54765. /**
  54766. * Utility function to easily create a checkbox with a header
  54767. * @param title defines the label to use for the header
  54768. * @param onValueChanged defines the callback to call when value changes
  54769. * @returns a StackPanel containing the checkbox and a textBlock
  54770. */
  54771. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  54772. }
  54773. }
  54774. declare module BABYLON.GUI {
  54775. /**
  54776. * Class used to store key control properties
  54777. */
  54778. export class KeyPropertySet {
  54779. /** Width */
  54780. width?: string;
  54781. /** Height */
  54782. height?: string;
  54783. /** Left padding */
  54784. paddingLeft?: string;
  54785. /** Right padding */
  54786. paddingRight?: string;
  54787. /** Top padding */
  54788. paddingTop?: string;
  54789. /** Bottom padding */
  54790. paddingBottom?: string;
  54791. /** Foreground color */
  54792. color?: string;
  54793. /** Background color */
  54794. background?: string;
  54795. }
  54796. /**
  54797. * Class used to create virtual keyboard
  54798. */
  54799. export class VirtualKeyboard extends StackPanel {
  54800. /** BABYLON.Observable raised when a key is pressed */
  54801. onKeyPressObservable: BABYLON.Observable<string>;
  54802. /** Gets or sets default key button width */
  54803. defaultButtonWidth: string;
  54804. /** Gets or sets default key button height */
  54805. defaultButtonHeight: string;
  54806. /** Gets or sets default key button left padding */
  54807. defaultButtonPaddingLeft: string;
  54808. /** Gets or sets default key button right padding */
  54809. defaultButtonPaddingRight: string;
  54810. /** Gets or sets default key button top padding */
  54811. defaultButtonPaddingTop: string;
  54812. /** Gets or sets default key button bottom padding */
  54813. defaultButtonPaddingBottom: string;
  54814. /** Gets or sets default key button foreground color */
  54815. defaultButtonColor: string;
  54816. /** Gets or sets default key button background color */
  54817. defaultButtonBackground: string;
  54818. /** Gets or sets shift button foreground color */
  54819. shiftButtonColor: string;
  54820. /** Gets or sets shift button thickness*/
  54821. selectedShiftThickness: number;
  54822. /** Gets shift key state */
  54823. shiftState: number;
  54824. protected _getTypeName(): string;
  54825. private _createKey;
  54826. /**
  54827. * Adds a new row of keys
  54828. * @param keys defines the list of keys to add
  54829. * @param propertySets defines the associated property sets
  54830. */
  54831. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  54832. /**
  54833. * Set the shift key to a specific state
  54834. * @param shiftState defines the new shift state
  54835. */
  54836. applyShiftState(shiftState: number): void;
  54837. private _currentlyConnectedInputText;
  54838. private _connectedInputTexts;
  54839. private _onKeyPressObserver;
  54840. /** Gets the input text control currently attached to the keyboard */
  54841. readonly connectedInputText: BABYLON.Nullable<InputText>;
  54842. /**
  54843. * Connects the keyboard with an input text control
  54844. *
  54845. * @param input defines the target control
  54846. */
  54847. connect(input: InputText): void;
  54848. /**
  54849. * Disconnects the keyboard from connected InputText controls
  54850. *
  54851. * @param input optionally defines a target control, otherwise all are disconnected
  54852. */
  54853. disconnect(input?: InputText): void;
  54854. private _removeConnectedInputObservables;
  54855. /**
  54856. * Release all resources
  54857. */
  54858. dispose(): void;
  54859. /**
  54860. * Creates a new keyboard using a default layout
  54861. *
  54862. * @param name defines control name
  54863. * @returns a new VirtualKeyboard
  54864. */
  54865. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  54866. }
  54867. }
  54868. declare module BABYLON.GUI {
  54869. /**
  54870. * Class used to create input text control
  54871. */
  54872. export class InputText extends Control implements IFocusableControl {
  54873. name?: string | undefined;
  54874. private _text;
  54875. private _placeholderText;
  54876. private _background;
  54877. private _focusedBackground;
  54878. private _focusedColor;
  54879. private _placeholderColor;
  54880. private _thickness;
  54881. private _margin;
  54882. private _autoStretchWidth;
  54883. private _maxWidth;
  54884. private _isFocused;
  54885. private _blinkTimeout;
  54886. private _blinkIsEven;
  54887. private _cursorOffset;
  54888. private _scrollLeft;
  54889. private _textWidth;
  54890. private _clickedCoordinate;
  54891. private _deadKey;
  54892. private _addKey;
  54893. private _currentKey;
  54894. private _isTextHighlightOn;
  54895. private _textHighlightColor;
  54896. private _highligherOpacity;
  54897. private _highlightedText;
  54898. private _startHighlightIndex;
  54899. private _endHighlightIndex;
  54900. private _cursorIndex;
  54901. private _onFocusSelectAll;
  54902. private _isPointerDown;
  54903. private _onClipboardObserver;
  54904. private _onPointerDblTapObserver;
  54905. /** @hidden */ connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  54906. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  54907. promptMessage: string;
  54908. /** BABYLON.Observable raised when the text changes */
  54909. onTextChangedObservable: BABYLON.Observable<InputText>;
  54910. /** BABYLON.Observable raised just before an entered character is to be added */
  54911. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  54912. /** BABYLON.Observable raised when the control gets the focus */
  54913. onFocusObservable: BABYLON.Observable<InputText>;
  54914. /** BABYLON.Observable raised when the control loses the focus */
  54915. onBlurObservable: BABYLON.Observable<InputText>;
  54916. /**Observable raised when the text is highlighted */
  54917. onTextHighlightObservable: BABYLON.Observable<InputText>;
  54918. /**Observable raised when copy event is triggered */
  54919. onTextCopyObservable: BABYLON.Observable<InputText>;
  54920. /** BABYLON.Observable raised when cut event is triggered */
  54921. onTextCutObservable: BABYLON.Observable<InputText>;
  54922. /** BABYLON.Observable raised when paste event is triggered */
  54923. onTextPasteObservable: BABYLON.Observable<InputText>;
  54924. /** BABYLON.Observable raised when a key event was processed */
  54925. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  54926. /** Gets or sets the maximum width allowed by the control */
  54927. maxWidth: string | number;
  54928. /** Gets the maximum width allowed by the control in pixels */
  54929. readonly maxWidthInPixels: number;
  54930. /** Gets or sets the text highlighter transparency; default: 0.4 */
  54931. highligherOpacity: number;
  54932. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  54933. onFocusSelectAll: boolean;
  54934. /** Gets or sets the text hightlight color */
  54935. textHighlightColor: string;
  54936. /** Gets or sets control margin */
  54937. margin: string;
  54938. /** Gets control margin in pixels */
  54939. readonly marginInPixels: number;
  54940. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  54941. autoStretchWidth: boolean;
  54942. /** Gets or sets border thickness */
  54943. thickness: number;
  54944. /** Gets or sets the background color when focused */
  54945. focusedBackground: string;
  54946. /** Gets or sets the background color when focused */
  54947. focusedColor: string;
  54948. /** Gets or sets the background color */
  54949. background: string;
  54950. /** Gets or sets the placeholder color */
  54951. placeholderColor: string;
  54952. /** Gets or sets the text displayed when the control is empty */
  54953. placeholderText: string;
  54954. /** Gets or sets the dead key flag */
  54955. deadKey: boolean;
  54956. /** Gets or sets the highlight text */
  54957. highlightedText: string;
  54958. /** Gets or sets if the current key should be added */
  54959. addKey: boolean;
  54960. /** Gets or sets the value of the current key being entered */
  54961. currentKey: string;
  54962. /** Gets or sets the text displayed in the control */
  54963. text: string;
  54964. /** Gets or sets control width */
  54965. width: string | number;
  54966. /**
  54967. * Creates a new InputText
  54968. * @param name defines the control name
  54969. * @param text defines the text of the control
  54970. */
  54971. constructor(name?: string | undefined, text?: string);
  54972. /** @hidden */
  54973. onBlur(): void;
  54974. /** @hidden */
  54975. onFocus(): void;
  54976. protected _getTypeName(): string;
  54977. /**
  54978. * Function called to get the list of controls that should not steal the focus from this control
  54979. * @returns an array of controls
  54980. */
  54981. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  54982. /** @hidden */
  54983. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  54984. /** @hidden */
  54985. private _updateValueFromCursorIndex;
  54986. /** @hidden */
  54987. private _processDblClick;
  54988. /** @hidden */
  54989. private _selectAllText;
  54990. /**
  54991. * Handles the keyboard event
  54992. * @param evt Defines the KeyboardEvent
  54993. */
  54994. processKeyboard(evt: KeyboardEvent): void;
  54995. /** @hidden */
  54996. private _onCopyText;
  54997. /** @hidden */
  54998. private _onCutText;
  54999. /** @hidden */
  55000. 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;
  55001. protected _beforeRenderText(text: string): string;
  55002. dispose(): void;
  55003. }
  55004. }
  55005. declare module BABYLON.GUI {
  55006. /**
  55007. * Class used to create a 2D grid container
  55008. */
  55009. export class Grid extends Container {
  55010. name?: string | undefined;
  55011. private _rowDefinitions;
  55012. private _columnDefinitions;
  55013. private _cells;
  55014. private _childControls;
  55015. /**
  55016. * Gets the number of columns
  55017. */
  55018. readonly columnCount: number;
  55019. /**
  55020. * Gets the number of rows
  55021. */
  55022. readonly rowCount: number;
  55023. /** Gets the list of children */
  55024. readonly children: Control[];
  55025. /**
  55026. * Gets the definition of a specific row
  55027. * @param index defines the index of the row
  55028. * @returns the row definition
  55029. */
  55030. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  55031. /**
  55032. * Gets the definition of a specific column
  55033. * @param index defines the index of the column
  55034. * @returns the column definition
  55035. */
  55036. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  55037. /**
  55038. * Adds a new row to the grid
  55039. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  55040. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  55041. * @returns the current grid
  55042. */
  55043. addRowDefinition(height: number, isPixel?: boolean): Grid;
  55044. /**
  55045. * Adds a new column to the grid
  55046. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  55047. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  55048. * @returns the current grid
  55049. */
  55050. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  55051. /**
  55052. * Update a row definition
  55053. * @param index defines the index of the row to update
  55054. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  55055. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  55056. * @returns the current grid
  55057. */
  55058. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  55059. /**
  55060. * Update a column definition
  55061. * @param index defines the index of the column to update
  55062. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  55063. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  55064. * @returns the current grid
  55065. */
  55066. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  55067. /**
  55068. * Gets the list of children stored in a specific cell
  55069. * @param row defines the row to check
  55070. * @param column defines the column to check
  55071. * @returns the list of controls
  55072. */
  55073. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  55074. /**
  55075. * Gets a string representing the child cell info (row x column)
  55076. * @param child defines the control to get info from
  55077. * @returns a string containing the child cell info (row x column)
  55078. */
  55079. getChildCellInfo(child: Control): string;
  55080. private _removeCell;
  55081. private _offsetCell;
  55082. /**
  55083. * Remove a column definition at specified index
  55084. * @param index defines the index of the column to remove
  55085. * @returns the current grid
  55086. */
  55087. removeColumnDefinition(index: number): Grid;
  55088. /**
  55089. * Remove a row definition at specified index
  55090. * @param index defines the index of the row to remove
  55091. * @returns the current grid
  55092. */
  55093. removeRowDefinition(index: number): Grid;
  55094. /**
  55095. * Adds a new control to the current grid
  55096. * @param control defines the control to add
  55097. * @param row defines the row where to add the control (0 by default)
  55098. * @param column defines the column where to add the control (0 by default)
  55099. * @returns the current grid
  55100. */
  55101. addControl(control: Control, row?: number, column?: number): Grid;
  55102. /**
  55103. * Removes a control from the current container
  55104. * @param control defines the control to remove
  55105. * @returns the current container
  55106. */
  55107. removeControl(control: Control): Container;
  55108. /**
  55109. * Creates a new Grid
  55110. * @param name defines control name
  55111. */
  55112. constructor(name?: string | undefined);
  55113. protected _getTypeName(): string;
  55114. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  55115. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; flagDescendantsAsMatrixDirty(): void; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  55116. /** Releases associated resources */
  55117. dispose(): void;
  55118. }
  55119. }
  55120. declare module BABYLON.GUI {
  55121. /** Class used to create color pickers */
  55122. export class ColorPicker extends Control {
  55123. name?: string | undefined;
  55124. private static _Epsilon;
  55125. private _colorWheelCanvas;
  55126. private _value;
  55127. private _tmpColor;
  55128. private _pointerStartedOnSquare;
  55129. private _pointerStartedOnWheel;
  55130. private _squareLeft;
  55131. private _squareTop;
  55132. private _squareSize;
  55133. private _h;
  55134. private _s;
  55135. private _v;
  55136. /**
  55137. * BABYLON.Observable raised when the value changes
  55138. */
  55139. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  55140. /** Gets or sets the color of the color picker */
  55141. value: BABYLON.Color3;
  55142. /**
  55143. * Gets or sets control width
  55144. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  55145. */
  55146. width: string | number;
  55147. /**
  55148. * Gets or sets control height
  55149. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  55150. */
  55151. /** Gets or sets control height */
  55152. height: string | number;
  55153. /** Gets or sets control size */
  55154. size: string | number;
  55155. /**
  55156. * Creates a new ColorPicker
  55157. * @param name defines the control name
  55158. */
  55159. constructor(name?: string | undefined);
  55160. protected _getTypeName(): string;
  55161. /** @hidden */
  55162. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55163. private _updateSquareProps;
  55164. private _drawGradientSquare;
  55165. private _drawCircle;
  55166. private _createColorWheelCanvas;
  55167. private _RGBtoHSV;
  55168. private _HSVtoRGB;
  55169. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  55170. private _pointerIsDown;
  55171. private _updateValueFromPointer;
  55172. private _isPointOnSquare;
  55173. 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;
  55174. /**
  55175. * This function expands the color picker by creating a color picker dialog with manual
  55176. * color value input and the ability to save colors into an array to be used later in
  55177. * subsequent launches of the dialogue.
  55178. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  55179. * @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.
  55180. * @returns picked color as a hex string and the saved colors array as hex strings.
  55181. */
  55182. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  55183. pickerWidth?: string;
  55184. pickerHeight?: string;
  55185. headerHeight?: string;
  55186. lastColor?: string;
  55187. swatchLimit?: number;
  55188. numSwatchesPerLine?: number;
  55189. savedColors?: Array<string>;
  55190. }): Promise<{
  55191. savedColors?: string[];
  55192. pickedColor: string;
  55193. }>;
  55194. }
  55195. }
  55196. declare module BABYLON.GUI {
  55197. /** Class used to create 2D ellipse containers */
  55198. export class Ellipse extends Container {
  55199. name?: string | undefined;
  55200. private _thickness;
  55201. /** Gets or sets border thickness */
  55202. thickness: number;
  55203. /**
  55204. * Creates a new Ellipse
  55205. * @param name defines the control name
  55206. */
  55207. constructor(name?: string | undefined);
  55208. protected _getTypeName(): string;
  55209. protected _localDraw(context: CanvasRenderingContext2D): void;
  55210. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55211. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  55212. }
  55213. }
  55214. declare module BABYLON.GUI {
  55215. /**
  55216. * Class used to create a password control
  55217. */
  55218. export class InputPassword extends InputText {
  55219. protected _beforeRenderText(text: string): string;
  55220. }
  55221. }
  55222. declare module BABYLON.GUI {
  55223. /** Class used to render 2D lines */
  55224. export class Line extends Control {
  55225. name?: string | undefined;
  55226. private _lineWidth;
  55227. private _x1;
  55228. private _y1;
  55229. private _x2;
  55230. private _y2;
  55231. private _dash;
  55232. private _connectedControl;
  55233. private _connectedControlDirtyObserver;
  55234. /** Gets or sets the dash pattern */
  55235. dash: Array<number>;
  55236. /** Gets or sets the control connected with the line end */
  55237. connectedControl: Control;
  55238. /** Gets or sets start coordinates on X axis */
  55239. x1: string | number;
  55240. /** Gets or sets start coordinates on Y axis */
  55241. y1: string | number;
  55242. /** Gets or sets end coordinates on X axis */
  55243. x2: string | number;
  55244. /** Gets or sets end coordinates on Y axis */
  55245. y2: string | number;
  55246. /** Gets or sets line width */
  55247. lineWidth: number;
  55248. /** Gets or sets horizontal alignment */
  55249. horizontalAlignment: number;
  55250. /** Gets or sets vertical alignment */
  55251. verticalAlignment: number;
  55252. private readonly _effectiveX2;
  55253. private readonly _effectiveY2;
  55254. /**
  55255. * Creates a new Line
  55256. * @param name defines the control name
  55257. */
  55258. constructor(name?: string | undefined);
  55259. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; measure(): void;
  55260. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55261. /**
  55262. * Move one end of the line given 3D cartesian coordinates.
  55263. * @param position Targeted world position
  55264. * @param scene BABYLON.Scene
  55265. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  55266. */
  55267. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  55268. /**
  55269. * Move one end of the line to a position in screen absolute space.
  55270. * @param projectedPosition Position in screen absolute space (X, Y)
  55271. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  55272. */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  55273. }
  55274. }
  55275. declare module BABYLON.GUI {
  55276. /**
  55277. * Class used to store a point for a MultiLine object.
  55278. * The point can be pure 2D coordinates, a mesh or a control
  55279. */
  55280. export class MultiLinePoint {
  55281. private _multiLine;
  55282. private _x;
  55283. private _y;
  55284. private _control;
  55285. private _mesh;
  55286. private _controlObserver;
  55287. private _meshObserver;
  55288. /** @hidden */ point: BABYLON.Vector2;
  55289. /**
  55290. * Creates a new MultiLinePoint
  55291. * @param multiLine defines the source MultiLine object
  55292. */
  55293. constructor(multiLine: MultiLine);
  55294. /** Gets or sets x coordinate */
  55295. x: string | number;
  55296. /** Gets or sets y coordinate */
  55297. y: string | number;
  55298. /** Gets or sets the control associated with this point */
  55299. control: BABYLON.Nullable<Control>;
  55300. /** Gets or sets the mesh associated with this point */
  55301. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  55302. /** Resets links */
  55303. resetLinks(): void;
  55304. /**
  55305. * Gets a translation vector
  55306. * @returns the translation vector
  55307. */
  55308. translate(): BABYLON.Vector2;
  55309. private _translatePoint;
  55310. /** Release associated resources */
  55311. dispose(): void;
  55312. }
  55313. }
  55314. declare module BABYLON.GUI {
  55315. /**
  55316. * Class used to create multi line control
  55317. */
  55318. export class MultiLine extends Control {
  55319. name?: string | undefined;
  55320. private _lineWidth;
  55321. private _dash;
  55322. private _points;
  55323. private _minX;
  55324. private _minY;
  55325. private _maxX;
  55326. private _maxY;
  55327. /**
  55328. * Creates a new MultiLine
  55329. * @param name defines the control name
  55330. */
  55331. constructor(name?: string | undefined);
  55332. /** Gets or sets dash pattern */
  55333. dash: Array<number>;
  55334. /**
  55335. * Gets point stored at specified index
  55336. * @param index defines the index to look for
  55337. * @returns the requested point if found
  55338. */
  55339. getAt(index: number): MultiLinePoint;
  55340. /** Function called when a point is updated */
  55341. onPointUpdate: () => void;
  55342. /**
  55343. * Adds new points to the point collection
  55344. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  55345. * @returns the list of created MultiLinePoint
  55346. */
  55347. add(...items: (AbstractMesh | Control | {
  55348. x: string | number;
  55349. y: string | number;
  55350. })[]): MultiLinePoint[];
  55351. /**
  55352. * Adds a new point to the point collection
  55353. * @param item defines the item (mesh, control or 2d coordiantes) to add
  55354. * @returns the created MultiLinePoint
  55355. */
  55356. push(item?: (AbstractMesh | Control | {
  55357. x: string | number;
  55358. y: string | number;
  55359. })): MultiLinePoint;
  55360. /**
  55361. * Remove a specific value or point from the active point collection
  55362. * @param value defines the value or point to remove
  55363. */
  55364. remove(value: number | MultiLinePoint): void;
  55365. /**
  55366. * Resets this object to initial state (no point)
  55367. */
  55368. reset(): void;
  55369. /**
  55370. * Resets all links
  55371. */
  55372. resetLinks(): void;
  55373. /** Gets or sets line width */
  55374. lineWidth: number;
  55375. horizontalAlignment: number;
  55376. verticalAlignment: number;
  55377. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  55378. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; measure(): void;
  55379. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55380. dispose(): void;
  55381. }
  55382. }
  55383. declare module BABYLON.GUI {
  55384. /**
  55385. * Class used to create radio button controls
  55386. */
  55387. export class RadioButton extends Control {
  55388. name?: string | undefined;
  55389. private _isChecked;
  55390. private _background;
  55391. private _checkSizeRatio;
  55392. private _thickness;
  55393. /** Gets or sets border thickness */
  55394. thickness: number;
  55395. /** Gets or sets group name */
  55396. group: string;
  55397. /** BABYLON.Observable raised when isChecked is changed */
  55398. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  55399. /** Gets or sets a value indicating the ratio between overall size and check size */
  55400. checkSizeRatio: number;
  55401. /** Gets or sets background color */
  55402. background: string;
  55403. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  55404. isChecked: boolean;
  55405. /**
  55406. * Creates a new RadioButton
  55407. * @param name defines the control name
  55408. */
  55409. constructor(name?: string | undefined);
  55410. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  55411. /**
  55412. * Utility function to easily create a radio button with a header
  55413. * @param title defines the label to use for the header
  55414. * @param group defines the group to use for the radio button
  55415. * @param isChecked defines the initial state of the radio button
  55416. * @param onValueChanged defines the callback to call when value changes
  55417. * @returns a StackPanel containing the radio button and a textBlock
  55418. */
  55419. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  55420. }
  55421. }
  55422. declare module BABYLON.GUI {
  55423. /**
  55424. * Class used to create slider controls
  55425. */
  55426. export class BaseSlider extends Control {
  55427. name?: string | undefined;
  55428. protected _thumbWidth: ValueAndUnit;
  55429. private _minimum;
  55430. private _maximum;
  55431. private _value;
  55432. private _isVertical;
  55433. protected _barOffset: ValueAndUnit;
  55434. private _isThumbClamped;
  55435. protected _displayThumb: boolean;
  55436. private _step;
  55437. protected _effectiveBarOffset: number;
  55438. protected _renderLeft: number;
  55439. protected _renderTop: number;
  55440. protected _renderWidth: number;
  55441. protected _renderHeight: number;
  55442. protected _backgroundBoxLength: number;
  55443. protected _backgroundBoxThickness: number;
  55444. protected _effectiveThumbThickness: number;
  55445. /** BABYLON.Observable raised when the sldier value changes */
  55446. onValueChangedObservable: BABYLON.Observable<number>;
  55447. /** Gets or sets a boolean indicating if the thumb must be rendered */
  55448. displayThumb: boolean;
  55449. /** Gets or sets a step to apply to values (0 by default) */
  55450. step: number;
  55451. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  55452. barOffset: string | number;
  55453. /** Gets main bar offset in pixels*/
  55454. readonly barOffsetInPixels: number;
  55455. /** Gets or sets thumb width */
  55456. thumbWidth: string | number;
  55457. /** Gets thumb width in pixels */
  55458. readonly thumbWidthInPixels: number;
  55459. /** Gets or sets minimum value */
  55460. minimum: number;
  55461. /** Gets or sets maximum value */
  55462. maximum: number;
  55463. /** Gets or sets current value */
  55464. value: number;
  55465. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  55466. isVertical: boolean;
  55467. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  55468. isThumbClamped: boolean;
  55469. /**
  55470. * Creates a new BaseSlider
  55471. * @param name defines the control name
  55472. */
  55473. constructor(name?: string | undefined);
  55474. protected _getTypeName(): string;
  55475. protected _getThumbPosition(): number;
  55476. protected _getThumbThickness(type: string): number;
  55477. protected _prepareRenderingData(type: string): void;
  55478. private _pointerIsDown;
  55479. /** @hidden */
  55480. 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;
  55481. }
  55482. }
  55483. declare module BABYLON.GUI {
  55484. /**
  55485. * Class used to create slider controls
  55486. */
  55487. export class Slider extends BaseSlider {
  55488. name?: string | undefined;
  55489. private _background;
  55490. private _borderColor;
  55491. private _isThumbCircle;
  55492. protected _displayValueBar: boolean;
  55493. /** Gets or sets a boolean indicating if the value bar must be rendered */
  55494. displayValueBar: boolean;
  55495. /** Gets or sets border color */
  55496. borderColor: string;
  55497. /** Gets or sets background color */
  55498. background: string;
  55499. /** Gets or sets a boolean indicating if the thumb should be round or square */
  55500. isThumbCircle: boolean;
  55501. /**
  55502. * Creates a new Slider
  55503. * @param name defines the control name
  55504. */
  55505. constructor(name?: string | undefined);
  55506. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  55507. }
  55508. }
  55509. declare module BABYLON.GUI {
  55510. /** Class used to create a RadioGroup
  55511. * which contains groups of radio buttons
  55512. */
  55513. export class SelectorGroup {
  55514. /** name of SelectorGroup */
  55515. name: string;
  55516. private _groupPanel;
  55517. private _selectors;
  55518. private _groupHeader;
  55519. /**
  55520. * Creates a new SelectorGroup
  55521. * @param name of group, used as a group heading
  55522. */
  55523. constructor(
  55524. /** name of SelectorGroup */
  55525. name: string);
  55526. /** Gets the groupPanel of the SelectorGroup */
  55527. readonly groupPanel: StackPanel;
  55528. /** Gets the selectors array */
  55529. readonly selectors: StackPanel[];
  55530. /** Gets and sets the group header */
  55531. header: string;
  55532. /** @hidden */
  55533. private _addGroupHeader;
  55534. /** @hidden*/ getSelector(selectorNb: number): StackPanel | undefined;
  55535. /** Removes the selector at the given position
  55536. * @param selectorNb the position of the selector within the group
  55537. */
  55538. removeSelector(selectorNb: number): void;
  55539. }
  55540. /** Class used to create a CheckboxGroup
  55541. * which contains groups of checkbox buttons
  55542. */
  55543. export class CheckboxGroup extends SelectorGroup {
  55544. /** Adds a checkbox as a control
  55545. * @param text is the label for the selector
  55546. * @param func is the function called when the Selector is checked
  55547. * @param checked is true when Selector is checked
  55548. */
  55549. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  55550. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  55551. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  55552. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  55553. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  55554. }
  55555. /** Class used to create a RadioGroup
  55556. * which contains groups of radio buttons
  55557. */
  55558. export class RadioGroup extends SelectorGroup {
  55559. private _selectNb;
  55560. /** Adds a radio button as a control
  55561. * @param label is the label for the selector
  55562. * @param func is the function called when the Selector is checked
  55563. * @param checked is true when Selector is checked
  55564. */
  55565. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  55566. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  55567. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  55568. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  55569. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  55570. }
  55571. /** Class used to create a SliderGroup
  55572. * which contains groups of slider buttons
  55573. */
  55574. export class SliderGroup extends SelectorGroup {
  55575. /**
  55576. * Adds a slider to the SelectorGroup
  55577. * @param label is the label for the SliderBar
  55578. * @param func is the function called when the Slider moves
  55579. * @param unit is a string describing the units used, eg degrees or metres
  55580. * @param min is the minimum value for the Slider
  55581. * @param max is the maximum value for the Slider
  55582. * @param value is the start value for the Slider between min and max
  55583. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  55584. */
  55585. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  55586. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  55587. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  55588. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  55589. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  55590. }
  55591. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  55592. * @see http://doc.babylonjs.com/how_to/selector
  55593. */
  55594. export class SelectionPanel extends Rectangle {
  55595. /** name of SelectionPanel */
  55596. name: string;
  55597. /** an array of SelectionGroups */
  55598. groups: SelectorGroup[];
  55599. private _panel;
  55600. private _buttonColor;
  55601. private _buttonBackground;
  55602. private _headerColor;
  55603. private _barColor;
  55604. private _barHeight;
  55605. private _spacerHeight;
  55606. private _labelColor;
  55607. private _groups;
  55608. private _bars;
  55609. /**
  55610. * Creates a new SelectionPanel
  55611. * @param name of SelectionPanel
  55612. * @param groups is an array of SelectionGroups
  55613. */
  55614. constructor(
  55615. /** name of SelectionPanel */
  55616. name: string,
  55617. /** an array of SelectionGroups */
  55618. groups?: SelectorGroup[]);
  55619. protected _getTypeName(): string;
  55620. /** Gets or sets the headerColor */
  55621. headerColor: string;
  55622. private _setHeaderColor;
  55623. /** Gets or sets the button color */
  55624. buttonColor: string;
  55625. private _setbuttonColor;
  55626. /** Gets or sets the label color */
  55627. labelColor: string;
  55628. private _setLabelColor;
  55629. /** Gets or sets the button background */
  55630. buttonBackground: string;
  55631. private _setButtonBackground;
  55632. /** Gets or sets the color of separator bar */
  55633. barColor: string;
  55634. private _setBarColor;
  55635. /** Gets or sets the height of separator bar */
  55636. barHeight: string;
  55637. private _setBarHeight;
  55638. /** Gets or sets the height of spacers*/
  55639. spacerHeight: string;
  55640. private _setSpacerHeight;
  55641. /** Adds a bar between groups */
  55642. private _addSpacer;
  55643. /** Add a group to the selection panel
  55644. * @param group is the selector group to add
  55645. */
  55646. addGroup(group: SelectorGroup): void;
  55647. /** Remove the group from the given position
  55648. * @param groupNb is the position of the group in the list
  55649. */
  55650. removeGroup(groupNb: number): void;
  55651. /** Change a group header label
  55652. * @param label is the new group header label
  55653. * @param groupNb is the number of the group to relabel
  55654. * */
  55655. setHeaderName(label: string, groupNb: number): void;
  55656. /** Change selector label to the one given
  55657. * @param label is the new selector label
  55658. * @param groupNb is the number of the groupcontaining the selector
  55659. * @param selectorNb is the number of the selector within a group to relabel
  55660. * */
  55661. relabel(label: string, groupNb: number, selectorNb: number): void;
  55662. /** For a given group position remove the selector at the given position
  55663. * @param groupNb is the number of the group to remove the selector from
  55664. * @param selectorNb is the number of the selector within the group
  55665. */
  55666. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  55667. /** For a given group position of correct type add a checkbox button
  55668. * @param groupNb is the number of the group to remove the selector from
  55669. * @param label is the label for the selector
  55670. * @param func is the function called when the Selector is checked
  55671. * @param checked is true when Selector is checked
  55672. */
  55673. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  55674. /** For a given group position of correct type add a radio button
  55675. * @param groupNb is the number of the group to remove the selector from
  55676. * @param label is the label for the selector
  55677. * @param func is the function called when the Selector is checked
  55678. * @param checked is true when Selector is checked
  55679. */
  55680. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  55681. /**
  55682. * For a given slider group add a slider
  55683. * @param groupNb is the number of the group to add the slider to
  55684. * @param label is the label for the Slider
  55685. * @param func is the function called when the Slider moves
  55686. * @param unit is a string describing the units used, eg degrees or metres
  55687. * @param min is the minimum value for the Slider
  55688. * @param max is the maximum value for the Slider
  55689. * @param value is the start value for the Slider between min and max
  55690. * @param onVal is the function used to format the value displayed, eg radians to degrees
  55691. */
  55692. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  55693. }
  55694. }
  55695. declare module BABYLON.GUI {
  55696. /**
  55697. * Class used to hold a the container for ScrollViewer
  55698. * @hidden
  55699. */
  55700. export class _ScrollViewerWindow extends Container {
  55701. parentClientWidth: number;
  55702. parentClientHeight: number;
  55703. /**
  55704. * Creates a new ScrollViewerWindow
  55705. * @param name of ScrollViewerWindow
  55706. */
  55707. constructor(name?: string);
  55708. protected _getTypeName(): string;
  55709. /** @hidden */
  55710. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55711. protected _postMeasure(): void;
  55712. }
  55713. }
  55714. declare module BABYLON.GUI {
  55715. /**
  55716. * Class used to create slider controls
  55717. */
  55718. export class ScrollBar extends BaseSlider {
  55719. name?: string | undefined;
  55720. private _background;
  55721. private _borderColor;
  55722. private _thumbMeasure;
  55723. /** Gets or sets border color */
  55724. borderColor: string;
  55725. /** Gets or sets background color */
  55726. background: string;
  55727. /**
  55728. * Creates a new Slider
  55729. * @param name defines the control name
  55730. */
  55731. constructor(name?: string | undefined);
  55732. protected _getTypeName(): string;
  55733. protected _getThumbThickness(): number; draw(context: CanvasRenderingContext2D): void;
  55734. private _first;
  55735. private _originX;
  55736. private _originY;
  55737. /** @hidden */
  55738. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  55739. }
  55740. }
  55741. declare module BABYLON.GUI {
  55742. /**
  55743. * Class used to hold a viewer window and sliders in a grid
  55744. */
  55745. export class ScrollViewer extends Rectangle {
  55746. private _grid;
  55747. private _horizontalBarSpace;
  55748. private _verticalBarSpace;
  55749. private _dragSpace;
  55750. private _horizontalBar;
  55751. private _verticalBar;
  55752. private _barColor;
  55753. private _barBackground;
  55754. private _barSize;
  55755. private _endLeft;
  55756. private _endTop;
  55757. private _window;
  55758. private _pointerIsOver;
  55759. private _wheelPrecision;
  55760. private _onPointerObserver;
  55761. private _clientWidth;
  55762. private _clientHeight;
  55763. /**
  55764. * Gets the horizontal scrollbar
  55765. */
  55766. readonly horizontalBar: ScrollBar;
  55767. /**
  55768. * Gets the vertical scrollbar
  55769. */
  55770. readonly verticalBar: ScrollBar;
  55771. /**
  55772. * Adds a new control to the current container
  55773. * @param control defines the control to add
  55774. * @returns the current container
  55775. */
  55776. addControl(control: BABYLON.Nullable<Control>): Container;
  55777. /**
  55778. * Removes a control from the current container
  55779. * @param control defines the control to remove
  55780. * @returns the current container
  55781. */
  55782. removeControl(control: Control): Container;
  55783. /** Gets the list of children */
  55784. readonly children: Control[]; flagDescendantsAsMatrixDirty(): void;
  55785. /**
  55786. * Creates a new ScrollViewer
  55787. * @param name of ScrollViewer
  55788. */
  55789. constructor(name?: string);
  55790. /** Reset the scroll viewer window to initial size */
  55791. resetWindow(): void;
  55792. protected _getTypeName(): string;
  55793. private _buildClientSizes;
  55794. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55795. protected _postMeasure(): void;
  55796. /**
  55797. * Gets or sets the mouse wheel precision
  55798. * from 0 to 1 with a default value of 0.05
  55799. * */
  55800. wheelPrecision: number;
  55801. /** Gets or sets the bar color */
  55802. barColor: string;
  55803. /** Gets or sets the size of the bar */
  55804. barSize: number;
  55805. /** Gets or sets the bar background */
  55806. barBackground: string;
  55807. /** @hidden */
  55808. private _updateScroller; link(host: AdvancedDynamicTexture): void;
  55809. /** @hidden */
  55810. private _attachWheel; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  55811. /** Releases associated resources */
  55812. dispose(): void;
  55813. }
  55814. }
  55815. declare module BABYLON.GUI {
  55816. /** Class used to render a grid */
  55817. export class DisplayGrid extends Control {
  55818. name?: string | undefined;
  55819. private _cellWidth;
  55820. private _cellHeight;
  55821. private _minorLineTickness;
  55822. private _minorLineColor;
  55823. private _majorLineTickness;
  55824. private _majorLineColor;
  55825. private _majorLineFrequency;
  55826. private _background;
  55827. private _displayMajorLines;
  55828. private _displayMinorLines;
  55829. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  55830. displayMinorLines: boolean;
  55831. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  55832. displayMajorLines: boolean;
  55833. /** Gets or sets background color (Black by default) */
  55834. background: string;
  55835. /** Gets or sets the width of each cell (20 by default) */
  55836. cellWidth: number;
  55837. /** Gets or sets the height of each cell (20 by default) */
  55838. cellHeight: number;
  55839. /** Gets or sets the tickness of minor lines (1 by default) */
  55840. minorLineTickness: number;
  55841. /** Gets or sets the color of minor lines (DarkGray by default) */
  55842. minorLineColor: string;
  55843. /** Gets or sets the tickness of major lines (2 by default) */
  55844. majorLineTickness: number;
  55845. /** Gets or sets the color of major lines (White by default) */
  55846. majorLineColor: string;
  55847. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  55848. majorLineFrequency: number;
  55849. /**
  55850. * Creates a new GridDisplayRectangle
  55851. * @param name defines the control name
  55852. */
  55853. constructor(name?: string | undefined); draw(context: CanvasRenderingContext2D): void;
  55854. protected _getTypeName(): string;
  55855. }
  55856. }
  55857. declare module BABYLON.GUI {
  55858. /**
  55859. * Class used to create slider controls based on images
  55860. */
  55861. export class ImageBasedSlider extends BaseSlider {
  55862. name?: string | undefined;
  55863. private _backgroundImage;
  55864. private _thumbImage;
  55865. private _valueBarImage;
  55866. private _tempMeasure;
  55867. displayThumb: boolean;
  55868. /**
  55869. * Gets or sets the image used to render the background
  55870. */
  55871. backgroundImage: Image;
  55872. /**
  55873. * Gets or sets the image used to render the value bar
  55874. */
  55875. valueBarImage: Image;
  55876. /**
  55877. * Gets or sets the image used to render the thumb
  55878. */
  55879. thumbImage: Image;
  55880. /**
  55881. * Creates a new ImageBasedSlider
  55882. * @param name defines the control name
  55883. */
  55884. constructor(name?: string | undefined);
  55885. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  55886. }
  55887. }
  55888. declare module BABYLON.GUI {
  55889. /**
  55890. * Forcing an export so that this code will execute
  55891. * @hidden
  55892. */
  55893. const name = "Statics";
  55894. }
  55895. declare module BABYLON.GUI {
  55896. /**
  55897. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  55898. */
  55899. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  55900. /**
  55901. * Define the instrumented AdvancedDynamicTexture.
  55902. */
  55903. texture: AdvancedDynamicTexture;
  55904. private _captureRenderTime;
  55905. private _renderTime;
  55906. private _captureLayoutTime;
  55907. private _layoutTime;
  55908. private _onBeginRenderObserver;
  55909. private _onEndRenderObserver;
  55910. private _onBeginLayoutObserver;
  55911. private _onEndLayoutObserver;
  55912. /**
  55913. * Gets the perf counter used to capture render time
  55914. */
  55915. readonly renderTimeCounter: BABYLON.PerfCounter;
  55916. /**
  55917. * Gets the perf counter used to capture layout time
  55918. */
  55919. readonly layoutTimeCounter: BABYLON.PerfCounter;
  55920. /**
  55921. * Enable or disable the render time capture
  55922. */
  55923. captureRenderTime: boolean;
  55924. /**
  55925. * Enable or disable the layout time capture
  55926. */
  55927. captureLayoutTime: boolean;
  55928. /**
  55929. * Instantiates a new advanced dynamic texture instrumentation.
  55930. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  55931. * @param texture Defines the AdvancedDynamicTexture to instrument
  55932. */
  55933. constructor(
  55934. /**
  55935. * Define the instrumented AdvancedDynamicTexture.
  55936. */
  55937. texture: AdvancedDynamicTexture);
  55938. /**
  55939. * Dispose and release associated resources.
  55940. */
  55941. dispose(): void;
  55942. }
  55943. }
  55944. declare module BABYLON.GUI {
  55945. /**
  55946. * Class used to create containers for controls
  55947. */
  55948. export class Container3D extends Control3D {
  55949. private _blockLayout;
  55950. /**
  55951. * Gets the list of child controls
  55952. */
  55953. protected _children: Control3D[];
  55954. /**
  55955. * Gets the list of child controls
  55956. */
  55957. readonly children: Array<Control3D>;
  55958. /**
  55959. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  55960. * This is helpful to optimize layout operation when adding multiple children in a row
  55961. */
  55962. blockLayout: boolean;
  55963. /**
  55964. * Creates a new container
  55965. * @param name defines the container name
  55966. */
  55967. constructor(name?: string);
  55968. /**
  55969. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  55970. * @returns the current container
  55971. */
  55972. updateLayout(): Container3D;
  55973. /**
  55974. * Gets a boolean indicating if the given control is in the children of this control
  55975. * @param control defines the control to check
  55976. * @returns true if the control is in the child list
  55977. */
  55978. containsControl(control: Control3D): boolean;
  55979. /**
  55980. * Adds a control to the children of this control
  55981. * @param control defines the control to add
  55982. * @returns the current container
  55983. */
  55984. addControl(control: Control3D): Container3D;
  55985. /**
  55986. * This function will be called everytime a new control is added
  55987. */
  55988. protected _arrangeChildren(): void;
  55989. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  55990. /**
  55991. * Removes a control from the children of this control
  55992. * @param control defines the control to remove
  55993. * @returns the current container
  55994. */
  55995. removeControl(control: Control3D): Container3D;
  55996. protected _getTypeName(): string;
  55997. /**
  55998. * Releases all associated resources
  55999. */
  56000. dispose(): void;
  56001. /** Control rotation will remain unchanged */
  56002. static readonly UNSET_ORIENTATION: number;
  56003. /** Control will rotate to make it look at sphere central axis */
  56004. static readonly FACEORIGIN_ORIENTATION: number;
  56005. /** Control will rotate to make it look back at sphere central axis */
  56006. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  56007. /** Control will rotate to look at z axis (0, 0, 1) */
  56008. static readonly FACEFORWARD_ORIENTATION: number;
  56009. /** Control will rotate to look at negative z axis (0, 0, -1) */
  56010. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  56011. }
  56012. }
  56013. declare module BABYLON.GUI {
  56014. /**
  56015. * Class used to manage 3D user interface
  56016. * @see http://doc.babylonjs.com/how_to/gui3d
  56017. */
  56018. export class GUI3DManager implements BABYLON.IDisposable {
  56019. private _scene;
  56020. private _sceneDisposeObserver;
  56021. private _utilityLayer;
  56022. private _rootContainer;
  56023. private _pointerObserver;
  56024. private _pointerOutObserver;
  56025. /** @hidden */ lastPickedControl: Control3D;
  56026. /** @hidden */ lastControlOver: {
  56027. [pointerId: number]: Control3D;
  56028. };
  56029. /** @hidden */ lastControlDown: {
  56030. [pointerId: number]: Control3D;
  56031. };
  56032. /**
  56033. * BABYLON.Observable raised when the point picked by the pointer events changed
  56034. */
  56035. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  56036. /** @hidden */ sharedMaterials: {
  56037. [key: string]: BABYLON.Material;
  56038. };
  56039. /** Gets the hosting scene */
  56040. readonly scene: BABYLON.Scene;
  56041. /** Gets associated utility layer */
  56042. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  56043. /**
  56044. * Creates a new GUI3DManager
  56045. * @param scene
  56046. */
  56047. constructor(scene?: BABYLON.Scene);
  56048. private _handlePointerOut;
  56049. private _doPicking;
  56050. /**
  56051. * Gets the root container
  56052. */
  56053. readonly rootContainer: Container3D;
  56054. /**
  56055. * Gets a boolean indicating if the given control is in the root child list
  56056. * @param control defines the control to check
  56057. * @returns true if the control is in the root child list
  56058. */
  56059. containsControl(control: Control3D): boolean;
  56060. /**
  56061. * Adds a control to the root child list
  56062. * @param control defines the control to add
  56063. * @returns the current manager
  56064. */
  56065. addControl(control: Control3D): GUI3DManager;
  56066. /**
  56067. * Removes a control from the root child list
  56068. * @param control defines the control to remove
  56069. * @returns the current container
  56070. */
  56071. removeControl(control: Control3D): GUI3DManager;
  56072. /**
  56073. * Releases all associated resources
  56074. */
  56075. dispose(): void;
  56076. }
  56077. }
  56078. declare module BABYLON.GUI {
  56079. /**
  56080. * Class used to transport BABYLON.Vector3 information for pointer events
  56081. */
  56082. export class Vector3WithInfo extends BABYLON.Vector3 {
  56083. /** defines the current mouse button index */
  56084. buttonIndex: number;
  56085. /**
  56086. * Creates a new Vector3WithInfo
  56087. * @param source defines the vector3 data to transport
  56088. * @param buttonIndex defines the current mouse button index
  56089. */
  56090. constructor(source: BABYLON.Vector3,
  56091. /** defines the current mouse button index */
  56092. buttonIndex?: number);
  56093. }
  56094. }
  56095. declare module BABYLON.GUI {
  56096. /**
  56097. * Class used as base class for controls
  56098. */
  56099. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  56100. /** Defines the control name */
  56101. name?: string | undefined;
  56102. /** @hidden */ host: GUI3DManager;
  56103. private _node;
  56104. private _downCount;
  56105. private _enterCount;
  56106. private _downPointerIds;
  56107. private _isVisible;
  56108. /** Gets or sets the control position in world space */
  56109. position: BABYLON.Vector3;
  56110. /** Gets or sets the control scaling in world space */
  56111. scaling: BABYLON.Vector3;
  56112. /** Callback used to start pointer enter animation */
  56113. pointerEnterAnimation: () => void;
  56114. /** Callback used to start pointer out animation */
  56115. pointerOutAnimation: () => void;
  56116. /** Callback used to start pointer down animation */
  56117. pointerDownAnimation: () => void;
  56118. /** Callback used to start pointer up animation */
  56119. pointerUpAnimation: () => void;
  56120. /**
  56121. * An event triggered when the pointer move over the control
  56122. */
  56123. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  56124. /**
  56125. * An event triggered when the pointer move out of the control
  56126. */
  56127. onPointerOutObservable: BABYLON.Observable<Control3D>;
  56128. /**
  56129. * An event triggered when the pointer taps the control
  56130. */
  56131. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  56132. /**
  56133. * An event triggered when pointer is up
  56134. */
  56135. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  56136. /**
  56137. * An event triggered when a control is clicked on (with a mouse)
  56138. */
  56139. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  56140. /**
  56141. * An event triggered when pointer enters the control
  56142. */
  56143. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  56144. /**
  56145. * Gets or sets the parent container
  56146. */
  56147. parent: BABYLON.Nullable<Container3D>;
  56148. private _behaviors;
  56149. /**
  56150. * Gets the list of attached behaviors
  56151. * @see http://doc.babylonjs.com/features/behaviour
  56152. */
  56153. readonly behaviors: BABYLON.Behavior<Control3D>[];
  56154. /**
  56155. * Attach a behavior to the control
  56156. * @see http://doc.babylonjs.com/features/behaviour
  56157. * @param behavior defines the behavior to attach
  56158. * @returns the current control
  56159. */
  56160. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  56161. /**
  56162. * Remove an attached behavior
  56163. * @see http://doc.babylonjs.com/features/behaviour
  56164. * @param behavior defines the behavior to attach
  56165. * @returns the current control
  56166. */
  56167. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  56168. /**
  56169. * Gets an attached behavior by name
  56170. * @param name defines the name of the behavior to look for
  56171. * @see http://doc.babylonjs.com/features/behaviour
  56172. * @returns null if behavior was not found else the requested behavior
  56173. */
  56174. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  56175. /** Gets or sets a boolean indicating if the control is visible */
  56176. isVisible: boolean;
  56177. /**
  56178. * Creates a new control
  56179. * @param name defines the control name
  56180. */
  56181. constructor(
  56182. /** Defines the control name */
  56183. name?: string | undefined);
  56184. /**
  56185. * Gets a string representing the class name
  56186. */
  56187. readonly typeName: string;
  56188. /**
  56189. * Get the current class name of the control.
  56190. * @returns current class name
  56191. */
  56192. getClassName(): string;
  56193. protected _getTypeName(): string;
  56194. /**
  56195. * Gets the transform node used by this control
  56196. */
  56197. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  56198. /**
  56199. * Gets the mesh used to render this control
  56200. */
  56201. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56202. /**
  56203. * Link the control as child of the given node
  56204. * @param node defines the node to link to. Use null to unlink the control
  56205. * @returns the current control
  56206. */
  56207. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  56208. /** @hidden **/ prepareNode(scene: BABYLON.Scene): void;
  56209. /**
  56210. * Node creation.
  56211. * Can be overriden by children
  56212. * @param scene defines the scene where the node must be attached
  56213. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  56214. */
  56215. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  56216. /**
  56217. * Affect a material to the given mesh
  56218. * @param mesh defines the mesh which will represent the control
  56219. */
  56220. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  56221. /** @hidden */ onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  56222. /** @hidden */ onPointerEnter(target: Control3D): boolean;
  56223. /** @hidden */ onPointerOut(target: Control3D): void;
  56224. /** @hidden */ onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  56225. /** @hidden */ onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  56226. /** @hidden */
  56227. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  56228. /** @hidden */ processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  56229. /** @hidden */ disposeNode(): void;
  56230. /**
  56231. * Releases all associated resources
  56232. */
  56233. dispose(): void;
  56234. }
  56235. }
  56236. declare module BABYLON.GUI {
  56237. /**
  56238. * Class used as a root to all buttons
  56239. */
  56240. export class AbstractButton3D extends Control3D {
  56241. /**
  56242. * Creates a new button
  56243. * @param name defines the control name
  56244. */
  56245. constructor(name?: string);
  56246. protected _getTypeName(): string;
  56247. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  56248. }
  56249. }
  56250. declare module BABYLON.GUI {
  56251. /**
  56252. * Class used to create a button in 3D
  56253. */
  56254. export class Button3D extends AbstractButton3D {
  56255. /** @hidden */
  56256. protected _currentMaterial: BABYLON.Material;
  56257. private _facadeTexture;
  56258. private _content;
  56259. private _contentResolution;
  56260. private _contentScaleRatio;
  56261. /**
  56262. * Gets or sets the texture resolution used to render content (512 by default)
  56263. */
  56264. contentResolution: BABYLON.int;
  56265. /**
  56266. * Gets or sets the texture scale ratio used to render content (2 by default)
  56267. */
  56268. contentScaleRatio: number;
  56269. protected _disposeFacadeTexture(): void;
  56270. protected _resetContent(): void;
  56271. /**
  56272. * Creates a new button
  56273. * @param name defines the control name
  56274. */
  56275. constructor(name?: string);
  56276. /**
  56277. * Gets or sets the GUI 2D content used to display the button's facade
  56278. */
  56279. content: Control;
  56280. /**
  56281. * Apply the facade texture (created from the content property).
  56282. * This function can be overloaded by child classes
  56283. * @param facadeTexture defines the AdvancedDynamicTexture to use
  56284. */
  56285. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  56286. protected _getTypeName(): string;
  56287. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  56288. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  56289. /**
  56290. * Releases all associated resources
  56291. */
  56292. dispose(): void;
  56293. }
  56294. }
  56295. declare module BABYLON.GUI {
  56296. /**
  56297. * Abstract class used to create a container panel deployed on the surface of a volume
  56298. */
  56299. export abstract class VolumeBasedPanel extends Container3D {
  56300. private _columns;
  56301. private _rows;
  56302. private _rowThenColum;
  56303. private _orientation;
  56304. protected _cellWidth: number;
  56305. protected _cellHeight: number;
  56306. /**
  56307. * Gets or sets the distance between elements
  56308. */
  56309. margin: number;
  56310. /**
  56311. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  56312. * | Value | Type | Description |
  56313. * | ----- | ----------------------------------- | ----------- |
  56314. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  56315. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  56316. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  56317. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  56318. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  56319. */
  56320. orientation: number;
  56321. /**
  56322. * Gets or sets the number of columns requested (10 by default).
  56323. * The panel will automatically compute the number of rows based on number of child controls.
  56324. */
  56325. columns: BABYLON.int;
  56326. /**
  56327. * Gets or sets a the number of rows requested.
  56328. * The panel will automatically compute the number of columns based on number of child controls.
  56329. */
  56330. rows: BABYLON.int;
  56331. /**
  56332. * Creates new VolumeBasedPanel
  56333. */
  56334. constructor();
  56335. protected _arrangeChildren(): void;
  56336. /** Child classes must implement this function to provide correct control positioning */
  56337. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56338. /** Child classes can implement this function to provide additional processing */
  56339. protected _finalProcessing(): void;
  56340. }
  56341. }
  56342. declare module BABYLON.GUI {
  56343. /**
  56344. * Class used to create a container panel deployed on the surface of a cylinder
  56345. */
  56346. export class CylinderPanel extends VolumeBasedPanel {
  56347. private _radius;
  56348. /**
  56349. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  56350. */
  56351. radius: BABYLON.float;
  56352. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56353. private _cylindricalMapping;
  56354. }
  56355. }
  56356. declare module BABYLON.GUI {
  56357. /** @hidden */
  56358. export var fluentVertexShader: {
  56359. name: string;
  56360. shader: string;
  56361. };
  56362. }
  56363. declare module BABYLON.GUI {
  56364. /** @hidden */
  56365. export var fluentPixelShader: {
  56366. name: string;
  56367. shader: string;
  56368. };
  56369. }
  56370. declare module BABYLON.GUI {
  56371. /** @hidden */
  56372. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  56373. INNERGLOW: boolean;
  56374. BORDER: boolean;
  56375. HOVERLIGHT: boolean;
  56376. TEXTURE: boolean;
  56377. constructor();
  56378. }
  56379. /**
  56380. * Class used to render controls with fluent desgin
  56381. */
  56382. export class FluentMaterial extends BABYLON.PushMaterial {
  56383. /**
  56384. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  56385. */
  56386. innerGlowColorIntensity: number;
  56387. /**
  56388. * Gets or sets the inner glow color (white by default)
  56389. */
  56390. innerGlowColor: BABYLON.Color3;
  56391. /**
  56392. * Gets or sets alpha value (default is 1.0)
  56393. */
  56394. alpha: number;
  56395. /**
  56396. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  56397. */
  56398. albedoColor: BABYLON.Color3;
  56399. /**
  56400. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  56401. */
  56402. renderBorders: boolean;
  56403. /**
  56404. * Gets or sets border width (default is 0.5)
  56405. */
  56406. borderWidth: number;
  56407. /**
  56408. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  56409. */
  56410. edgeSmoothingValue: number;
  56411. /**
  56412. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  56413. */
  56414. borderMinValue: number;
  56415. /**
  56416. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  56417. */
  56418. renderHoverLight: boolean;
  56419. /**
  56420. * Gets or sets the radius used to render the hover light (default is 1.0)
  56421. */
  56422. hoverRadius: number;
  56423. /**
  56424. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  56425. */
  56426. hoverColor: BABYLON.Color4;
  56427. /**
  56428. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  56429. */
  56430. hoverPosition: BABYLON.Vector3;
  56431. private _albedoTexture;
  56432. /** Gets or sets the texture to use for albedo color */
  56433. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  56434. /**
  56435. * Creates a new Fluent material
  56436. * @param name defines the name of the material
  56437. * @param scene defines the hosting scene
  56438. */
  56439. constructor(name: string, scene: BABYLON.Scene);
  56440. needAlphaBlending(): boolean;
  56441. needAlphaTesting(): boolean;
  56442. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  56443. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  56444. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  56445. getActiveTextures(): BABYLON.BaseTexture[];
  56446. hasTexture(texture: BABYLON.BaseTexture): boolean;
  56447. dispose(forceDisposeEffect?: boolean): void;
  56448. clone(name: string): FluentMaterial;
  56449. serialize(): any;
  56450. getClassName(): string;
  56451. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  56452. }
  56453. }
  56454. declare module BABYLON.GUI {
  56455. /**
  56456. * Class used to create a holographic button in 3D
  56457. */
  56458. export class HolographicButton extends Button3D {
  56459. private _backPlate;
  56460. private _textPlate;
  56461. private _frontPlate;
  56462. private _text;
  56463. private _imageUrl;
  56464. private _shareMaterials;
  56465. private _frontMaterial;
  56466. private _backMaterial;
  56467. private _plateMaterial;
  56468. private _pickedPointObserver;
  56469. private _tooltipFade;
  56470. private _tooltipTextBlock;
  56471. private _tooltipTexture;
  56472. private _tooltipMesh;
  56473. private _tooltipHoverObserver;
  56474. private _tooltipOutObserver;
  56475. private _disposeTooltip;
  56476. /**
  56477. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  56478. */
  56479. tooltipText: BABYLON.Nullable<string>;
  56480. /**
  56481. * Gets or sets text for the button
  56482. */
  56483. text: string;
  56484. /**
  56485. * Gets or sets the image url for the button
  56486. */
  56487. imageUrl: string;
  56488. /**
  56489. * Gets the back material used by this button
  56490. */
  56491. readonly backMaterial: FluentMaterial;
  56492. /**
  56493. * Gets the front material used by this button
  56494. */
  56495. readonly frontMaterial: FluentMaterial;
  56496. /**
  56497. * Gets the plate material used by this button
  56498. */
  56499. readonly plateMaterial: BABYLON.StandardMaterial;
  56500. /**
  56501. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  56502. */
  56503. readonly shareMaterials: boolean;
  56504. /**
  56505. * Creates a new button
  56506. * @param name defines the control name
  56507. */
  56508. constructor(name?: string, shareMaterials?: boolean);
  56509. protected _getTypeName(): string;
  56510. private _rebuildContent;
  56511. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  56512. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  56513. private _createBackMaterial;
  56514. private _createFrontMaterial;
  56515. private _createPlateMaterial;
  56516. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  56517. /**
  56518. * Releases all associated resources
  56519. */
  56520. dispose(): void;
  56521. }
  56522. }
  56523. declare module BABYLON.GUI {
  56524. /**
  56525. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  56526. */
  56527. export class MeshButton3D extends Button3D {
  56528. /** @hidden */
  56529. protected _currentMesh: BABYLON.Mesh;
  56530. /**
  56531. * Creates a new 3D button based on a mesh
  56532. * @param mesh mesh to become a 3D button
  56533. * @param name defines the control name
  56534. */
  56535. constructor(mesh: BABYLON.Mesh, name?: string);
  56536. protected _getTypeName(): string;
  56537. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  56538. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  56539. }
  56540. }
  56541. declare module BABYLON.GUI {
  56542. /**
  56543. * Class used to create a container panel deployed on the surface of a plane
  56544. */
  56545. export class PlanePanel extends VolumeBasedPanel {
  56546. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56547. }
  56548. }
  56549. declare module BABYLON.GUI {
  56550. /**
  56551. * Class used to create a container panel where items get randomized planar mapping
  56552. */
  56553. export class ScatterPanel extends VolumeBasedPanel {
  56554. private _iteration;
  56555. /**
  56556. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  56557. */
  56558. iteration: BABYLON.float;
  56559. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56560. private _scatterMapping;
  56561. protected _finalProcessing(): void;
  56562. }
  56563. }
  56564. declare module BABYLON.GUI {
  56565. /**
  56566. * Class used to create a container panel deployed on the surface of a sphere
  56567. */
  56568. export class SpherePanel extends VolumeBasedPanel {
  56569. private _radius;
  56570. /**
  56571. * Gets or sets the radius of the sphere where to project controls (5 by default)
  56572. */
  56573. radius: BABYLON.float;
  56574. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56575. private _sphericalMapping;
  56576. }
  56577. }
  56578. declare module BABYLON.GUI {
  56579. /**
  56580. * Class used to create a stack panel in 3D on XY plane
  56581. */
  56582. export class StackPanel3D extends Container3D {
  56583. private _isVertical;
  56584. /**
  56585. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  56586. */
  56587. isVertical: boolean;
  56588. /**
  56589. * Gets or sets the distance between elements
  56590. */
  56591. margin: number;
  56592. /**
  56593. * Creates new StackPanel
  56594. * @param isVertical
  56595. */
  56596. constructor(isVertical?: boolean);
  56597. protected _arrangeChildren(): void;
  56598. }
  56599. }
  56600. declare module BABYLON {
  56601. /**
  56602. * Mode that determines the coordinate system to use.
  56603. */
  56604. export enum GLTFLoaderCoordinateSystemMode {
  56605. /**
  56606. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  56607. */
  56608. AUTO = 0,
  56609. /**
  56610. * Sets the useRightHandedSystem flag on the scene.
  56611. */
  56612. FORCE_RIGHT_HANDED = 1
  56613. }
  56614. /**
  56615. * Mode that determines what animations will start.
  56616. */
  56617. export enum GLTFLoaderAnimationStartMode {
  56618. /**
  56619. * No animation will start.
  56620. */
  56621. NONE = 0,
  56622. /**
  56623. * The first animation will start.
  56624. */
  56625. FIRST = 1,
  56626. /**
  56627. * All animations will start.
  56628. */
  56629. ALL = 2
  56630. }
  56631. /**
  56632. * Interface that contains the data for the glTF asset.
  56633. */
  56634. export interface IGLTFLoaderData {
  56635. /**
  56636. * Object that represents the glTF JSON.
  56637. */
  56638. json: Object;
  56639. /**
  56640. * The BIN chunk of a binary glTF.
  56641. */
  56642. bin: Nullable<ArrayBufferView>;
  56643. }
  56644. /**
  56645. * Interface for extending the loader.
  56646. */
  56647. export interface IGLTFLoaderExtension {
  56648. /**
  56649. * The name of this extension.
  56650. */
  56651. readonly name: string;
  56652. /**
  56653. * Defines whether this extension is enabled.
  56654. */
  56655. enabled: boolean;
  56656. }
  56657. /**
  56658. * Loader state.
  56659. */
  56660. export enum GLTFLoaderState {
  56661. /**
  56662. * The asset is loading.
  56663. */
  56664. LOADING = 0,
  56665. /**
  56666. * The asset is ready for rendering.
  56667. */
  56668. READY = 1,
  56669. /**
  56670. * The asset is completely loaded.
  56671. */
  56672. COMPLETE = 2
  56673. }
  56674. /** @hidden */
  56675. export interface IGLTFLoader extends IDisposable {
  56676. readonly state: Nullable<GLTFLoaderState>;
  56677. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  56678. meshes: AbstractMesh[];
  56679. particleSystems: IParticleSystem[];
  56680. skeletons: Skeleton[];
  56681. animationGroups: AnimationGroup[];
  56682. }>;
  56683. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  56684. }
  56685. /**
  56686. * File loader for loading glTF files into a scene.
  56687. */
  56688. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  56689. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  56690. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  56691. /**
  56692. * Raised when the asset has been parsed
  56693. */
  56694. onParsedObservable: Observable<IGLTFLoaderData>;
  56695. private _onParsedObserver;
  56696. /**
  56697. * Raised when the asset has been parsed
  56698. */
  56699. onParsed: (loaderData: IGLTFLoaderData) => void;
  56700. /**
  56701. * 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.
  56702. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  56703. * Defaults to true.
  56704. * @hidden
  56705. */
  56706. static IncrementalLoading: boolean;
  56707. /**
  56708. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  56709. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  56710. * @hidden
  56711. */
  56712. static HomogeneousCoordinates: boolean;
  56713. /**
  56714. * The coordinate system mode. Defaults to AUTO.
  56715. */
  56716. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  56717. /**
  56718. * The animation start mode. Defaults to FIRST.
  56719. */
  56720. animationStartMode: GLTFLoaderAnimationStartMode;
  56721. /**
  56722. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  56723. */
  56724. compileMaterials: boolean;
  56725. /**
  56726. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  56727. */
  56728. useClipPlane: boolean;
  56729. /**
  56730. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  56731. */
  56732. compileShadowGenerators: boolean;
  56733. /**
  56734. * Defines if the Alpha blended materials are only applied as coverage.
  56735. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  56736. * If true, no extra effects are applied to transparent pixels.
  56737. */
  56738. transparencyAsCoverage: boolean;
  56739. /**
  56740. * Function called before loading a url referenced by the asset.
  56741. */
  56742. preprocessUrlAsync: (url: string) => Promise<string>;
  56743. /**
  56744. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  56745. */
  56746. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  56747. private _onMeshLoadedObserver;
  56748. /**
  56749. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  56750. */
  56751. onMeshLoaded: (mesh: AbstractMesh) => void;
  56752. /**
  56753. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  56754. */
  56755. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  56756. private _onTextureLoadedObserver;
  56757. /**
  56758. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  56759. */
  56760. onTextureLoaded: (texture: BaseTexture) => void;
  56761. /**
  56762. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  56763. */
  56764. readonly onMaterialLoadedObservable: Observable<Material>;
  56765. private _onMaterialLoadedObserver;
  56766. /**
  56767. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  56768. */
  56769. onMaterialLoaded: (material: Material) => void;
  56770. /**
  56771. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  56772. */
  56773. readonly onCameraLoadedObservable: Observable<Camera>;
  56774. private _onCameraLoadedObserver;
  56775. /**
  56776. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  56777. */
  56778. onCameraLoaded: (camera: Camera) => void;
  56779. /**
  56780. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  56781. * For assets with LODs, raised when all of the LODs are complete.
  56782. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  56783. */
  56784. readonly onCompleteObservable: Observable<void>;
  56785. private _onCompleteObserver;
  56786. /**
  56787. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  56788. * For assets with LODs, raised when all of the LODs are complete.
  56789. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  56790. */
  56791. onComplete: () => void;
  56792. /**
  56793. * Observable raised when an error occurs.
  56794. */
  56795. readonly onErrorObservable: Observable<any>;
  56796. private _onErrorObserver;
  56797. /**
  56798. * Callback raised when an error occurs.
  56799. */
  56800. onError: (reason: any) => void;
  56801. /**
  56802. * Observable raised after the loader is disposed.
  56803. */
  56804. readonly onDisposeObservable: Observable<void>;
  56805. private _onDisposeObserver;
  56806. /**
  56807. * Callback raised after the loader is disposed.
  56808. */
  56809. onDispose: () => void;
  56810. /**
  56811. * Observable raised after a loader extension is created.
  56812. * Set additional options for a loader extension in this event.
  56813. */
  56814. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  56815. private _onExtensionLoadedObserver;
  56816. /**
  56817. * Callback raised after a loader extension is created.
  56818. */
  56819. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  56820. /**
  56821. * Defines if the loader logging is enabled.
  56822. */
  56823. loggingEnabled: boolean;
  56824. /**
  56825. * Defines if the loader should capture performance counters.
  56826. */
  56827. capturePerformanceCounters: boolean;
  56828. /**
  56829. * Defines if the loader should validate the asset.
  56830. */
  56831. validate: boolean;
  56832. /**
  56833. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  56834. */
  56835. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  56836. private _onValidatedObserver;
  56837. /**
  56838. * Callback raised after a loader extension is created.
  56839. */
  56840. onValidated: (results: IGLTFValidationResults) => void;
  56841. private _loader;
  56842. /**
  56843. * Name of the loader ("gltf")
  56844. */
  56845. name: string;
  56846. /**
  56847. * Supported file extensions of the loader (.gltf, .glb)
  56848. */
  56849. extensions: ISceneLoaderPluginExtensions;
  56850. /**
  56851. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  56852. */
  56853. dispose(): void;
  56854. /** @hidden */ clear(): void;
  56855. /**
  56856. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  56857. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  56858. * @param scene the scene the meshes should be added to
  56859. * @param data the glTF data to load
  56860. * @param rootUrl root url to load from
  56861. * @param onProgress event that fires when loading progress has occured
  56862. * @param fileName Defines the name of the file to load
  56863. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  56864. */
  56865. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  56866. meshes: AbstractMesh[];
  56867. particleSystems: IParticleSystem[];
  56868. skeletons: Skeleton[];
  56869. animationGroups: AnimationGroup[];
  56870. }>;
  56871. /**
  56872. * Imports all objects from the loaded glTF data and adds them to the scene
  56873. * @param scene the scene the objects should be added to
  56874. * @param data the glTF data to load
  56875. * @param rootUrl root url to load from
  56876. * @param onProgress event that fires when loading progress has occured
  56877. * @param fileName Defines the name of the file to load
  56878. * @returns a promise which completes when objects have been loaded to the scene
  56879. */
  56880. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  56881. /**
  56882. * Load into an asset container.
  56883. * @param scene The scene to load into
  56884. * @param data The data to import
  56885. * @param rootUrl The root url for scene and resources
  56886. * @param onProgress The callback when the load progresses
  56887. * @param fileName Defines the name of the file to load
  56888. * @returns The loaded asset container
  56889. */
  56890. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  56891. /**
  56892. * If the data string can be loaded directly.
  56893. * @param data string contianing the file data
  56894. * @returns if the data can be loaded directly
  56895. */
  56896. canDirectLoad(data: string): boolean;
  56897. /**
  56898. * Rewrites a url by combining a root url and response url.
  56899. */
  56900. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  56901. /**
  56902. * Instantiates a glTF file loader plugin.
  56903. * @returns the created plugin
  56904. */
  56905. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  56906. /**
  56907. * The loader state or null if the loader is not active.
  56908. */
  56909. readonly loaderState: Nullable<GLTFLoaderState>;
  56910. /**
  56911. * Returns a promise that resolves when the asset is completely loaded.
  56912. * @returns a promise that resolves when the asset is completely loaded.
  56913. */
  56914. whenCompleteAsync(): Promise<void>;
  56915. private _parseAsync;
  56916. private _validateAsync;
  56917. private _getLoader;
  56918. private _unpackBinary;
  56919. private _unpackBinaryV1;
  56920. private _unpackBinaryV2;
  56921. private static _parseVersion;
  56922. private static _compareVersion;
  56923. private static _decodeBufferToText;
  56924. private static readonly _logSpaces;
  56925. private _logIndentLevel;
  56926. private _loggingEnabled;
  56927. /** @hidden */ log: (message: string) => void;
  56928. /** @hidden */ logOpen(message: string): void;
  56929. /** @hidden */ logClose(): void;
  56930. private _logEnabled;
  56931. private _logDisabled;
  56932. private _capturePerformanceCounters;
  56933. /** @hidden */ startPerformanceCounter: (counterName: string) => void;
  56934. /** @hidden */ endPerformanceCounter: (counterName: string) => void;
  56935. private _startPerformanceCounterEnabled;
  56936. private _startPerformanceCounterDisabled;
  56937. private _endPerformanceCounterEnabled;
  56938. private _endPerformanceCounterDisabled;
  56939. }
  56940. }
  56941. declare module BABYLON.GLTF1 {
  56942. /**
  56943. * Enums
  56944. * @hidden
  56945. */
  56946. export enum EComponentType {
  56947. BYTE = 5120,
  56948. UNSIGNED_BYTE = 5121,
  56949. SHORT = 5122,
  56950. UNSIGNED_SHORT = 5123,
  56951. FLOAT = 5126
  56952. }
  56953. /** @hidden */
  56954. export enum EShaderType {
  56955. FRAGMENT = 35632,
  56956. VERTEX = 35633
  56957. }
  56958. /** @hidden */
  56959. export enum EParameterType {
  56960. BYTE = 5120,
  56961. UNSIGNED_BYTE = 5121,
  56962. SHORT = 5122,
  56963. UNSIGNED_SHORT = 5123,
  56964. INT = 5124,
  56965. UNSIGNED_INT = 5125,
  56966. FLOAT = 5126,
  56967. FLOAT_VEC2 = 35664,
  56968. FLOAT_VEC3 = 35665,
  56969. FLOAT_VEC4 = 35666,
  56970. INT_VEC2 = 35667,
  56971. INT_VEC3 = 35668,
  56972. INT_VEC4 = 35669,
  56973. BOOL = 35670,
  56974. BOOL_VEC2 = 35671,
  56975. BOOL_VEC3 = 35672,
  56976. BOOL_VEC4 = 35673,
  56977. FLOAT_MAT2 = 35674,
  56978. FLOAT_MAT3 = 35675,
  56979. FLOAT_MAT4 = 35676,
  56980. SAMPLER_2D = 35678
  56981. }
  56982. /** @hidden */
  56983. export enum ETextureWrapMode {
  56984. CLAMP_TO_EDGE = 33071,
  56985. MIRRORED_REPEAT = 33648,
  56986. REPEAT = 10497
  56987. }
  56988. /** @hidden */
  56989. export enum ETextureFilterType {
  56990. NEAREST = 9728,
  56991. LINEAR = 9728,
  56992. NEAREST_MIPMAP_NEAREST = 9984,
  56993. LINEAR_MIPMAP_NEAREST = 9985,
  56994. NEAREST_MIPMAP_LINEAR = 9986,
  56995. LINEAR_MIPMAP_LINEAR = 9987
  56996. }
  56997. /** @hidden */
  56998. export enum ETextureFormat {
  56999. ALPHA = 6406,
  57000. RGB = 6407,
  57001. RGBA = 6408,
  57002. LUMINANCE = 6409,
  57003. LUMINANCE_ALPHA = 6410
  57004. }
  57005. /** @hidden */
  57006. export enum ECullingType {
  57007. FRONT = 1028,
  57008. BACK = 1029,
  57009. FRONT_AND_BACK = 1032
  57010. }
  57011. /** @hidden */
  57012. export enum EBlendingFunction {
  57013. ZERO = 0,
  57014. ONE = 1,
  57015. SRC_COLOR = 768,
  57016. ONE_MINUS_SRC_COLOR = 769,
  57017. DST_COLOR = 774,
  57018. ONE_MINUS_DST_COLOR = 775,
  57019. SRC_ALPHA = 770,
  57020. ONE_MINUS_SRC_ALPHA = 771,
  57021. DST_ALPHA = 772,
  57022. ONE_MINUS_DST_ALPHA = 773,
  57023. CONSTANT_COLOR = 32769,
  57024. ONE_MINUS_CONSTANT_COLOR = 32770,
  57025. CONSTANT_ALPHA = 32771,
  57026. ONE_MINUS_CONSTANT_ALPHA = 32772,
  57027. SRC_ALPHA_SATURATE = 776
  57028. }
  57029. /** @hidden */
  57030. export interface IGLTFProperty {
  57031. extensions?: {
  57032. [key: string]: any;
  57033. };
  57034. extras?: Object;
  57035. }
  57036. /** @hidden */
  57037. export interface IGLTFChildRootProperty extends IGLTFProperty {
  57038. name?: string;
  57039. }
  57040. /** @hidden */
  57041. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  57042. bufferView: string;
  57043. byteOffset: number;
  57044. byteStride: number;
  57045. count: number;
  57046. type: string;
  57047. componentType: EComponentType;
  57048. max?: number[];
  57049. min?: number[];
  57050. name?: string;
  57051. }
  57052. /** @hidden */
  57053. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  57054. buffer: string;
  57055. byteOffset: number;
  57056. byteLength: number;
  57057. byteStride: number;
  57058. target?: number;
  57059. }
  57060. /** @hidden */
  57061. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  57062. uri: string;
  57063. byteLength?: number;
  57064. type?: string;
  57065. }
  57066. /** @hidden */
  57067. export interface IGLTFShader extends IGLTFChildRootProperty {
  57068. uri: string;
  57069. type: EShaderType;
  57070. }
  57071. /** @hidden */
  57072. export interface IGLTFProgram extends IGLTFChildRootProperty {
  57073. attributes: string[];
  57074. fragmentShader: string;
  57075. vertexShader: string;
  57076. }
  57077. /** @hidden */
  57078. export interface IGLTFTechniqueParameter {
  57079. type: number;
  57080. count?: number;
  57081. semantic?: string;
  57082. node?: string;
  57083. value?: number | boolean | string | Array<any>;
  57084. source?: string;
  57085. babylonValue?: any;
  57086. }
  57087. /** @hidden */
  57088. export interface IGLTFTechniqueCommonProfile {
  57089. lightingModel: string;
  57090. texcoordBindings: Object;
  57091. parameters?: Array<any>;
  57092. }
  57093. /** @hidden */
  57094. export interface IGLTFTechniqueStatesFunctions {
  57095. blendColor?: number[];
  57096. blendEquationSeparate?: number[];
  57097. blendFuncSeparate?: number[];
  57098. colorMask: boolean[];
  57099. cullFace: number[];
  57100. }
  57101. /** @hidden */
  57102. export interface IGLTFTechniqueStates {
  57103. enable: number[];
  57104. functions: IGLTFTechniqueStatesFunctions;
  57105. }
  57106. /** @hidden */
  57107. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  57108. parameters: {
  57109. [key: string]: IGLTFTechniqueParameter;
  57110. };
  57111. program: string;
  57112. attributes: {
  57113. [key: string]: string;
  57114. };
  57115. uniforms: {
  57116. [key: string]: string;
  57117. };
  57118. states: IGLTFTechniqueStates;
  57119. }
  57120. /** @hidden */
  57121. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  57122. technique?: string;
  57123. values: string[];
  57124. }
  57125. /** @hidden */
  57126. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  57127. attributes: {
  57128. [key: string]: string;
  57129. };
  57130. indices: string;
  57131. material: string;
  57132. mode?: number;
  57133. }
  57134. /** @hidden */
  57135. export interface IGLTFMesh extends IGLTFChildRootProperty {
  57136. primitives: IGLTFMeshPrimitive[];
  57137. }
  57138. /** @hidden */
  57139. export interface IGLTFImage extends IGLTFChildRootProperty {
  57140. uri: string;
  57141. }
  57142. /** @hidden */
  57143. export interface IGLTFSampler extends IGLTFChildRootProperty {
  57144. magFilter?: number;
  57145. minFilter?: number;
  57146. wrapS?: number;
  57147. wrapT?: number;
  57148. }
  57149. /** @hidden */
  57150. export interface IGLTFTexture extends IGLTFChildRootProperty {
  57151. sampler: string;
  57152. source: string;
  57153. format?: ETextureFormat;
  57154. internalFormat?: ETextureFormat;
  57155. target?: number;
  57156. type?: number;
  57157. babylonTexture?: Texture;
  57158. }
  57159. /** @hidden */
  57160. export interface IGLTFAmbienLight {
  57161. color?: number[];
  57162. }
  57163. /** @hidden */
  57164. export interface IGLTFDirectionalLight {
  57165. color?: number[];
  57166. }
  57167. /** @hidden */
  57168. export interface IGLTFPointLight {
  57169. color?: number[];
  57170. constantAttenuation?: number;
  57171. linearAttenuation?: number;
  57172. quadraticAttenuation?: number;
  57173. }
  57174. /** @hidden */
  57175. export interface IGLTFSpotLight {
  57176. color?: number[];
  57177. constantAttenuation?: number;
  57178. fallOfAngle?: number;
  57179. fallOffExponent?: number;
  57180. linearAttenuation?: number;
  57181. quadraticAttenuation?: number;
  57182. }
  57183. /** @hidden */
  57184. export interface IGLTFLight extends IGLTFChildRootProperty {
  57185. type: string;
  57186. }
  57187. /** @hidden */
  57188. export interface IGLTFCameraOrthographic {
  57189. xmag: number;
  57190. ymag: number;
  57191. zfar: number;
  57192. znear: number;
  57193. }
  57194. /** @hidden */
  57195. export interface IGLTFCameraPerspective {
  57196. aspectRatio: number;
  57197. yfov: number;
  57198. zfar: number;
  57199. znear: number;
  57200. }
  57201. /** @hidden */
  57202. export interface IGLTFCamera extends IGLTFChildRootProperty {
  57203. type: string;
  57204. }
  57205. /** @hidden */
  57206. export interface IGLTFAnimationChannelTarget {
  57207. id: string;
  57208. path: string;
  57209. }
  57210. /** @hidden */
  57211. export interface IGLTFAnimationChannel {
  57212. sampler: string;
  57213. target: IGLTFAnimationChannelTarget;
  57214. }
  57215. /** @hidden */
  57216. export interface IGLTFAnimationSampler {
  57217. input: string;
  57218. output: string;
  57219. interpolation?: string;
  57220. }
  57221. /** @hidden */
  57222. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  57223. channels?: IGLTFAnimationChannel[];
  57224. parameters?: {
  57225. [key: string]: string;
  57226. };
  57227. samplers?: {
  57228. [key: string]: IGLTFAnimationSampler;
  57229. };
  57230. }
  57231. /** @hidden */
  57232. export interface IGLTFNodeInstanceSkin {
  57233. skeletons: string[];
  57234. skin: string;
  57235. meshes: string[];
  57236. }
  57237. /** @hidden */
  57238. export interface IGLTFSkins extends IGLTFChildRootProperty {
  57239. bindShapeMatrix: number[];
  57240. inverseBindMatrices: string;
  57241. jointNames: string[];
  57242. babylonSkeleton?: Skeleton;
  57243. }
  57244. /** @hidden */
  57245. export interface IGLTFNode extends IGLTFChildRootProperty {
  57246. camera?: string;
  57247. children: string[];
  57248. skin?: string;
  57249. jointName?: string;
  57250. light?: string;
  57251. matrix: number[];
  57252. mesh?: string;
  57253. meshes?: string[];
  57254. rotation?: number[];
  57255. scale?: number[];
  57256. translation?: number[];
  57257. babylonNode?: Node;
  57258. }
  57259. /** @hidden */
  57260. export interface IGLTFScene extends IGLTFChildRootProperty {
  57261. nodes: string[];
  57262. }
  57263. /** @hidden */
  57264. export interface IGLTFRuntime {
  57265. extensions: {
  57266. [key: string]: any;
  57267. };
  57268. accessors: {
  57269. [key: string]: IGLTFAccessor;
  57270. };
  57271. buffers: {
  57272. [key: string]: IGLTFBuffer;
  57273. };
  57274. bufferViews: {
  57275. [key: string]: IGLTFBufferView;
  57276. };
  57277. meshes: {
  57278. [key: string]: IGLTFMesh;
  57279. };
  57280. lights: {
  57281. [key: string]: IGLTFLight;
  57282. };
  57283. cameras: {
  57284. [key: string]: IGLTFCamera;
  57285. };
  57286. nodes: {
  57287. [key: string]: IGLTFNode;
  57288. };
  57289. images: {
  57290. [key: string]: IGLTFImage;
  57291. };
  57292. textures: {
  57293. [key: string]: IGLTFTexture;
  57294. };
  57295. shaders: {
  57296. [key: string]: IGLTFShader;
  57297. };
  57298. programs: {
  57299. [key: string]: IGLTFProgram;
  57300. };
  57301. samplers: {
  57302. [key: string]: IGLTFSampler;
  57303. };
  57304. techniques: {
  57305. [key: string]: IGLTFTechnique;
  57306. };
  57307. materials: {
  57308. [key: string]: IGLTFMaterial;
  57309. };
  57310. animations: {
  57311. [key: string]: IGLTFAnimation;
  57312. };
  57313. skins: {
  57314. [key: string]: IGLTFSkins;
  57315. };
  57316. currentScene?: Object;
  57317. scenes: {
  57318. [key: string]: IGLTFScene;
  57319. };
  57320. extensionsUsed: string[];
  57321. extensionsRequired?: string[];
  57322. buffersCount: number;
  57323. shaderscount: number;
  57324. scene: Scene;
  57325. rootUrl: string;
  57326. loadedBufferCount: number;
  57327. loadedBufferViews: {
  57328. [name: string]: ArrayBufferView;
  57329. };
  57330. loadedShaderCount: number;
  57331. importOnlyMeshes: boolean;
  57332. importMeshesNames?: string[];
  57333. dummyNodes: Node[];
  57334. }
  57335. /** @hidden */
  57336. export interface INodeToRoot {
  57337. bone: Bone;
  57338. node: IGLTFNode;
  57339. id: string;
  57340. }
  57341. /** @hidden */
  57342. export interface IJointNode {
  57343. node: IGLTFNode;
  57344. id: string;
  57345. }
  57346. }
  57347. declare module BABYLON.GLTF1 {
  57348. /**
  57349. * Utils functions for GLTF
  57350. * @hidden
  57351. */
  57352. export class GLTFUtils {
  57353. /**
  57354. * Sets the given "parameter" matrix
  57355. * @param scene: the Scene object
  57356. * @param source: the source node where to pick the matrix
  57357. * @param parameter: the GLTF technique parameter
  57358. * @param uniformName: the name of the shader's uniform
  57359. * @param shaderMaterial: the shader material
  57360. */
  57361. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  57362. /**
  57363. * Sets the given "parameter" matrix
  57364. * @param shaderMaterial: the shader material
  57365. * @param uniform: the name of the shader's uniform
  57366. * @param value: the value of the uniform
  57367. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  57368. */
  57369. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  57370. /**
  57371. * Returns the wrap mode of the texture
  57372. * @param mode: the mode value
  57373. */
  57374. static GetWrapMode(mode: number): number;
  57375. /**
  57376. * Returns the byte stride giving an accessor
  57377. * @param accessor: the GLTF accessor objet
  57378. */
  57379. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  57380. /**
  57381. * Returns the texture filter mode giving a mode value
  57382. * @param mode: the filter mode value
  57383. */
  57384. static GetTextureFilterMode(mode: number): ETextureFilterType;
  57385. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  57386. /**
  57387. * Returns a buffer from its accessor
  57388. * @param gltfRuntime: the GLTF runtime
  57389. * @param accessor: the GLTF accessor
  57390. */
  57391. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  57392. /**
  57393. * Decodes a buffer view into a string
  57394. * @param view: the buffer view
  57395. */
  57396. static DecodeBufferToText(view: ArrayBufferView): string;
  57397. /**
  57398. * Returns the default material of gltf. Related to
  57399. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  57400. * @param scene: the Babylon.js scene
  57401. */
  57402. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  57403. private static _DefaultMaterial;
  57404. }
  57405. }
  57406. declare module BABYLON.GLTF1 {
  57407. /**
  57408. * Implementation of the base glTF spec
  57409. * @hidden
  57410. */
  57411. export class GLTFLoaderBase {
  57412. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  57413. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  57414. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  57415. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  57416. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  57417. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  57418. }
  57419. /**
  57420. * glTF V1 Loader
  57421. * @hidden
  57422. */
  57423. export class GLTFLoader implements IGLTFLoader {
  57424. static Extensions: {
  57425. [name: string]: GLTFLoaderExtension;
  57426. };
  57427. static RegisterExtension(extension: GLTFLoaderExtension): void;
  57428. state: Nullable<GLTFLoaderState>;
  57429. dispose(): void;
  57430. private _importMeshAsync;
  57431. /**
  57432. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  57433. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  57434. * @param scene the scene the meshes should be added to
  57435. * @param data gltf data containing information of the meshes in a loaded file
  57436. * @param rootUrl root url to load from
  57437. * @param onProgress event that fires when loading progress has occured
  57438. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  57439. */
  57440. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  57441. meshes: AbstractMesh[];
  57442. particleSystems: IParticleSystem[];
  57443. skeletons: Skeleton[];
  57444. animationGroups: AnimationGroup[];
  57445. }>;
  57446. private _loadAsync;
  57447. /**
  57448. * Imports all objects from a loaded gltf file and adds them to the scene
  57449. * @param scene the scene the objects should be added to
  57450. * @param data gltf data containing information of the meshes in a loaded file
  57451. * @param rootUrl root url to load from
  57452. * @param onProgress event that fires when loading progress has occured
  57453. * @returns a promise which completes when objects have been loaded to the scene
  57454. */
  57455. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  57456. private _loadShadersAsync;
  57457. private _loadBuffersAsync;
  57458. private _createNodes;
  57459. }
  57460. /** @hidden */
  57461. export abstract class GLTFLoaderExtension {
  57462. private _name;
  57463. constructor(name: string);
  57464. readonly name: string;
  57465. /**
  57466. * Defines an override for loading the runtime
  57467. * Return true to stop further extensions from loading the runtime
  57468. */
  57469. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  57470. /**
  57471. * Defines an onverride for creating gltf runtime
  57472. * Return true to stop further extensions from creating the runtime
  57473. */
  57474. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  57475. /**
  57476. * Defines an override for loading buffers
  57477. * Return true to stop further extensions from loading this buffer
  57478. */
  57479. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  57480. /**
  57481. * Defines an override for loading texture buffers
  57482. * Return true to stop further extensions from loading this texture data
  57483. */
  57484. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  57485. /**
  57486. * Defines an override for creating textures
  57487. * Return true to stop further extensions from loading this texture
  57488. */
  57489. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  57490. /**
  57491. * Defines an override for loading shader strings
  57492. * Return true to stop further extensions from loading this shader data
  57493. */
  57494. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  57495. /**
  57496. * Defines an override for loading materials
  57497. * Return true to stop further extensions from loading this material
  57498. */
  57499. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  57500. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  57501. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  57502. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  57503. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  57504. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  57505. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  57506. private static LoadTextureBufferAsync;
  57507. private static CreateTextureAsync;
  57508. private static ApplyExtensions;
  57509. }
  57510. }
  57511. declare module BABYLON.GLTF1 {
  57512. /** @hidden */
  57513. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  57514. private _bin;
  57515. constructor();
  57516. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  57517. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  57518. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  57519. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  57520. }
  57521. }
  57522. declare module BABYLON.GLTF1 {
  57523. /** @hidden */
  57524. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  57525. constructor();
  57526. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  57527. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  57528. private _loadTexture;
  57529. }
  57530. }
  57531. declare module BABYLON.GLTF2.Loader {
  57532. /**
  57533. * Loader interface with an index field.
  57534. */
  57535. export interface IArrayItem {
  57536. /**
  57537. * The index of this item in the array.
  57538. */
  57539. index: number;
  57540. }
  57541. /**
  57542. * Loader interface with additional members.
  57543. */
  57544. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  57545. /** @hidden */ data?: Promise<ArrayBufferView>;
  57546. /** @hidden */ babylonVertexBuffer?: Promise<VertexBuffer>;
  57547. }
  57548. /**
  57549. * Loader interface with additional members.
  57550. */
  57551. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  57552. }
  57553. /** @hidden */
  57554. export interface _IAnimationSamplerData {
  57555. input: Float32Array;
  57556. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  57557. output: Float32Array;
  57558. }
  57559. /**
  57560. * Loader interface with additional members.
  57561. */
  57562. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  57563. /** @hidden */ data?: Promise<_IAnimationSamplerData>;
  57564. }
  57565. /**
  57566. * Loader interface with additional members.
  57567. */
  57568. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  57569. channels: IAnimationChannel[];
  57570. samplers: IAnimationSampler[];
  57571. /** @hidden */ babylonAnimationGroup?: AnimationGroup;
  57572. }
  57573. /**
  57574. * Loader interface with additional members.
  57575. */
  57576. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  57577. /** @hidden */ data?: Promise<ArrayBufferView>;
  57578. }
  57579. /**
  57580. * Loader interface with additional members.
  57581. */
  57582. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  57583. /** @hidden */ data?: Promise<ArrayBufferView>;
  57584. /** @hidden */ babylonBuffer?: Promise<Buffer>;
  57585. }
  57586. /**
  57587. * Loader interface with additional members.
  57588. */
  57589. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  57590. }
  57591. /**
  57592. * Loader interface with additional members.
  57593. */
  57594. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  57595. /** @hidden */ data?: Promise<ArrayBufferView>;
  57596. }
  57597. /**
  57598. * Loader interface with additional members.
  57599. */
  57600. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  57601. }
  57602. /**
  57603. * Loader interface with additional members.
  57604. */
  57605. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  57606. }
  57607. /**
  57608. * Loader interface with additional members.
  57609. */
  57610. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  57611. baseColorTexture?: ITextureInfo;
  57612. metallicRoughnessTexture?: ITextureInfo;
  57613. }
  57614. /**
  57615. * Loader interface with additional members.
  57616. */
  57617. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  57618. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  57619. normalTexture?: IMaterialNormalTextureInfo;
  57620. occlusionTexture?: IMaterialOcclusionTextureInfo;
  57621. emissiveTexture?: ITextureInfo;
  57622. /** @hidden */ data?: {
  57623. [babylonDrawMode: number]: {
  57624. babylonMaterial: Material;
  57625. babylonMeshes: AbstractMesh[];
  57626. promise: Promise<void>;
  57627. };
  57628. };
  57629. }
  57630. /**
  57631. * Loader interface with additional members.
  57632. */
  57633. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  57634. primitives: IMeshPrimitive[];
  57635. }
  57636. /**
  57637. * Loader interface with additional members.
  57638. */
  57639. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  57640. /** @hidden */ instanceData?: {
  57641. babylonSourceMesh: Mesh;
  57642. promise: Promise<any>;
  57643. };
  57644. }
  57645. /**
  57646. * Loader interface with additional members.
  57647. */
  57648. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  57649. /**
  57650. * The parent glTF node.
  57651. */
  57652. parent?: INode;
  57653. /** @hidden */ babylonTransformNode?: TransformNode;
  57654. /** @hidden */ primitiveBabylonMeshes?: AbstractMesh[];
  57655. /** @hidden */ babylonBones?: Bone[];
  57656. /** @hidden */ numMorphTargets?: number;
  57657. }
  57658. /** @hidden */
  57659. export interface _ISamplerData {
  57660. noMipMaps: boolean;
  57661. samplingMode: number;
  57662. wrapU: number;
  57663. wrapV: number;
  57664. }
  57665. /**
  57666. * Loader interface with additional members.
  57667. */
  57668. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  57669. /** @hidden */ data?: _ISamplerData;
  57670. }
  57671. /**
  57672. * Loader interface with additional members.
  57673. */
  57674. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  57675. }
  57676. /**
  57677. * Loader interface with additional members.
  57678. */
  57679. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  57680. /** @hidden */ data?: {
  57681. babylonSkeleton: Skeleton;
  57682. promise: Promise<void>;
  57683. };
  57684. }
  57685. /**
  57686. * Loader interface with additional members.
  57687. */
  57688. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  57689. }
  57690. /**
  57691. * Loader interface with additional members.
  57692. */
  57693. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  57694. }
  57695. /**
  57696. * Loader interface with additional members.
  57697. */
  57698. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  57699. accessors?: IAccessor[];
  57700. animations?: IAnimation[];
  57701. buffers?: IBuffer[];
  57702. bufferViews?: IBufferView[];
  57703. cameras?: ICamera[];
  57704. images?: IImage[];
  57705. materials?: IMaterial[];
  57706. meshes?: IMesh[];
  57707. nodes?: INode[];
  57708. samplers?: ISampler[];
  57709. scenes?: IScene[];
  57710. skins?: ISkin[];
  57711. textures?: ITexture[];
  57712. }
  57713. }
  57714. declare module BABYLON.GLTF2 {
  57715. /**
  57716. * Interface for a glTF loader extension.
  57717. */
  57718. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  57719. /**
  57720. * Called after the loader state changes to LOADING.
  57721. */
  57722. onLoading?(): void;
  57723. /**
  57724. * Called after the loader state changes to READY.
  57725. */
  57726. onReady?(): void;
  57727. /**
  57728. * Define this method to modify the default behavior when loading scenes.
  57729. * @param context The context when loading the asset
  57730. * @param scene The glTF scene property
  57731. * @returns A promise that resolves when the load is complete or null if not handled
  57732. */
  57733. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  57734. /**
  57735. * Define this method to modify the default behavior when loading nodes.
  57736. * @param context The context when loading the asset
  57737. * @param node The glTF node property
  57738. * @param assign A function called synchronously after parsing the glTF properties
  57739. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  57740. */
  57741. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  57742. /**
  57743. * Define this method to modify the default behavior when loading cameras.
  57744. * @param context The context when loading the asset
  57745. * @param camera The glTF camera property
  57746. * @param assign A function called synchronously after parsing the glTF properties
  57747. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  57748. */
  57749. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  57750. /**
  57751. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  57752. * @param context The context when loading the asset
  57753. * @param primitive The glTF mesh primitive property
  57754. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  57755. */ loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  57756. /**
  57757. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  57758. * @param context The context when loading the asset
  57759. * @param material The glTF material property
  57760. * @param assign A function called synchronously after parsing the glTF properties
  57761. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  57762. */ loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  57763. /**
  57764. * Define this method to modify the default behavior when creating materials.
  57765. * @param context The context when loading the asset
  57766. * @param material The glTF material property
  57767. * @param babylonDrawMode The draw mode for the Babylon material
  57768. * @returns The Babylon material or null if not handled
  57769. */
  57770. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  57771. /**
  57772. * Define this method to modify the default behavior when loading material properties.
  57773. * @param context The context when loading the asset
  57774. * @param material The glTF material property
  57775. * @param babylonMaterial The Babylon material
  57776. * @returns A promise that resolves when the load is complete or null if not handled
  57777. */
  57778. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  57779. /**
  57780. * Define this method to modify the default behavior when loading texture infos.
  57781. * @param context The context when loading the asset
  57782. * @param textureInfo The glTF texture info property
  57783. * @param assign A function called synchronously after parsing the glTF properties
  57784. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  57785. */
  57786. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  57787. /**
  57788. * Define this method to modify the default behavior when loading animations.
  57789. * @param context The context when loading the asset
  57790. * @param animation The glTF animation property
  57791. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  57792. */
  57793. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  57794. /**
  57795. * Define this method to modify the default behavior when loading uris.
  57796. * @param context The context when loading the asset
  57797. * @param uri The uri to load
  57798. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  57799. */ loadUriAsync?(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  57800. }
  57801. }
  57802. declare module BABYLON.GLTF2 {
  57803. /**
  57804. * Helper class for working with arrays when loading the glTF asset
  57805. */
  57806. export class ArrayItem {
  57807. /**
  57808. * Gets an item from the given array.
  57809. * @param context The context when loading the asset
  57810. * @param array The array to get the item from
  57811. * @param index The index to the array
  57812. * @returns The array item
  57813. */
  57814. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  57815. /**
  57816. * Assign an `index` field to each item of the given array.
  57817. * @param array The array of items
  57818. */
  57819. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  57820. }
  57821. /**
  57822. * The glTF 2.0 loader
  57823. */
  57824. export class GLTFLoader implements IGLTFLoader {
  57825. /** The glTF object parsed from the JSON. */
  57826. gltf: IGLTF;
  57827. /** The Babylon scene when loading the asset. */
  57828. babylonScene: Scene;
  57829. /** @hidden */ completePromises: Promise<any>[];
  57830. private _disposed;
  57831. private _parent;
  57832. private _state;
  57833. private _extensions;
  57834. private _rootUrl;
  57835. private _fileName;
  57836. private _uniqueRootUrl;
  57837. private _rootBabylonMesh;
  57838. private _defaultBabylonMaterialData;
  57839. private _progressCallback?;
  57840. private _requests;
  57841. private static readonly _DefaultSampler;
  57842. private static _ExtensionNames;
  57843. private static _ExtensionFactories;
  57844. /**
  57845. * Registers a loader extension.
  57846. * @param name The name of the loader extension.
  57847. * @param factory The factory function that creates the loader extension.
  57848. */
  57849. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  57850. /**
  57851. * Unregisters a loader extension.
  57852. * @param name The name of the loader extenion.
  57853. * @returns A boolean indicating whether the extension has been unregistered
  57854. */
  57855. static UnregisterExtension(name: string): boolean;
  57856. /**
  57857. * Gets the loader state.
  57858. */
  57859. readonly state: Nullable<GLTFLoaderState>;
  57860. /** @hidden */
  57861. constructor(parent: GLTFFileLoader);
  57862. /** @hidden */
  57863. dispose(): void;
  57864. /** @hidden */
  57865. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  57866. meshes: AbstractMesh[];
  57867. particleSystems: IParticleSystem[];
  57868. skeletons: Skeleton[];
  57869. animationGroups: AnimationGroup[];
  57870. }>;
  57871. /** @hidden */
  57872. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  57873. private _loadAsync;
  57874. private _loadData;
  57875. private _setupData;
  57876. private _loadExtensions;
  57877. private _checkExtensions;
  57878. private _setState;
  57879. private _createRootNode;
  57880. /**
  57881. * Loads a glTF scene.
  57882. * @param context The context when loading the asset
  57883. * @param scene The glTF scene property
  57884. * @returns A promise that resolves when the load is complete
  57885. */
  57886. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  57887. private _forEachPrimitive;
  57888. private _getMeshes;
  57889. private _getSkeletons;
  57890. private _getAnimationGroups;
  57891. private _startAnimations;
  57892. /**
  57893. * Loads a glTF node.
  57894. * @param context The context when loading the asset
  57895. * @param node The glTF node property
  57896. * @param assign A function called synchronously after parsing the glTF properties
  57897. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  57898. */
  57899. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  57900. private _loadMeshAsync;
  57901. private _loadMeshPrimitiveAsync;
  57902. private _loadVertexDataAsync;
  57903. private _createMorphTargets;
  57904. private _loadMorphTargetsAsync;
  57905. private _loadMorphTargetVertexDataAsync;
  57906. private static _LoadTransform;
  57907. private _loadSkinAsync;
  57908. private _loadBones;
  57909. private _loadBone;
  57910. private _loadSkinInverseBindMatricesDataAsync;
  57911. private _updateBoneMatrices;
  57912. private _getNodeMatrix;
  57913. /**
  57914. * Loads a glTF camera.
  57915. * @param context The context when loading the asset
  57916. * @param camera The glTF camera property
  57917. * @param assign A function called synchronously after parsing the glTF properties
  57918. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  57919. */
  57920. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  57921. private _loadAnimationsAsync;
  57922. /**
  57923. * Loads a glTF animation.
  57924. * @param context The context when loading the asset
  57925. * @param animation The glTF animation property
  57926. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  57927. */
  57928. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  57929. private _loadAnimationChannelAsync;
  57930. private _loadAnimationSamplerAsync;
  57931. private _loadBufferAsync;
  57932. /**
  57933. * Loads a glTF buffer view.
  57934. * @param context The context when loading the asset
  57935. * @param bufferView The glTF buffer view property
  57936. * @returns A promise that resolves with the loaded data when the load is complete
  57937. */
  57938. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  57939. private _loadIndicesAccessorAsync;
  57940. private _loadFloatAccessorAsync;
  57941. private _loadVertexBufferViewAsync;
  57942. private _loadVertexAccessorAsync;
  57943. private _loadMaterialMetallicRoughnessPropertiesAsync;
  57944. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  57945. private _createDefaultMaterial;
  57946. /**
  57947. * Creates a Babylon material from a glTF material.
  57948. * @param context The context when loading the asset
  57949. * @param material The glTF material property
  57950. * @param babylonDrawMode The draw mode for the Babylon material
  57951. * @returns The Babylon material
  57952. */
  57953. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  57954. /**
  57955. * Loads properties from a glTF material into a Babylon material.
  57956. * @param context The context when loading the asset
  57957. * @param material The glTF material property
  57958. * @param babylonMaterial The Babylon material
  57959. * @returns A promise that resolves when the load is complete
  57960. */
  57961. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  57962. /**
  57963. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  57964. * @param context The context when loading the asset
  57965. * @param material The glTF material property
  57966. * @param babylonMaterial The Babylon material
  57967. * @returns A promise that resolves when the load is complete
  57968. */
  57969. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  57970. /**
  57971. * Loads the alpha properties from a glTF material into a Babylon material.
  57972. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  57973. * @param context The context when loading the asset
  57974. * @param material The glTF material property
  57975. * @param babylonMaterial The Babylon material
  57976. */
  57977. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  57978. /**
  57979. * Loads a glTF texture info.
  57980. * @param context The context when loading the asset
  57981. * @param textureInfo The glTF texture info property
  57982. * @param assign A function called synchronously after parsing the glTF properties
  57983. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  57984. */
  57985. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  57986. private _loadTextureAsync;
  57987. private _loadSampler;
  57988. /**
  57989. * Loads a glTF image.
  57990. * @param context The context when loading the asset
  57991. * @param image The glTF image property
  57992. * @returns A promise that resolves with the loaded data when the load is complete
  57993. */
  57994. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  57995. /**
  57996. * Loads a glTF uri.
  57997. * @param context The context when loading the asset
  57998. * @param uri The base64 or relative uri
  57999. * @returns A promise that resolves with the loaded data when the load is complete
  58000. */
  58001. loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
  58002. private _onProgress;
  58003. /**
  58004. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  58005. * @param babylonObject the Babylon object with metadata
  58006. * @param pointer the JSON pointer
  58007. */
  58008. static AddPointerMetadata(babylonObject: {
  58009. metadata: any;
  58010. }, pointer: string): void;
  58011. private static _GetTextureWrapMode;
  58012. private static _GetTextureSamplingMode;
  58013. private static _GetTypedArray;
  58014. private static _GetNumComponents;
  58015. private static _ValidateUri;
  58016. private static _GetDrawMode;
  58017. private _compileMaterialsAsync;
  58018. private _compileShadowGeneratorsAsync;
  58019. private _forEachExtensions;
  58020. private _applyExtensions;
  58021. private _extensionsOnLoading;
  58022. private _extensionsOnReady;
  58023. private _extensionsLoadSceneAsync;
  58024. private _extensionsLoadNodeAsync;
  58025. private _extensionsLoadCameraAsync;
  58026. private _extensionsLoadVertexDataAsync;
  58027. private _extensionsLoadMaterialAsync;
  58028. private _extensionsCreateMaterial;
  58029. private _extensionsLoadMaterialPropertiesAsync;
  58030. private _extensionsLoadTextureInfoAsync;
  58031. private _extensionsLoadAnimationAsync;
  58032. private _extensionsLoadUriAsync;
  58033. /**
  58034. * Helper method called by a loader extension to load an glTF extension.
  58035. * @param context The context when loading the asset
  58036. * @param property The glTF property to load the extension from
  58037. * @param extensionName The name of the extension to load
  58038. * @param actionAsync The action to run
  58039. * @returns The promise returned by actionAsync or null if the extension does not exist
  58040. */
  58041. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  58042. /**
  58043. * Helper method called by a loader extension to load a glTF extra.
  58044. * @param context The context when loading the asset
  58045. * @param property The glTF property to load the extra from
  58046. * @param extensionName The name of the extension to load
  58047. * @param actionAsync The action to run
  58048. * @returns The promise returned by actionAsync or null if the extra does not exist
  58049. */
  58050. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  58051. /**
  58052. * Increments the indentation level and logs a message.
  58053. * @param message The message to log
  58054. */
  58055. logOpen(message: string): void;
  58056. /**
  58057. * Decrements the indentation level.
  58058. */
  58059. logClose(): void;
  58060. /**
  58061. * Logs a message
  58062. * @param message The message to log
  58063. */
  58064. log(message: string): void;
  58065. /**
  58066. * Starts a performance counter.
  58067. * @param counterName The name of the performance counter
  58068. */
  58069. startPerformanceCounter(counterName: string): void;
  58070. /**
  58071. * Ends a performance counter.
  58072. * @param counterName The name of the performance counter
  58073. */
  58074. endPerformanceCounter(counterName: string): void;
  58075. }
  58076. }
  58077. declare module BABYLON.GLTF2.Loader.Extensions {
  58078. /**
  58079. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  58080. */
  58081. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  58082. /** The name of this extension. */
  58083. readonly name: string;
  58084. /** Defines whether this extension is enabled. */
  58085. enabled: boolean;
  58086. private _loader;
  58087. private _lights?;
  58088. /** @hidden */
  58089. constructor(loader: GLTFLoader);
  58090. /** @hidden */
  58091. dispose(): void;
  58092. /** @hidden */
  58093. onLoading(): void;
  58094. /** @hidden */
  58095. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  58096. private _loadLightAsync;
  58097. }
  58098. }
  58099. declare module BABYLON.GLTF2.Loader.Extensions {
  58100. /**
  58101. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  58102. */
  58103. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  58104. /** The name of this extension. */
  58105. readonly name: string;
  58106. /** Defines whether this extension is enabled. */
  58107. enabled: boolean;
  58108. private _loader;
  58109. private _dracoCompression?;
  58110. /** @hidden */
  58111. constructor(loader: GLTFLoader);
  58112. /** @hidden */
  58113. dispose(): void;
  58114. /** @hidden */ loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  58115. }
  58116. }
  58117. declare module BABYLON.GLTF2.Loader.Extensions {
  58118. /**
  58119. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  58120. */
  58121. export class KHR_lights implements IGLTFLoaderExtension {
  58122. /** The name of this extension. */
  58123. readonly name: string;
  58124. /** Defines whether this extension is enabled. */
  58125. enabled: boolean;
  58126. private _loader;
  58127. private _lights?;
  58128. /** @hidden */
  58129. constructor(loader: GLTFLoader);
  58130. /** @hidden */
  58131. dispose(): void;
  58132. /** @hidden */
  58133. onLoading(): void;
  58134. /** @hidden */
  58135. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  58136. }
  58137. }
  58138. declare module BABYLON.GLTF2.Loader.Extensions {
  58139. /**
  58140. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  58141. */
  58142. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  58143. /** The name of this extension. */
  58144. readonly name: string;
  58145. /** Defines whether this extension is enabled. */
  58146. enabled: boolean;
  58147. private _loader;
  58148. /** @hidden */
  58149. constructor(loader: GLTFLoader);
  58150. /** @hidden */
  58151. dispose(): void;
  58152. /** @hidden */
  58153. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  58154. private _loadSpecularGlossinessPropertiesAsync;
  58155. }
  58156. }
  58157. declare module BABYLON.GLTF2.Loader.Extensions {
  58158. /**
  58159. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  58160. */
  58161. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  58162. /** The name of this extension. */
  58163. readonly name: string;
  58164. /** Defines whether this extension is enabled. */
  58165. enabled: boolean;
  58166. private _loader;
  58167. /** @hidden */
  58168. constructor(loader: GLTFLoader);
  58169. /** @hidden */
  58170. dispose(): void;
  58171. /** @hidden */
  58172. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  58173. private _loadUnlitPropertiesAsync;
  58174. }
  58175. }
  58176. declare module BABYLON.GLTF2.Loader.Extensions {
  58177. /**
  58178. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  58179. */
  58180. export class KHR_texture_transform implements IGLTFLoaderExtension {
  58181. /** The name of this extension. */
  58182. readonly name: string;
  58183. /** Defines whether this extension is enabled. */
  58184. enabled: boolean;
  58185. private _loader;
  58186. /** @hidden */
  58187. constructor(loader: GLTFLoader);
  58188. /** @hidden */
  58189. dispose(): void;
  58190. /** @hidden */
  58191. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  58192. }
  58193. }
  58194. declare module BABYLON.GLTF2.Loader.Extensions {
  58195. /**
  58196. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  58197. */
  58198. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  58199. /** The name of this extension. */
  58200. readonly name: string;
  58201. /** Defines whether this extension is enabled. */
  58202. enabled: boolean;
  58203. private _loader;
  58204. private _clips;
  58205. private _emitters;
  58206. /** @hidden */
  58207. constructor(loader: GLTFLoader);
  58208. /** @hidden */
  58209. dispose(): void;
  58210. /** @hidden */
  58211. onLoading(): void;
  58212. /** @hidden */
  58213. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  58214. /** @hidden */
  58215. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  58216. /** @hidden */
  58217. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  58218. private _loadClipAsync;
  58219. private _loadEmitterAsync;
  58220. private _getEventAction;
  58221. private _loadAnimationEventAsync;
  58222. }
  58223. }
  58224. declare module BABYLON.GLTF2.Loader.Extensions {
  58225. /**
  58226. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  58227. */
  58228. export class MSFT_lod implements IGLTFLoaderExtension {
  58229. /** The name of this extension. */
  58230. readonly name: string;
  58231. /** Defines whether this extension is enabled. */
  58232. enabled: boolean;
  58233. /**
  58234. * Maximum number of LODs to load, starting from the lowest LOD.
  58235. */
  58236. maxLODsToLoad: number;
  58237. /**
  58238. * Observable raised when all node LODs of one level are loaded.
  58239. * The event data is the index of the loaded LOD starting from zero.
  58240. * Dispose the loader to cancel the loading of the next level of LODs.
  58241. */
  58242. onNodeLODsLoadedObservable: Observable<number>;
  58243. /**
  58244. * Observable raised when all material LODs of one level are loaded.
  58245. * The event data is the index of the loaded LOD starting from zero.
  58246. * Dispose the loader to cancel the loading of the next level of LODs.
  58247. */
  58248. onMaterialLODsLoadedObservable: Observable<number>;
  58249. private _loader;
  58250. private _nodeIndexLOD;
  58251. private _nodeSignalLODs;
  58252. private _nodePromiseLODs;
  58253. private _materialIndexLOD;
  58254. private _materialSignalLODs;
  58255. private _materialPromiseLODs;
  58256. /** @hidden */
  58257. constructor(loader: GLTFLoader);
  58258. /** @hidden */
  58259. dispose(): void;
  58260. /** @hidden */
  58261. onReady(): void;
  58262. /** @hidden */
  58263. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  58264. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  58265. /** @hidden */ loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  58266. /**
  58267. * Gets an array of LOD properties from lowest to highest.
  58268. */
  58269. private _getLODs;
  58270. private _disposeUnusedMaterials;
  58271. }
  58272. }
  58273. declare module BABYLON.GLTF2.Loader.Extensions {
  58274. /** @hidden */
  58275. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  58276. readonly name: string;
  58277. enabled: boolean;
  58278. private _loader;
  58279. constructor(loader: GLTFLoader);
  58280. dispose(): void;
  58281. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  58282. }
  58283. }
  58284. declare module BABYLON.GLTF2.Loader.Extensions {
  58285. /** @hidden */
  58286. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  58287. readonly name: string;
  58288. enabled: boolean;
  58289. private _loader;
  58290. constructor(loader: GLTFLoader);
  58291. dispose(): void;
  58292. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  58293. }
  58294. }
  58295. declare module BABYLON {
  58296. /**
  58297. * Class reading and parsing the MTL file bundled with the obj file.
  58298. */
  58299. export class MTLFileLoader {
  58300. /**
  58301. * All material loaded from the mtl will be set here
  58302. */
  58303. materials: StandardMaterial[];
  58304. /**
  58305. * This function will read the mtl file and create each material described inside
  58306. * This function could be improve by adding :
  58307. * -some component missing (Ni, Tf...)
  58308. * -including the specific options available
  58309. *
  58310. * @param scene defines the scene the material will be created in
  58311. * @param data defines the mtl data to parse
  58312. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  58313. */
  58314. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  58315. /**
  58316. * Gets the texture for the material.
  58317. *
  58318. * If the material is imported from input file,
  58319. * We sanitize the url to ensure it takes the textre from aside the material.
  58320. *
  58321. * @param rootUrl The root url to load from
  58322. * @param value The value stored in the mtl
  58323. * @return The Texture
  58324. */
  58325. private static _getTexture;
  58326. }
  58327. /**
  58328. * OBJ file type loader.
  58329. * This is a babylon scene loader plugin.
  58330. */
  58331. export class OBJFileLoader implements ISceneLoaderPluginAsync {
  58332. /**
  58333. * Defines if UVs are optimized by default during load.
  58334. */
  58335. static OPTIMIZE_WITH_UV: boolean;
  58336. /**
  58337. * Invert model on y-axis (does a model scaling inversion)
  58338. */
  58339. static INVERT_Y: boolean;
  58340. /**
  58341. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  58342. */
  58343. static IMPORT_VERTEX_COLORS: boolean;
  58344. /**
  58345. * Compute the normals for the model, even if normals are present in the file
  58346. */
  58347. static COMPUTE_NORMALS: boolean;
  58348. /**
  58349. * Defines the name of the plugin.
  58350. */
  58351. name: string;
  58352. /**
  58353. * Defines the extension the plugin is able to load.
  58354. */
  58355. extensions: string;
  58356. /** @hidden */
  58357. obj: RegExp;
  58358. /** @hidden */
  58359. group: RegExp;
  58360. /** @hidden */
  58361. mtllib: RegExp;
  58362. /** @hidden */
  58363. usemtl: RegExp;
  58364. /** @hidden */
  58365. smooth: RegExp;
  58366. /** @hidden */
  58367. vertexPattern: RegExp;
  58368. /** @hidden */
  58369. normalPattern: RegExp;
  58370. /** @hidden */
  58371. uvPattern: RegExp;
  58372. /** @hidden */
  58373. facePattern1: RegExp;
  58374. /** @hidden */
  58375. facePattern2: RegExp;
  58376. /** @hidden */
  58377. facePattern3: RegExp;
  58378. /** @hidden */
  58379. facePattern4: RegExp;
  58380. /** @hidden */
  58381. facePattern5: RegExp;
  58382. /**
  58383. * Calls synchronously the MTL file attached to this obj.
  58384. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  58385. * Without this function materials are not displayed in the first frame (but displayed after).
  58386. * In consequence it is impossible to get material information in your HTML file
  58387. *
  58388. * @param url The URL of the MTL file
  58389. * @param rootUrl
  58390. * @param onSuccess Callback function to be called when the MTL file is loaded
  58391. * @private
  58392. */
  58393. private _loadMTL;
  58394. /**
  58395. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  58396. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  58397. * @param scene the scene the meshes should be added to
  58398. * @param data the OBJ data to load
  58399. * @param rootUrl root url to load from
  58400. * @param onProgress event that fires when loading progress has occured
  58401. * @param fileName Defines the name of the file to load
  58402. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  58403. */
  58404. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  58405. meshes: AbstractMesh[];
  58406. particleSystems: IParticleSystem[];
  58407. skeletons: Skeleton[];
  58408. animationGroups: AnimationGroup[];
  58409. }>;
  58410. /**
  58411. * Imports all objects from the loaded OBJ data and adds them to the scene
  58412. * @param scene the scene the objects should be added to
  58413. * @param data the OBJ data to load
  58414. * @param rootUrl root url to load from
  58415. * @param onProgress event that fires when loading progress has occured
  58416. * @param fileName Defines the name of the file to load
  58417. * @returns a promise which completes when objects have been loaded to the scene
  58418. */
  58419. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  58420. /**
  58421. * Load into an asset container.
  58422. * @param scene The scene to load into
  58423. * @param data The data to import
  58424. * @param rootUrl The root url for scene and resources
  58425. * @param onProgress The callback when the load progresses
  58426. * @param fileName Defines the name of the file to load
  58427. * @returns The loaded asset container
  58428. */
  58429. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  58430. /**
  58431. * Read the OBJ file and create an Array of meshes.
  58432. * Each mesh contains all information given by the OBJ and the MTL file.
  58433. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  58434. *
  58435. * @param meshesNames
  58436. * @param scene Scene The scene where are displayed the data
  58437. * @param data String The content of the obj file
  58438. * @param rootUrl String The path to the folder
  58439. * @returns Array<AbstractMesh>
  58440. * @private
  58441. */
  58442. private _parseSolid;
  58443. }
  58444. }
  58445. declare module BABYLON {
  58446. /**
  58447. * STL file type loader.
  58448. * This is a babylon scene loader plugin.
  58449. */
  58450. export class STLFileLoader implements ISceneLoaderPlugin {
  58451. /** @hidden */
  58452. solidPattern: RegExp;
  58453. /** @hidden */
  58454. facetsPattern: RegExp;
  58455. /** @hidden */
  58456. normalPattern: RegExp;
  58457. /** @hidden */
  58458. vertexPattern: RegExp;
  58459. /**
  58460. * Defines the name of the plugin.
  58461. */
  58462. name: string;
  58463. /**
  58464. * Defines the extensions the stl loader is able to load.
  58465. * force data to come in as an ArrayBuffer
  58466. * we'll convert to string if it looks like it's an ASCII .stl
  58467. */
  58468. extensions: ISceneLoaderPluginExtensions;
  58469. /**
  58470. * Import meshes into a scene.
  58471. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  58472. * @param scene The scene to import into
  58473. * @param data The data to import
  58474. * @param rootUrl The root url for scene and resources
  58475. * @param meshes The meshes array to import into
  58476. * @param particleSystems The particle systems array to import into
  58477. * @param skeletons The skeletons array to import into
  58478. * @param onError The callback when import fails
  58479. * @returns True if successful or false otherwise
  58480. */
  58481. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  58482. /**
  58483. * Load into a scene.
  58484. * @param scene The scene to load into
  58485. * @param data The data to import
  58486. * @param rootUrl The root url for scene and resources
  58487. * @param onError The callback when import fails
  58488. * @returns true if successful or false otherwise
  58489. */
  58490. load(scene: Scene, data: any, rootUrl: string): boolean;
  58491. /**
  58492. * Load into an asset container.
  58493. * @param scene The scene to load into
  58494. * @param data The data to import
  58495. * @param rootUrl The root url for scene and resources
  58496. * @param onError The callback when import fails
  58497. * @returns The loaded asset container
  58498. */
  58499. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  58500. private _isBinary;
  58501. private _parseBinary;
  58502. private _parseASCII;
  58503. }
  58504. }
  58505. declare module BABYLON {
  58506. /**
  58507. * Class for generating OBJ data from a Babylon scene.
  58508. */
  58509. export class OBJExport {
  58510. /**
  58511. * Exports the geometry of a Mesh array in .OBJ file format (text)
  58512. * @param mesh defines the list of meshes to serialize
  58513. * @param materials defines if materials should be exported
  58514. * @param matlibname defines the name of the associated mtl file
  58515. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  58516. * @returns the OBJ content
  58517. */
  58518. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  58519. /**
  58520. * Exports the material(s) of a mesh in .MTL file format (text)
  58521. * @param mesh defines the mesh to extract the material from
  58522. * @returns the mtl content
  58523. */
  58524. static MTL(mesh: Mesh): string;
  58525. }
  58526. }
  58527. declare module BABYLON {
  58528. /** @hidden */
  58529. export var __IGLTFExporterExtension: number;
  58530. /**
  58531. * Interface for extending the exporter
  58532. * @hidden
  58533. */
  58534. export interface IGLTFExporterExtension {
  58535. /**
  58536. * The name of this extension
  58537. */
  58538. readonly name: string;
  58539. /**
  58540. * Defines whether this extension is enabled
  58541. */
  58542. enabled: boolean;
  58543. /**
  58544. * Defines whether this extension is required
  58545. */
  58546. required: boolean;
  58547. }
  58548. }
  58549. declare module BABYLON.GLTF2.Exporter {
  58550. /** @hidden */
  58551. export var __IGLTFExporterExtensionV2: number;
  58552. /**
  58553. * Interface for a glTF exporter extension
  58554. * @hidden
  58555. */
  58556. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  58557. /**
  58558. * Define this method to modify the default behavior before exporting a texture
  58559. * @param context The context when loading the asset
  58560. * @param babylonTexture The glTF texture info property
  58561. * @param mimeType The mime-type of the generated image
  58562. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  58563. */
  58564. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  58565. /**
  58566. * Define this method to modify the default behavior when exporting texture info
  58567. * @param context The context when loading the asset
  58568. * @param meshPrimitive glTF mesh primitive
  58569. * @param babylonSubMesh Babylon submesh
  58570. * @param binaryWriter glTF serializer binary writer instance
  58571. * @returns nullable IMeshPrimitive promise
  58572. */
  58573. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  58574. /**
  58575. * Define this method to modify the default behavior when exporting a node
  58576. * @param context The context when exporting the node
  58577. * @param node glTF node
  58578. * @param babylonNode BabylonJS node
  58579. * @returns nullable INode promise
  58580. */
  58581. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  58582. /**
  58583. * Called after the exporter state changes to EXPORTING
  58584. */
  58585. onExporting?(): void;
  58586. }
  58587. }
  58588. declare module BABYLON.GLTF2.Exporter {
  58589. /**
  58590. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  58591. * @hidden
  58592. */
  58593. export class _GLTFMaterialExporter {
  58594. /**
  58595. * Represents the dielectric specular values for R, G and B
  58596. */
  58597. private static readonly _DielectricSpecular;
  58598. /**
  58599. * Allows the maximum specular power to be defined for material calculations
  58600. */
  58601. private static readonly _MaxSpecularPower;
  58602. /**
  58603. * Mapping to store textures
  58604. */
  58605. private _textureMap;
  58606. /**
  58607. * Numeric tolerance value
  58608. */
  58609. private static readonly _Epsilon;
  58610. /**
  58611. * Reference to the glTF Exporter
  58612. */
  58613. private _exporter;
  58614. constructor(exporter: _Exporter);
  58615. /**
  58616. * Specifies if two colors are approximately equal in value
  58617. * @param color1 first color to compare to
  58618. * @param color2 second color to compare to
  58619. * @param epsilon threshold value
  58620. */
  58621. private static FuzzyEquals;
  58622. /**
  58623. * Gets the materials from a Babylon scene and converts them to glTF materials
  58624. * @param scene babylonjs scene
  58625. * @param mimeType texture mime type
  58626. * @param images array of images
  58627. * @param textures array of textures
  58628. * @param materials array of materials
  58629. * @param imageData mapping of texture names to base64 textures
  58630. * @param hasTextureCoords specifies if texture coordinates are present on the material
  58631. */ convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  58632. /**
  58633. * Makes a copy of the glTF material without the texture parameters
  58634. * @param originalMaterial original glTF material
  58635. * @returns glTF material without texture parameters
  58636. */ stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  58637. /**
  58638. * Specifies if the material has any texture parameters present
  58639. * @param material glTF Material
  58640. * @returns boolean specifying if texture parameters are present
  58641. */ hasTexturesPresent(material: IMaterial): boolean;
  58642. /**
  58643. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  58644. * @param babylonStandardMaterial
  58645. * @returns glTF Metallic Roughness Material representation
  58646. */ convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  58647. /**
  58648. * Computes the metallic factor
  58649. * @param diffuse diffused value
  58650. * @param specular specular value
  58651. * @param oneMinusSpecularStrength one minus the specular strength
  58652. * @returns metallic value
  58653. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  58654. /**
  58655. * Gets the glTF alpha mode from the Babylon Material
  58656. * @param babylonMaterial Babylon Material
  58657. * @returns The Babylon alpha mode value
  58658. */ getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  58659. /**
  58660. * Converts a Babylon Standard Material to a glTF Material
  58661. * @param babylonStandardMaterial BJS Standard Material
  58662. * @param mimeType mime type to use for the textures
  58663. * @param images array of glTF image interfaces
  58664. * @param textures array of glTF texture interfaces
  58665. * @param materials array of glTF material interfaces
  58666. * @param imageData map of image file name to data
  58667. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58668. */ convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  58669. /**
  58670. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  58671. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  58672. * @param mimeType mime type to use for the textures
  58673. * @param images array of glTF image interfaces
  58674. * @param textures array of glTF texture interfaces
  58675. * @param materials array of glTF material interfaces
  58676. * @param imageData map of image file name to data
  58677. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58678. */ convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  58679. /**
  58680. * Converts an image typed array buffer to a base64 image
  58681. * @param buffer typed array buffer
  58682. * @param width width of the image
  58683. * @param height height of the image
  58684. * @param mimeType mimetype of the image
  58685. * @returns base64 image string
  58686. */
  58687. private _createBase64FromCanvasAsync;
  58688. /**
  58689. * Generates a white texture based on the specified width and height
  58690. * @param width width of the texture in pixels
  58691. * @param height height of the texture in pixels
  58692. * @param scene babylonjs scene
  58693. * @returns white texture
  58694. */
  58695. private _createWhiteTexture;
  58696. /**
  58697. * 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
  58698. * @param texture1 first texture to resize
  58699. * @param texture2 second texture to resize
  58700. * @param scene babylonjs scene
  58701. * @returns resized textures or null
  58702. */
  58703. private _resizeTexturesToSameDimensions;
  58704. /**
  58705. * Converts an array of pixels to a Float32Array
  58706. * Throws an error if the pixel format is not supported
  58707. * @param pixels - array buffer containing pixel values
  58708. * @returns Float32 of pixels
  58709. */
  58710. private _convertPixelArrayToFloat32;
  58711. /**
  58712. * Convert Specular Glossiness Textures to Metallic Roughness
  58713. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  58714. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  58715. * @param diffuseTexture texture used to store diffuse information
  58716. * @param specularGlossinessTexture texture used to store specular and glossiness information
  58717. * @param factors specular glossiness material factors
  58718. * @param mimeType the mime type to use for the texture
  58719. * @returns pbr metallic roughness interface or null
  58720. */
  58721. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  58722. /**
  58723. * Converts specular glossiness material properties to metallic roughness
  58724. * @param specularGlossiness interface with specular glossiness material properties
  58725. * @returns interface with metallic roughness material properties
  58726. */
  58727. private _convertSpecularGlossinessToMetallicRoughness;
  58728. /**
  58729. * Calculates the surface reflectance, independent of lighting conditions
  58730. * @param color Color source to calculate brightness from
  58731. * @returns number representing the perceived brightness, or zero if color is undefined
  58732. */
  58733. private _getPerceivedBrightness;
  58734. /**
  58735. * Returns the maximum color component value
  58736. * @param color
  58737. * @returns maximum color component value, or zero if color is null or undefined
  58738. */
  58739. private _getMaxComponent;
  58740. /**
  58741. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  58742. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  58743. * @param mimeType mime type to use for the textures
  58744. * @param images array of glTF image interfaces
  58745. * @param textures array of glTF texture interfaces
  58746. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  58747. * @param imageData map of image file name to data
  58748. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58749. * @returns glTF PBR Metallic Roughness factors
  58750. */
  58751. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  58752. private _getGLTFTextureSampler;
  58753. private _getGLTFTextureWrapMode;
  58754. private _getGLTFTextureWrapModesSampler;
  58755. /**
  58756. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  58757. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  58758. * @param mimeType mime type to use for the textures
  58759. * @param images array of glTF image interfaces
  58760. * @param textures array of glTF texture interfaces
  58761. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  58762. * @param imageData map of image file name to data
  58763. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58764. * @returns glTF PBR Metallic Roughness factors
  58765. */
  58766. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  58767. /**
  58768. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  58769. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  58770. * @param mimeType mime type to use for the textures
  58771. * @param images array of glTF image interfaces
  58772. * @param textures array of glTF texture interfaces
  58773. * @param materials array of glTF material interfaces
  58774. * @param imageData map of image file name to data
  58775. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58776. */ convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  58777. private setMetallicRoughnessPbrMaterial;
  58778. private getPixelsFromTexture;
  58779. /**
  58780. * Extracts a texture from a Babylon texture into file data and glTF data
  58781. * @param babylonTexture Babylon texture to extract
  58782. * @param mimeType Mime Type of the babylonTexture
  58783. * @return glTF texture info, or null if the texture format is not supported
  58784. */ exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  58785. /**
  58786. * Builds a texture from base64 string
  58787. * @param base64Texture base64 texture string
  58788. * @param baseTextureName Name to use for the texture
  58789. * @param mimeType image mime type for the texture
  58790. * @param images array of images
  58791. * @param textures array of textures
  58792. * @param imageData map of image data
  58793. * @returns glTF texture info, or null if the texture format is not supported
  58794. */
  58795. private _getTextureInfoFromBase64;
  58796. }
  58797. }
  58798. declare module BABYLON {
  58799. /**
  58800. * Class for holding and downloading glTF file data
  58801. */
  58802. export class GLTFData {
  58803. /**
  58804. * Object which contains the file name as the key and its data as the value
  58805. */
  58806. glTFFiles: {
  58807. [fileName: string]: string | Blob;
  58808. };
  58809. /**
  58810. * Initializes the glTF file object
  58811. */
  58812. constructor();
  58813. /**
  58814. * Downloads the glTF data as files based on their names and data
  58815. */
  58816. downloadFiles(): void;
  58817. }
  58818. }
  58819. declare module BABYLON {
  58820. /**
  58821. * Holds a collection of exporter options and parameters
  58822. */
  58823. export interface IExportOptions {
  58824. /**
  58825. * Function which indicates whether a babylon node should be exported or not
  58826. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  58827. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  58828. */
  58829. shouldExportNode?(node: Node): boolean;
  58830. /**
  58831. * The sample rate to bake animation curves
  58832. */
  58833. animationSampleRate?: number;
  58834. /**
  58835. * Begin serialization without waiting for the scene to be ready
  58836. */
  58837. exportWithoutWaitingForScene?: boolean;
  58838. }
  58839. /**
  58840. * Class for generating glTF data from a Babylon scene.
  58841. */
  58842. export class GLTF2Export {
  58843. /**
  58844. * Exports the geometry of the scene to .gltf file format asynchronously
  58845. * @param scene Babylon scene with scene hierarchy information
  58846. * @param filePrefix File prefix to use when generating the glTF file
  58847. * @param options Exporter options
  58848. * @returns Returns an object with a .gltf file and associates texture names
  58849. * as keys and their data and paths as values
  58850. */
  58851. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  58852. private static _PreExportAsync;
  58853. private static _PostExportAsync;
  58854. /**
  58855. * Exports the geometry of the scene to .glb file format asychronously
  58856. * @param scene Babylon scene with scene hierarchy information
  58857. * @param filePrefix File prefix to use when generating glb file
  58858. * @param options Exporter options
  58859. * @returns Returns an object with a .glb filename as key and data as value
  58860. */
  58861. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  58862. }
  58863. }
  58864. declare module BABYLON.GLTF2.Exporter {
  58865. /**
  58866. * @hidden
  58867. */
  58868. export class _GLTFUtilities {
  58869. /**
  58870. * Creates a buffer view based on the supplied arguments
  58871. * @param bufferIndex index value of the specified buffer
  58872. * @param byteOffset byte offset value
  58873. * @param byteLength byte length of the bufferView
  58874. * @param byteStride byte distance between conequential elements
  58875. * @param name name of the buffer view
  58876. * @returns bufferView for glTF
  58877. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  58878. /**
  58879. * Creates an accessor based on the supplied arguments
  58880. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  58881. * @param name The name of the accessor
  58882. * @param type The type of the accessor
  58883. * @param componentType The datatype of components in the attribute
  58884. * @param count The number of attributes referenced by this accessor
  58885. * @param byteOffset The offset relative to the start of the bufferView in bytes
  58886. * @param min Minimum value of each component in this attribute
  58887. * @param max Maximum value of each component in this attribute
  58888. * @returns accessor for glTF
  58889. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  58890. /**
  58891. * Calculates the minimum and maximum values of an array of position floats
  58892. * @param positions Positions array of a mesh
  58893. * @param vertexStart Starting vertex offset to calculate min and max values
  58894. * @param vertexCount Number of vertices to check for min and max values
  58895. * @returns min number array and max number array
  58896. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  58897. min: number[];
  58898. max: number[];
  58899. };
  58900. /**
  58901. * Converts a new right-handed Vector3
  58902. * @param vector vector3 array
  58903. * @returns right-handed Vector3
  58904. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  58905. /**
  58906. * Converts a Vector3 to right-handed
  58907. * @param vector Vector3 to convert to right-handed
  58908. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  58909. /**
  58910. * Converts a three element number array to right-handed
  58911. * @param vector number array to convert to right-handed
  58912. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  58913. /**
  58914. * Converts a new right-handed Vector3
  58915. * @param vector vector3 array
  58916. * @returns right-handed Vector3
  58917. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  58918. /**
  58919. * Converts a Vector3 to right-handed
  58920. * @param vector Vector3 to convert to right-handed
  58921. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  58922. /**
  58923. * Converts a three element number array to right-handed
  58924. * @param vector number array to convert to right-handed
  58925. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  58926. /**
  58927. * Converts a Vector4 to right-handed
  58928. * @param vector Vector4 to convert to right-handed
  58929. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  58930. /**
  58931. * Converts a Vector4 to right-handed
  58932. * @param vector Vector4 to convert to right-handed
  58933. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  58934. /**
  58935. * Converts a Quaternion to right-handed
  58936. * @param quaternion Source quaternion to convert to right-handed
  58937. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  58938. /**
  58939. * Converts a Quaternion to right-handed
  58940. * @param quaternion Source quaternion to convert to right-handed
  58941. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  58942. }
  58943. }
  58944. declare module BABYLON.GLTF2.Exporter {
  58945. /**
  58946. * Converts Babylon Scene into glTF 2.0.
  58947. * @hidden
  58948. */
  58949. export class _Exporter {
  58950. /**
  58951. * Stores the glTF to export
  58952. */ glTF: IGLTF;
  58953. /**
  58954. * Stores all generated buffer views, which represents views into the main glTF buffer data
  58955. */ bufferViews: IBufferView[];
  58956. /**
  58957. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  58958. */ accessors: IAccessor[];
  58959. /**
  58960. * Stores all the generated nodes, which contains transform and/or mesh information per node
  58961. */
  58962. private _nodes;
  58963. /**
  58964. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  58965. */
  58966. private _scenes;
  58967. /**
  58968. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  58969. */
  58970. private _meshes;
  58971. /**
  58972. * Stores all the generated material information, which represents the appearance of each primitive
  58973. */ materials: IMaterial[]; materialMap: {
  58974. [materialID: number]: number;
  58975. };
  58976. /**
  58977. * Stores all the generated texture information, which is referenced by glTF materials
  58978. */ textures: ITexture[];
  58979. /**
  58980. * Stores all the generated image information, which is referenced by glTF textures
  58981. */ images: IImage[];
  58982. /**
  58983. * Stores all the texture samplers
  58984. */ samplers: ISampler[];
  58985. /**
  58986. * Stores all the generated animation samplers, which is referenced by glTF animations
  58987. */
  58988. /**
  58989. * Stores the animations for glTF models
  58990. */
  58991. private _animations;
  58992. /**
  58993. * Stores the total amount of bytes stored in the glTF buffer
  58994. */
  58995. private _totalByteLength;
  58996. /**
  58997. * Stores a reference to the Babylon scene containing the source geometry and material information
  58998. */ babylonScene: Scene;
  58999. /**
  59000. * Stores a map of the image data, where the key is the file name and the value
  59001. * is the image data
  59002. */ imageData: {
  59003. [fileName: string]: {
  59004. data: Uint8Array;
  59005. mimeType: ImageMimeType;
  59006. };
  59007. };
  59008. /**
  59009. * Stores a map of the unique id of a node to its index in the node array
  59010. */
  59011. private _nodeMap;
  59012. /**
  59013. * Specifies if the Babylon scene should be converted to right-handed on export
  59014. */ convertToRightHandedSystem: boolean;
  59015. /**
  59016. * Baked animation sample rate
  59017. */
  59018. private _animationSampleRate;
  59019. /**
  59020. * Callback which specifies if a node should be exported or not
  59021. */
  59022. private _shouldExportNode;
  59023. private _localEngine; glTFMaterialExporter: _GLTFMaterialExporter;
  59024. private _extensions;
  59025. private static _ExtensionNames;
  59026. private static _ExtensionFactories;
  59027. private _applyExtensions; extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  59028. private _forEachExtensions;
  59029. private _extensionsOnExporting;
  59030. /**
  59031. * Load glTF serializer extensions
  59032. */
  59033. private _loadExtensions;
  59034. /**
  59035. * Creates a glTF Exporter instance, which can accept optional exporter options
  59036. * @param babylonScene Babylon scene object
  59037. * @param options Options to modify the behavior of the exporter
  59038. */
  59039. constructor(babylonScene: Scene, options?: IExportOptions);
  59040. /**
  59041. * Registers a glTF exporter extension
  59042. * @param name Name of the extension to export
  59043. * @param factory The factory function that creates the exporter extension
  59044. */
  59045. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  59046. /**
  59047. * Un-registers an exporter extension
  59048. * @param name The name fo the exporter extension
  59049. * @returns A boolean indicating whether the extension has been un-registered
  59050. */
  59051. static UnregisterExtension(name: string): boolean;
  59052. /**
  59053. * Lazy load a local engine with premultiplied alpha set to false
  59054. */ getLocalEngine(): Engine;
  59055. private reorderIndicesBasedOnPrimitiveMode;
  59056. /**
  59057. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  59058. * clock-wise during export to glTF
  59059. * @param submesh BabylonJS submesh
  59060. * @param primitiveMode Primitive mode of the mesh
  59061. * @param sideOrientation the winding order of the submesh
  59062. * @param vertexBufferKind The type of vertex attribute
  59063. * @param meshAttributeArray The vertex attribute data
  59064. * @param byteOffset The offset to the binary data
  59065. * @param binaryWriter The binary data for the glTF file
  59066. */
  59067. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  59068. /**
  59069. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  59070. * clock-wise during export to glTF
  59071. * @param submesh BabylonJS submesh
  59072. * @param primitiveMode Primitive mode of the mesh
  59073. * @param sideOrientation the winding order of the submesh
  59074. * @param vertexBufferKind The type of vertex attribute
  59075. * @param meshAttributeArray The vertex attribute data
  59076. * @param byteOffset The offset to the binary data
  59077. * @param binaryWriter The binary data for the glTF file
  59078. */
  59079. private reorderTriangleFillMode;
  59080. /**
  59081. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  59082. * clock-wise during export to glTF
  59083. * @param submesh BabylonJS submesh
  59084. * @param primitiveMode Primitive mode of the mesh
  59085. * @param sideOrientation the winding order of the submesh
  59086. * @param vertexBufferKind The type of vertex attribute
  59087. * @param meshAttributeArray The vertex attribute data
  59088. * @param byteOffset The offset to the binary data
  59089. * @param binaryWriter The binary data for the glTF file
  59090. */
  59091. private reorderTriangleStripDrawMode;
  59092. /**
  59093. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  59094. * clock-wise during export to glTF
  59095. * @param submesh BabylonJS submesh
  59096. * @param primitiveMode Primitive mode of the mesh
  59097. * @param sideOrientation the winding order of the submesh
  59098. * @param vertexBufferKind The type of vertex attribute
  59099. * @param meshAttributeArray The vertex attribute data
  59100. * @param byteOffset The offset to the binary data
  59101. * @param binaryWriter The binary data for the glTF file
  59102. */
  59103. private reorderTriangleFanMode;
  59104. /**
  59105. * Writes the vertex attribute data to binary
  59106. * @param vertices The vertices to write to the binary writer
  59107. * @param byteOffset The offset into the binary writer to overwrite binary data
  59108. * @param vertexAttributeKind The vertex attribute type
  59109. * @param meshAttributeArray The vertex attribute data
  59110. * @param binaryWriter The writer containing the binary data
  59111. */
  59112. private writeVertexAttributeData;
  59113. /**
  59114. * Writes mesh attribute data to a data buffer
  59115. * Returns the bytelength of the data
  59116. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  59117. * @param meshAttributeArray Array containing the attribute data
  59118. * @param binaryWriter The buffer to write the binary data to
  59119. * @param indices Used to specify the order of the vertex data
  59120. */
  59121. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  59122. /**
  59123. * Generates glTF json data
  59124. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  59125. * @param glTFPrefix Text to use when prefixing a glTF file
  59126. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  59127. * @returns json data as string
  59128. */
  59129. private generateJSON;
  59130. /**
  59131. * Generates data for .gltf and .bin files based on the glTF prefix string
  59132. * @param glTFPrefix Text to use when prefixing a glTF file
  59133. * @returns GLTFData with glTF file data
  59134. */ generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  59135. /**
  59136. * Creates a binary buffer for glTF
  59137. * @returns array buffer for binary data
  59138. */
  59139. private _generateBinaryAsync;
  59140. /**
  59141. * Pads the number to a multiple of 4
  59142. * @param num number to pad
  59143. * @returns padded number
  59144. */
  59145. private _getPadding;
  59146. /**
  59147. * Generates a glb file from the json and binary data
  59148. * Returns an object with the glb file name as the key and data as the value
  59149. * @param glTFPrefix
  59150. * @returns object with glb filename as key and data as value
  59151. */ generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  59152. /**
  59153. * Sets the TRS for each node
  59154. * @param node glTF Node for storing the transformation data
  59155. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  59156. */
  59157. private setNodeTransformation;
  59158. private getVertexBufferFromMesh;
  59159. /**
  59160. * Creates a bufferview based on the vertices type for the Babylon mesh
  59161. * @param kind Indicates the type of vertices data
  59162. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  59163. * @param binaryWriter The buffer to write the bufferview data to
  59164. */
  59165. private createBufferViewKind;
  59166. /**
  59167. * The primitive mode of the Babylon mesh
  59168. * @param babylonMesh The BabylonJS mesh
  59169. */
  59170. private getMeshPrimitiveMode;
  59171. /**
  59172. * Sets the primitive mode of the glTF mesh primitive
  59173. * @param meshPrimitive glTF mesh primitive
  59174. * @param primitiveMode The primitive mode
  59175. */
  59176. private setPrimitiveMode;
  59177. /**
  59178. * Sets the vertex attribute accessor based of the glTF mesh primitive
  59179. * @param meshPrimitive glTF mesh primitive
  59180. * @param attributeKind vertex attribute
  59181. * @returns boolean specifying if uv coordinates are present
  59182. */
  59183. private setAttributeKind;
  59184. /**
  59185. * Sets data for the primitive attributes of each submesh
  59186. * @param mesh glTF Mesh object to store the primitive attribute information
  59187. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  59188. * @param binaryWriter Buffer to write the attribute data to
  59189. */
  59190. private setPrimitiveAttributesAsync;
  59191. /**
  59192. * Creates a glTF scene based on the array of meshes
  59193. * Returns the the total byte offset
  59194. * @param babylonScene Babylon scene to get the mesh data from
  59195. * @param binaryWriter Buffer to write binary data to
  59196. */
  59197. private createSceneAsync;
  59198. /**
  59199. * Creates a mapping of Node unique id to node index and handles animations
  59200. * @param babylonScene Babylon Scene
  59201. * @param nodes Babylon transform nodes
  59202. * @param shouldExportNode Callback specifying if a transform node should be exported
  59203. * @param binaryWriter Buffer to write binary data to
  59204. * @returns Node mapping of unique id to index
  59205. */
  59206. private createNodeMapAndAnimationsAsync;
  59207. /**
  59208. * Creates a glTF node from a Babylon mesh
  59209. * @param babylonMesh Source Babylon mesh
  59210. * @param binaryWriter Buffer for storing geometry data
  59211. * @returns glTF node
  59212. */
  59213. private createNodeAsync;
  59214. }
  59215. /**
  59216. * @hidden
  59217. *
  59218. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  59219. */
  59220. export class _BinaryWriter {
  59221. /**
  59222. * Array buffer which stores all binary data
  59223. */
  59224. private _arrayBuffer;
  59225. /**
  59226. * View of the array buffer
  59227. */
  59228. private _dataView;
  59229. /**
  59230. * byte offset of data in array buffer
  59231. */
  59232. private _byteOffset;
  59233. /**
  59234. * Initialize binary writer with an initial byte length
  59235. * @param byteLength Initial byte length of the array buffer
  59236. */
  59237. constructor(byteLength: number);
  59238. /**
  59239. * Resize the array buffer to the specified byte length
  59240. * @param byteLength
  59241. */
  59242. private resizeBuffer;
  59243. /**
  59244. * Get an array buffer with the length of the byte offset
  59245. * @returns ArrayBuffer resized to the byte offset
  59246. */
  59247. getArrayBuffer(): ArrayBuffer;
  59248. /**
  59249. * Get the byte offset of the array buffer
  59250. * @returns byte offset
  59251. */
  59252. getByteOffset(): number;
  59253. /**
  59254. * Stores an UInt8 in the array buffer
  59255. * @param entry
  59256. * @param byteOffset If defined, specifies where to set the value as an offset.
  59257. */
  59258. setUInt8(entry: number, byteOffset?: number): void;
  59259. /**
  59260. * Gets an UInt32 in the array buffer
  59261. * @param entry
  59262. * @param byteOffset If defined, specifies where to set the value as an offset.
  59263. */
  59264. getUInt32(byteOffset: number): number;
  59265. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  59266. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  59267. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  59268. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  59269. /**
  59270. * Stores a Float32 in the array buffer
  59271. * @param entry
  59272. */
  59273. setFloat32(entry: number, byteOffset?: number): void;
  59274. /**
  59275. * Stores an UInt32 in the array buffer
  59276. * @param entry
  59277. * @param byteOffset If defined, specifies where to set the value as an offset.
  59278. */
  59279. setUInt32(entry: number, byteOffset?: number): void;
  59280. }
  59281. }
  59282. declare module BABYLON.GLTF2.Exporter {
  59283. /**
  59284. * @hidden
  59285. * Interface to store animation data.
  59286. */
  59287. export interface _IAnimationData {
  59288. /**
  59289. * Keyframe data.
  59290. */
  59291. inputs: number[];
  59292. /**
  59293. * Value data.
  59294. */
  59295. outputs: number[][];
  59296. /**
  59297. * Animation interpolation data.
  59298. */
  59299. samplerInterpolation: AnimationSamplerInterpolation;
  59300. /**
  59301. * Minimum keyframe value.
  59302. */
  59303. inputsMin: number;
  59304. /**
  59305. * Maximum keyframe value.
  59306. */
  59307. inputsMax: number;
  59308. }
  59309. /**
  59310. * @hidden
  59311. */
  59312. export interface _IAnimationInfo {
  59313. /**
  59314. * The target channel for the animation
  59315. */
  59316. animationChannelTargetPath: AnimationChannelTargetPath;
  59317. /**
  59318. * The glTF accessor type for the data.
  59319. */
  59320. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  59321. /**
  59322. * Specifies if quaternions should be used.
  59323. */
  59324. useQuaternion: boolean;
  59325. }
  59326. /**
  59327. * @hidden
  59328. * Utility class for generating glTF animation data from BabylonJS.
  59329. */
  59330. export class _GLTFAnimation {
  59331. /**
  59332. * @ignore
  59333. *
  59334. * Creates glTF channel animation from BabylonJS animation.
  59335. * @param babylonTransformNode - BabylonJS mesh.
  59336. * @param animation - animation.
  59337. * @param animationChannelTargetPath - The target animation channel.
  59338. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  59339. * @param useQuaternion - Specifies if quaternions are used.
  59340. * @returns nullable IAnimationData
  59341. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  59342. private static _DeduceAnimationInfo;
  59343. /**
  59344. * @ignore
  59345. * Create node animations from the transform node animations
  59346. * @param babylonNode
  59347. * @param runtimeGLTFAnimation
  59348. * @param idleGLTFAnimations
  59349. * @param nodeMap
  59350. * @param nodes
  59351. * @param binaryWriter
  59352. * @param bufferViews
  59353. * @param accessors
  59354. * @param convertToRightHandedSystem
  59355. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  59356. [key: number]: number;
  59357. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  59358. /**
  59359. * @ignore
  59360. * Create node animations from the animation groups
  59361. * @param babylonScene
  59362. * @param glTFAnimations
  59363. * @param nodeMap
  59364. * @param nodes
  59365. * @param binaryWriter
  59366. * @param bufferViews
  59367. * @param accessors
  59368. * @param convertToRightHandedSystem
  59369. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  59370. [key: number]: number;
  59371. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  59372. private static AddAnimation;
  59373. /**
  59374. * Create a baked animation
  59375. * @param babylonTransformNode BabylonJS mesh
  59376. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  59377. * @param animationChannelTargetPath animation target channel
  59378. * @param minFrame minimum animation frame
  59379. * @param maxFrame maximum animation frame
  59380. * @param fps frames per second of the animation
  59381. * @param inputs input key frames of the animation
  59382. * @param outputs output key frame data of the animation
  59383. * @param convertToRightHandedSystem converts the values to right-handed
  59384. * @param useQuaternion specifies if quaternions should be used
  59385. */
  59386. private static _CreateBakedAnimation;
  59387. private static _ConvertFactorToVector3OrQuaternion;
  59388. private static _SetInterpolatedValue;
  59389. /**
  59390. * Creates linear animation from the animation key frames
  59391. * @param babylonTransformNode BabylonJS mesh
  59392. * @param animation BabylonJS animation
  59393. * @param animationChannelTargetPath The target animation channel
  59394. * @param frameDelta The difference between the last and first frame of the animation
  59395. * @param inputs Array to store the key frame times
  59396. * @param outputs Array to store the key frame data
  59397. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  59398. * @param useQuaternion Specifies if quaternions are used in the animation
  59399. */
  59400. private static _CreateLinearOrStepAnimation;
  59401. /**
  59402. * Creates cubic spline animation from the animation key frames
  59403. * @param babylonTransformNode BabylonJS mesh
  59404. * @param animation BabylonJS animation
  59405. * @param animationChannelTargetPath The target animation channel
  59406. * @param frameDelta The difference between the last and first frame of the animation
  59407. * @param inputs Array to store the key frame times
  59408. * @param outputs Array to store the key frame data
  59409. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  59410. * @param useQuaternion Specifies if quaternions are used in the animation
  59411. */
  59412. private static _CreateCubicSplineAnimation;
  59413. private static _GetBasePositionRotationOrScale;
  59414. /**
  59415. * Adds a key frame value
  59416. * @param keyFrame
  59417. * @param animation
  59418. * @param outputs
  59419. * @param animationChannelTargetPath
  59420. * @param basePositionRotationOrScale
  59421. * @param convertToRightHandedSystem
  59422. * @param useQuaternion
  59423. */
  59424. private static _AddKeyframeValue;
  59425. /**
  59426. * Determine the interpolation based on the key frames
  59427. * @param keyFrames
  59428. * @param animationChannelTargetPath
  59429. * @param useQuaternion
  59430. */
  59431. private static _DeduceInterpolation;
  59432. /**
  59433. * Adds an input tangent or output tangent to the output data
  59434. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  59435. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  59436. * @param outputs The animation data by keyframe
  59437. * @param animationChannelTargetPath The target animation channel
  59438. * @param interpolation The interpolation type
  59439. * @param keyFrame The key frame with the animation data
  59440. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  59441. * @param useQuaternion Specifies if quaternions are used
  59442. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  59443. */
  59444. private static AddSplineTangent;
  59445. /**
  59446. * Get the minimum and maximum key frames' frame values
  59447. * @param keyFrames animation key frames
  59448. * @returns the minimum and maximum key frame value
  59449. */
  59450. private static calculateMinMaxKeyFrames;
  59451. }
  59452. }
  59453. declare module BABYLON.GLTF2.Exporter {
  59454. /** @hidden */
  59455. export var textureTransformPixelShader: {
  59456. name: string;
  59457. shader: string;
  59458. };
  59459. }
  59460. declare module BABYLON.GLTF2.Exporter.Extensions {
  59461. /**
  59462. * @hidden
  59463. */
  59464. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  59465. /** Name of this extension */
  59466. readonly name: string;
  59467. /** Defines whether this extension is enabled */
  59468. enabled: boolean;
  59469. /** Defines whether this extension is required */
  59470. required: boolean;
  59471. /** Reference to the glTF exporter */
  59472. private _exporter;
  59473. constructor(exporter: _Exporter);
  59474. dispose(): void;
  59475. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  59476. /**
  59477. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  59478. * @param babylonTexture
  59479. * @param offset
  59480. * @param rotation
  59481. * @param scale
  59482. * @param scene
  59483. */
  59484. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  59485. }
  59486. }
  59487. declare module BABYLON.GLTF2.Exporter.Extensions {
  59488. /**
  59489. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  59490. */
  59491. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  59492. /** The name of this extension. */
  59493. readonly name: string;
  59494. /** Defines whether this extension is enabled. */
  59495. enabled: boolean;
  59496. /** Defines whether this extension is required */
  59497. required: boolean;
  59498. /** Reference to the glTF exporter */
  59499. private _exporter;
  59500. private _lights;
  59501. /** @hidden */
  59502. constructor(exporter: _Exporter);
  59503. /** @hidden */
  59504. dispose(): void;
  59505. /** @hidden */
  59506. onExporting(): void;
  59507. /**
  59508. * Define this method to modify the default behavior when exporting a node
  59509. * @param context The context when exporting the node
  59510. * @param node glTF node
  59511. * @param babylonNode BabylonJS node
  59512. * @returns nullable INode promise
  59513. */
  59514. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  59515. }
  59516. }
  59517. /**
  59518. * @ignoreChildren
  59519. * @ignore
  59520. */
  59521. declare module "babylonjs-gltf2interface" {
  59522. export = BABYLON.GLTF2;
  59523. }
  59524. /**
  59525. * Module for glTF 2.0 Interface
  59526. * @ignoreChildren
  59527. * @ignore
  59528. */
  59529. declare module BABYLON.GLTF2 {
  59530. /**
  59531. * The datatype of the components in the attribute
  59532. */
  59533. const enum AccessorComponentType {
  59534. /**
  59535. * Byte
  59536. */
  59537. BYTE = 5120,
  59538. /**
  59539. * Unsigned Byte
  59540. */
  59541. UNSIGNED_BYTE = 5121,
  59542. /**
  59543. * Short
  59544. */
  59545. SHORT = 5122,
  59546. /**
  59547. * Unsigned Short
  59548. */
  59549. UNSIGNED_SHORT = 5123,
  59550. /**
  59551. * Unsigned Int
  59552. */
  59553. UNSIGNED_INT = 5125,
  59554. /**
  59555. * Float
  59556. */
  59557. FLOAT = 5126,
  59558. }
  59559. /**
  59560. * Specifies if the attirbute is a scalar, vector, or matrix
  59561. */
  59562. const enum AccessorType {
  59563. /**
  59564. * Scalar
  59565. */
  59566. SCALAR = "SCALAR",
  59567. /**
  59568. * Vector2
  59569. */
  59570. VEC2 = "VEC2",
  59571. /**
  59572. * Vector3
  59573. */
  59574. VEC3 = "VEC3",
  59575. /**
  59576. * Vector4
  59577. */
  59578. VEC4 = "VEC4",
  59579. /**
  59580. * Matrix2x2
  59581. */
  59582. MAT2 = "MAT2",
  59583. /**
  59584. * Matrix3x3
  59585. */
  59586. MAT3 = "MAT3",
  59587. /**
  59588. * Matrix4x4
  59589. */
  59590. MAT4 = "MAT4",
  59591. }
  59592. /**
  59593. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  59594. */
  59595. const enum AnimationChannelTargetPath {
  59596. /**
  59597. * Translation
  59598. */
  59599. TRANSLATION = "translation",
  59600. /**
  59601. * Rotation
  59602. */
  59603. ROTATION = "rotation",
  59604. /**
  59605. * Scale
  59606. */
  59607. SCALE = "scale",
  59608. /**
  59609. * Weights
  59610. */
  59611. WEIGHTS = "weights",
  59612. }
  59613. /**
  59614. * Interpolation algorithm
  59615. */
  59616. const enum AnimationSamplerInterpolation {
  59617. /**
  59618. * The animated values are linearly interpolated between keyframes
  59619. */
  59620. LINEAR = "LINEAR",
  59621. /**
  59622. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  59623. */
  59624. STEP = "STEP",
  59625. /**
  59626. * The animation's interpolation is computed using a cubic spline with specified tangents
  59627. */
  59628. CUBICSPLINE = "CUBICSPLINE",
  59629. }
  59630. /**
  59631. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  59632. */
  59633. const enum CameraType {
  59634. /**
  59635. * A perspective camera containing properties to create a perspective projection matrix
  59636. */
  59637. PERSPECTIVE = "perspective",
  59638. /**
  59639. * An orthographic camera containing properties to create an orthographic projection matrix
  59640. */
  59641. ORTHOGRAPHIC = "orthographic",
  59642. }
  59643. /**
  59644. * The mime-type of the image
  59645. */
  59646. const enum ImageMimeType {
  59647. /**
  59648. * JPEG Mime-type
  59649. */
  59650. JPEG = "image/jpeg",
  59651. /**
  59652. * PNG Mime-type
  59653. */
  59654. PNG = "image/png",
  59655. }
  59656. /**
  59657. * The alpha rendering mode of the material
  59658. */
  59659. const enum MaterialAlphaMode {
  59660. /**
  59661. * The alpha value is ignored and the rendered output is fully opaque
  59662. */
  59663. OPAQUE = "OPAQUE",
  59664. /**
  59665. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  59666. */
  59667. MASK = "MASK",
  59668. /**
  59669. * 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)
  59670. */
  59671. BLEND = "BLEND",
  59672. }
  59673. /**
  59674. * The type of the primitives to render
  59675. */
  59676. const enum MeshPrimitiveMode {
  59677. /**
  59678. * Points
  59679. */
  59680. POINTS = 0,
  59681. /**
  59682. * Lines
  59683. */
  59684. LINES = 1,
  59685. /**
  59686. * Line Loop
  59687. */
  59688. LINE_LOOP = 2,
  59689. /**
  59690. * Line Strip
  59691. */
  59692. LINE_STRIP = 3,
  59693. /**
  59694. * Triangles
  59695. */
  59696. TRIANGLES = 4,
  59697. /**
  59698. * Triangle Strip
  59699. */
  59700. TRIANGLE_STRIP = 5,
  59701. /**
  59702. * Triangle Fan
  59703. */
  59704. TRIANGLE_FAN = 6,
  59705. }
  59706. /**
  59707. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  59708. */
  59709. const enum TextureMagFilter {
  59710. /**
  59711. * Nearest
  59712. */
  59713. NEAREST = 9728,
  59714. /**
  59715. * Linear
  59716. */
  59717. LINEAR = 9729,
  59718. }
  59719. /**
  59720. * Minification filter. All valid values correspond to WebGL enums
  59721. */
  59722. const enum TextureMinFilter {
  59723. /**
  59724. * Nearest
  59725. */
  59726. NEAREST = 9728,
  59727. /**
  59728. * Linear
  59729. */
  59730. LINEAR = 9729,
  59731. /**
  59732. * Nearest Mip-Map Nearest
  59733. */
  59734. NEAREST_MIPMAP_NEAREST = 9984,
  59735. /**
  59736. * Linear Mipmap Nearest
  59737. */
  59738. LINEAR_MIPMAP_NEAREST = 9985,
  59739. /**
  59740. * Nearest Mipmap Linear
  59741. */
  59742. NEAREST_MIPMAP_LINEAR = 9986,
  59743. /**
  59744. * Linear Mipmap Linear
  59745. */
  59746. LINEAR_MIPMAP_LINEAR = 9987,
  59747. }
  59748. /**
  59749. * S (U) wrapping mode. All valid values correspond to WebGL enums
  59750. */
  59751. const enum TextureWrapMode {
  59752. /**
  59753. * Clamp to Edge
  59754. */
  59755. CLAMP_TO_EDGE = 33071,
  59756. /**
  59757. * Mirrored Repeat
  59758. */
  59759. MIRRORED_REPEAT = 33648,
  59760. /**
  59761. * Repeat
  59762. */
  59763. REPEAT = 10497,
  59764. }
  59765. /**
  59766. * glTF Property
  59767. */
  59768. interface IProperty {
  59769. /**
  59770. * Dictionary object with extension-specific objects
  59771. */
  59772. extensions?: {
  59773. [key: string]: any;
  59774. };
  59775. /**
  59776. * Application-Specific data
  59777. */
  59778. extras?: any;
  59779. }
  59780. /**
  59781. * glTF Child of Root Property
  59782. */
  59783. interface IChildRootProperty extends IProperty {
  59784. /**
  59785. * The user-defined name of this object
  59786. */
  59787. name?: string;
  59788. }
  59789. /**
  59790. * Indices of those attributes that deviate from their initialization value
  59791. */
  59792. interface IAccessorSparseIndices extends IProperty {
  59793. /**
  59794. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  59795. */
  59796. bufferView: number;
  59797. /**
  59798. * The offset relative to the start of the bufferView in bytes. Must be aligned
  59799. */
  59800. byteOffset?: number;
  59801. /**
  59802. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  59803. */
  59804. componentType: AccessorComponentType;
  59805. }
  59806. /**
  59807. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  59808. */
  59809. interface IAccessorSparseValues extends IProperty {
  59810. /**
  59811. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  59812. */
  59813. bufferView: number;
  59814. /**
  59815. * The offset relative to the start of the bufferView in bytes. Must be aligned
  59816. */
  59817. byteOffset?: number;
  59818. }
  59819. /**
  59820. * Sparse storage of attributes that deviate from their initialization value
  59821. */
  59822. interface IAccessorSparse extends IProperty {
  59823. /**
  59824. * The number of attributes encoded in this sparse accessor
  59825. */
  59826. count: number;
  59827. /**
  59828. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  59829. */
  59830. indices: IAccessorSparseIndices;
  59831. /**
  59832. * 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
  59833. */
  59834. values: IAccessorSparseValues;
  59835. }
  59836. /**
  59837. * 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
  59838. */
  59839. interface IAccessor extends IChildRootProperty {
  59840. /**
  59841. * The index of the bufferview
  59842. */
  59843. bufferView?: number;
  59844. /**
  59845. * The offset relative to the start of the bufferView in bytes
  59846. */
  59847. byteOffset?: number;
  59848. /**
  59849. * The datatype of components in the attribute
  59850. */
  59851. componentType: AccessorComponentType;
  59852. /**
  59853. * Specifies whether integer data values should be normalized
  59854. */
  59855. normalized?: boolean;
  59856. /**
  59857. * The number of attributes referenced by this accessor
  59858. */
  59859. count: number;
  59860. /**
  59861. * Specifies if the attribute is a scalar, vector, or matrix
  59862. */
  59863. type: AccessorType;
  59864. /**
  59865. * Maximum value of each component in this attribute
  59866. */
  59867. max?: number[];
  59868. /**
  59869. * Minimum value of each component in this attribute
  59870. */
  59871. min?: number[];
  59872. /**
  59873. * Sparse storage of attributes that deviate from their initialization value
  59874. */
  59875. sparse?: IAccessorSparse;
  59876. }
  59877. /**
  59878. * Targets an animation's sampler at a node's property
  59879. */
  59880. interface IAnimationChannel extends IProperty {
  59881. /**
  59882. * The index of a sampler in this animation used to compute the value for the target
  59883. */
  59884. sampler: number;
  59885. /**
  59886. * The index of the node and TRS property to target
  59887. */
  59888. target: IAnimationChannelTarget;
  59889. }
  59890. /**
  59891. * The index of the node and TRS property that an animation channel targets
  59892. */
  59893. interface IAnimationChannelTarget extends IProperty {
  59894. /**
  59895. * The index of the node to target
  59896. */
  59897. node: number;
  59898. /**
  59899. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  59900. */
  59901. path: AnimationChannelTargetPath;
  59902. }
  59903. /**
  59904. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  59905. */
  59906. interface IAnimationSampler extends IProperty {
  59907. /**
  59908. * The index of an accessor containing keyframe input values, e.g., time
  59909. */
  59910. input: number;
  59911. /**
  59912. * Interpolation algorithm
  59913. */
  59914. interpolation?: AnimationSamplerInterpolation;
  59915. /**
  59916. * The index of an accessor, containing keyframe output values
  59917. */
  59918. output: number;
  59919. }
  59920. /**
  59921. * A keyframe animation
  59922. */
  59923. interface IAnimation extends IChildRootProperty {
  59924. /**
  59925. * An array of channels, each of which targets an animation's sampler at a node's property
  59926. */
  59927. channels: IAnimationChannel[];
  59928. /**
  59929. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  59930. */
  59931. samplers: IAnimationSampler[];
  59932. }
  59933. /**
  59934. * Metadata about the glTF asset
  59935. */
  59936. interface IAsset extends IChildRootProperty {
  59937. /**
  59938. * A copyright message suitable for display to credit the content creator
  59939. */
  59940. copyright?: string;
  59941. /**
  59942. * Tool that generated this glTF model. Useful for debugging
  59943. */
  59944. generator?: string;
  59945. /**
  59946. * The glTF version that this asset targets
  59947. */
  59948. version: string;
  59949. /**
  59950. * The minimum glTF version that this asset targets
  59951. */
  59952. minVersion?: string;
  59953. }
  59954. /**
  59955. * A buffer points to binary geometry, animation, or skins
  59956. */
  59957. interface IBuffer extends IChildRootProperty {
  59958. /**
  59959. * 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
  59960. */
  59961. uri?: string;
  59962. /**
  59963. * The length of the buffer in bytes
  59964. */
  59965. byteLength: number;
  59966. }
  59967. /**
  59968. * A view into a buffer generally representing a subset of the buffer
  59969. */
  59970. interface IBufferView extends IChildRootProperty {
  59971. /**
  59972. * The index of the buffer
  59973. */
  59974. buffer: number;
  59975. /**
  59976. * The offset into the buffer in bytes
  59977. */
  59978. byteOffset?: number;
  59979. /**
  59980. * The lenth of the bufferView in bytes
  59981. */
  59982. byteLength: number;
  59983. /**
  59984. * The stride, in bytes
  59985. */
  59986. byteStride?: number;
  59987. }
  59988. /**
  59989. * An orthographic camera containing properties to create an orthographic projection matrix
  59990. */
  59991. interface ICameraOrthographic extends IProperty {
  59992. /**
  59993. * The floating-point horizontal magnification of the view. Must not be zero
  59994. */
  59995. xmag: number;
  59996. /**
  59997. * The floating-point vertical magnification of the view. Must not be zero
  59998. */
  59999. ymag: number;
  60000. /**
  60001. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  60002. */
  60003. zfar: number;
  60004. /**
  60005. * The floating-point distance to the near clipping plane
  60006. */
  60007. znear: number;
  60008. }
  60009. /**
  60010. * A perspective camera containing properties to create a perspective projection matrix
  60011. */
  60012. interface ICameraPerspective extends IProperty {
  60013. /**
  60014. * The floating-point aspect ratio of the field of view
  60015. */
  60016. aspectRatio?: number;
  60017. /**
  60018. * The floating-point vertical field of view in radians
  60019. */
  60020. yfov: number;
  60021. /**
  60022. * The floating-point distance to the far clipping plane
  60023. */
  60024. zfar?: number;
  60025. /**
  60026. * The floating-point distance to the near clipping plane
  60027. */
  60028. znear: number;
  60029. }
  60030. /**
  60031. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  60032. */
  60033. interface ICamera extends IChildRootProperty {
  60034. /**
  60035. * An orthographic camera containing properties to create an orthographic projection matrix
  60036. */
  60037. orthographic?: ICameraOrthographic;
  60038. /**
  60039. * A perspective camera containing properties to create a perspective projection matrix
  60040. */
  60041. perspective?: ICameraPerspective;
  60042. /**
  60043. * Specifies if the camera uses a perspective or orthographic projection
  60044. */
  60045. type: CameraType;
  60046. }
  60047. /**
  60048. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  60049. */
  60050. interface IImage extends IChildRootProperty {
  60051. /**
  60052. * 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
  60053. */
  60054. uri?: string;
  60055. /**
  60056. * The image's MIME type
  60057. */
  60058. mimeType?: ImageMimeType;
  60059. /**
  60060. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  60061. */
  60062. bufferView?: number;
  60063. }
  60064. /**
  60065. * Material Normal Texture Info
  60066. */
  60067. interface IMaterialNormalTextureInfo extends ITextureInfo {
  60068. /**
  60069. * The scalar multiplier applied to each normal vector of the normal texture
  60070. */
  60071. scale?: number;
  60072. }
  60073. /**
  60074. * Material Occlusion Texture Info
  60075. */
  60076. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  60077. /**
  60078. * A scalar multiplier controlling the amount of occlusion applied
  60079. */
  60080. strength?: number;
  60081. }
  60082. /**
  60083. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  60084. */
  60085. interface IMaterialPbrMetallicRoughness {
  60086. /**
  60087. * The material's base color factor
  60088. */
  60089. baseColorFactor?: number[];
  60090. /**
  60091. * The base color texture
  60092. */
  60093. baseColorTexture?: ITextureInfo;
  60094. /**
  60095. * The metalness of the material
  60096. */
  60097. metallicFactor?: number;
  60098. /**
  60099. * The roughness of the material
  60100. */
  60101. roughnessFactor?: number;
  60102. /**
  60103. * The metallic-roughness texture
  60104. */
  60105. metallicRoughnessTexture?: ITextureInfo;
  60106. }
  60107. /**
  60108. * The material appearance of a primitive
  60109. */
  60110. interface IMaterial extends IChildRootProperty {
  60111. /**
  60112. * 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
  60113. */
  60114. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  60115. /**
  60116. * The normal map texture
  60117. */
  60118. normalTexture?: IMaterialNormalTextureInfo;
  60119. /**
  60120. * The occlusion map texture
  60121. */
  60122. occlusionTexture?: IMaterialOcclusionTextureInfo;
  60123. /**
  60124. * The emissive map texture
  60125. */
  60126. emissiveTexture?: ITextureInfo;
  60127. /**
  60128. * 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
  60129. */
  60130. emissiveFactor?: number[];
  60131. /**
  60132. * The alpha rendering mode of the material
  60133. */
  60134. alphaMode?: MaterialAlphaMode;
  60135. /**
  60136. * The alpha cutoff value of the material
  60137. */
  60138. alphaCutoff?: number;
  60139. /**
  60140. * Specifies whether the material is double sided
  60141. */
  60142. doubleSided?: boolean;
  60143. }
  60144. /**
  60145. * Geometry to be rendered with the given material
  60146. */
  60147. interface IMeshPrimitive extends IProperty {
  60148. /**
  60149. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  60150. */
  60151. attributes: {
  60152. [name: string]: number;
  60153. };
  60154. /**
  60155. * The index of the accessor that contains the indices
  60156. */
  60157. indices?: number;
  60158. /**
  60159. * The index of the material to apply to this primitive when rendering
  60160. */
  60161. material?: number;
  60162. /**
  60163. * The type of primitives to render. All valid values correspond to WebGL enums
  60164. */
  60165. mode?: MeshPrimitiveMode;
  60166. /**
  60167. * 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
  60168. */
  60169. targets?: {
  60170. [name: string]: number;
  60171. }[];
  60172. }
  60173. /**
  60174. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  60175. */
  60176. interface IMesh extends IChildRootProperty {
  60177. /**
  60178. * An array of primitives, each defining geometry to be rendered with a material
  60179. */
  60180. primitives: IMeshPrimitive[];
  60181. /**
  60182. * Array of weights to be applied to the Morph Targets
  60183. */
  60184. weights?: number[];
  60185. }
  60186. /**
  60187. * A node in the node hierarchy
  60188. */
  60189. interface INode extends IChildRootProperty {
  60190. /**
  60191. * The index of the camera referenced by this node
  60192. */
  60193. camera?: number;
  60194. /**
  60195. * The indices of this node's children
  60196. */
  60197. children?: number[];
  60198. /**
  60199. * The index of the skin referenced by this node
  60200. */
  60201. skin?: number;
  60202. /**
  60203. * A floating-point 4x4 transformation matrix stored in column-major order
  60204. */
  60205. matrix?: number[];
  60206. /**
  60207. * The index of the mesh in this node
  60208. */
  60209. mesh?: number;
  60210. /**
  60211. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  60212. */
  60213. rotation?: number[];
  60214. /**
  60215. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  60216. */
  60217. scale?: number[];
  60218. /**
  60219. * The node's translation along the x, y, and z axes
  60220. */
  60221. translation?: number[];
  60222. /**
  60223. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  60224. */
  60225. weights?: number[];
  60226. }
  60227. /**
  60228. * Texture sampler properties for filtering and wrapping modes
  60229. */
  60230. interface ISampler extends IChildRootProperty {
  60231. /**
  60232. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  60233. */
  60234. magFilter?: TextureMagFilter;
  60235. /**
  60236. * Minification filter. All valid values correspond to WebGL enums
  60237. */
  60238. minFilter?: TextureMinFilter;
  60239. /**
  60240. * S (U) wrapping mode. All valid values correspond to WebGL enums
  60241. */
  60242. wrapS?: TextureWrapMode;
  60243. /**
  60244. * T (V) wrapping mode. All valid values correspond to WebGL enums
  60245. */
  60246. wrapT?: TextureWrapMode;
  60247. }
  60248. /**
  60249. * The root nodes of a scene
  60250. */
  60251. interface IScene extends IChildRootProperty {
  60252. /**
  60253. * The indices of each root node
  60254. */
  60255. nodes: number[];
  60256. }
  60257. /**
  60258. * Joints and matrices defining a skin
  60259. */
  60260. interface ISkin extends IChildRootProperty {
  60261. /**
  60262. * 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
  60263. */
  60264. inverseBindMatrices?: number;
  60265. /**
  60266. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  60267. */
  60268. skeleton?: number;
  60269. /**
  60270. * 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)
  60271. */
  60272. joints: number[];
  60273. }
  60274. /**
  60275. * A texture and its sampler
  60276. */
  60277. interface ITexture extends IChildRootProperty {
  60278. /**
  60279. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  60280. */
  60281. sampler?: number;
  60282. /**
  60283. * The index of the image used by this texture
  60284. */
  60285. source: number;
  60286. }
  60287. /**
  60288. * Reference to a texture
  60289. */
  60290. interface ITextureInfo extends IProperty {
  60291. /**
  60292. * The index of the texture
  60293. */
  60294. index: number;
  60295. /**
  60296. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  60297. */
  60298. texCoord?: number;
  60299. }
  60300. /**
  60301. * The root object for a glTF asset
  60302. */
  60303. interface IGLTF extends IProperty {
  60304. /**
  60305. * An array of accessors. An accessor is a typed view into a bufferView
  60306. */
  60307. accessors?: IAccessor[];
  60308. /**
  60309. * An array of keyframe animations
  60310. */
  60311. animations?: IAnimation[];
  60312. /**
  60313. * Metadata about the glTF asset
  60314. */
  60315. asset: IAsset;
  60316. /**
  60317. * An array of buffers. A buffer points to binary geometry, animation, or skins
  60318. */
  60319. buffers?: IBuffer[];
  60320. /**
  60321. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  60322. */
  60323. bufferViews?: IBufferView[];
  60324. /**
  60325. * An array of cameras
  60326. */
  60327. cameras?: ICamera[];
  60328. /**
  60329. * Names of glTF extensions used somewhere in this asset
  60330. */
  60331. extensionsUsed?: string[];
  60332. /**
  60333. * Names of glTF extensions required to properly load this asset
  60334. */
  60335. extensionsRequired?: string[];
  60336. /**
  60337. * An array of images. An image defines data used to create a texture
  60338. */
  60339. images?: IImage[];
  60340. /**
  60341. * An array of materials. A material defines the appearance of a primitive
  60342. */
  60343. materials?: IMaterial[];
  60344. /**
  60345. * An array of meshes. A mesh is a set of primitives to be rendered
  60346. */
  60347. meshes?: IMesh[];
  60348. /**
  60349. * An array of nodes
  60350. */
  60351. nodes?: INode[];
  60352. /**
  60353. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  60354. */
  60355. samplers?: ISampler[];
  60356. /**
  60357. * The index of the default scene
  60358. */
  60359. scene?: number;
  60360. /**
  60361. * An array of scenes
  60362. */
  60363. scenes?: IScene[];
  60364. /**
  60365. * An array of skins. A skin is defined by joints and matrices
  60366. */
  60367. skins?: ISkin[];
  60368. /**
  60369. * An array of textures
  60370. */
  60371. textures?: ITexture[];
  60372. }
  60373. /**
  60374. * Interface for glTF validation results
  60375. */
  60376. interface IGLTFValidationResults {
  60377. info: {
  60378. generator: string;
  60379. hasAnimations: boolean;
  60380. hasDefaultScene: boolean;
  60381. hasMaterials: boolean;
  60382. hasMorphTargets: boolean;
  60383. hasSkins: boolean;
  60384. hasTextures: boolean;
  60385. maxAttributesUsed: number;
  60386. primitivesCount: number
  60387. };
  60388. issues: {
  60389. messages: Array<string>;
  60390. numErrors: number;
  60391. numHints: number;
  60392. numInfos: number;
  60393. numWarnings: number;
  60394. truncated: boolean
  60395. };
  60396. mimeType: string;
  60397. uri: string;
  60398. validatedAt: string;
  60399. validatorVersion: string;
  60400. }
  60401. /**
  60402. * Interface for glTF validation options
  60403. */
  60404. interface IGLTFValidationOptions {
  60405. uri?: string;
  60406. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  60407. validateAccessorData?: boolean;
  60408. maxIssues?: number;
  60409. ignoredIssues?: Array<string>;
  60410. severityOverrides?: Object;
  60411. }
  60412. /**
  60413. * glTF validator object Tyyings
  60414. */
  60415. interface IGLTFValidatorTypings {
  60416. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  60417. }
  60418. }
  60419. /**
  60420. * Interface for glTF validation results
  60421. */
  60422. interface IGLTFValidationResults {
  60423. info: {
  60424. generator: string;
  60425. hasAnimations: boolean;
  60426. hasDefaultScene: boolean;
  60427. hasMaterials: boolean;
  60428. hasMorphTargets: boolean;
  60429. hasSkins: boolean;
  60430. hasTextures: boolean;
  60431. maxAttributesUsed: number;
  60432. primitivesCount: number
  60433. };
  60434. issues: {
  60435. messages: Array<string>;
  60436. numErrors: number;
  60437. numHints: number;
  60438. numInfos: number;
  60439. numWarnings: number;
  60440. truncated: boolean
  60441. };
  60442. mimeType: string;
  60443. uri: string;
  60444. validatedAt: string;
  60445. validatorVersion: string;
  60446. }
  60447. /**
  60448. * Interface for glTF validation options
  60449. */
  60450. interface IGLTFValidationOptions {
  60451. uri?: string;
  60452. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  60453. validateAccessorData?: boolean;
  60454. maxIssues?: number;
  60455. ignoredIssues?: Array<string>;
  60456. severityOverrides?: Object;
  60457. }
  60458. /**
  60459. * glTF validator object Tyyings
  60460. */
  60461. interface IGLTFValidatorTypings {
  60462. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  60463. }
  60464. declare module BABYLON {
  60465. /** @hidden */
  60466. export var cellPixelShader: {
  60467. name: string;
  60468. shader: string;
  60469. };
  60470. }
  60471. declare module BABYLON {
  60472. /** @hidden */
  60473. export var cellVertexShader: {
  60474. name: string;
  60475. shader: string;
  60476. };
  60477. }
  60478. declare module BABYLON {
  60479. export class CellMaterial extends BABYLON.PushMaterial {
  60480. private _diffuseTexture;
  60481. diffuseTexture: BABYLON.BaseTexture;
  60482. diffuseColor: BABYLON.Color3; computeHighLevel: boolean;
  60483. computeHighLevel: boolean;
  60484. private _disableLighting;
  60485. disableLighting: boolean;
  60486. private _maxSimultaneousLights;
  60487. maxSimultaneousLights: number;
  60488. private _renderId;
  60489. constructor(name: string, scene: BABYLON.Scene);
  60490. needAlphaBlending(): boolean;
  60491. needAlphaTesting(): boolean;
  60492. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60493. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60494. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60495. getAnimatables(): BABYLON.IAnimatable[];
  60496. getActiveTextures(): BABYLON.BaseTexture[];
  60497. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60498. dispose(forceDisposeEffect?: boolean): void;
  60499. getClassName(): string;
  60500. clone(name: string): CellMaterial;
  60501. serialize(): any;
  60502. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  60503. }
  60504. }
  60505. declare module BABYLON {
  60506. export class CustomShaderStructure {
  60507. FragmentStore: string;
  60508. VertexStore: string;
  60509. constructor();
  60510. }
  60511. export class ShaderSpecialParts {
  60512. constructor();
  60513. Fragment_Begin: string;
  60514. Fragment_Definitions: string;
  60515. Fragment_MainBegin: string;
  60516. Fragment_Custom_Diffuse: string;
  60517. Fragment_Custom_Alpha: string;
  60518. Fragment_Before_FragColor: string;
  60519. Vertex_Begin: string;
  60520. Vertex_Definitions: string;
  60521. Vertex_MainBegin: string;
  60522. Vertex_Before_PositionUpdated: string;
  60523. Vertex_Before_NormalUpdated: string;
  60524. }
  60525. export class CustomMaterial extends BABYLON.StandardMaterial {
  60526. static ShaderIndexer: number;
  60527. CustomParts: ShaderSpecialParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  60528. FragmentShader: string;
  60529. VertexShader: string;
  60530. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  60531. ReviewUniform(name: string, arr: string[]): string[];
  60532. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  60533. constructor(name: string, scene: BABYLON.Scene);
  60534. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  60535. Fragment_Begin(shaderPart: string): CustomMaterial;
  60536. Fragment_Definitions(shaderPart: string): CustomMaterial;
  60537. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  60538. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  60539. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  60540. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  60541. Vertex_Begin(shaderPart: string): CustomMaterial;
  60542. Vertex_Definitions(shaderPart: string): CustomMaterial;
  60543. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  60544. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  60545. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  60546. }
  60547. }
  60548. declare module BABYLON {
  60549. /** @hidden */
  60550. export var firePixelShader: {
  60551. name: string;
  60552. shader: string;
  60553. };
  60554. }
  60555. declare module BABYLON {
  60556. /** @hidden */
  60557. export var fireVertexShader: {
  60558. name: string;
  60559. shader: string;
  60560. };
  60561. }
  60562. declare module BABYLON {
  60563. export class FireMaterial extends BABYLON.PushMaterial {
  60564. private _diffuseTexture;
  60565. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  60566. private _distortionTexture;
  60567. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  60568. private _opacityTexture;
  60569. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  60570. diffuseColor: BABYLON.Color3;
  60571. speed: number;
  60572. private _scaledDiffuse;
  60573. private _renderId;
  60574. private _lastTime;
  60575. constructor(name: string, scene: BABYLON.Scene);
  60576. needAlphaBlending(): boolean;
  60577. needAlphaTesting(): boolean;
  60578. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60579. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60580. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60581. getAnimatables(): BABYLON.IAnimatable[];
  60582. getActiveTextures(): BABYLON.BaseTexture[];
  60583. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60584. getClassName(): string;
  60585. dispose(forceDisposeEffect?: boolean): void;
  60586. clone(name: string): FireMaterial;
  60587. serialize(): any;
  60588. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  60589. }
  60590. }
  60591. declare module BABYLON {
  60592. /** @hidden */
  60593. export var furPixelShader: {
  60594. name: string;
  60595. shader: string;
  60596. };
  60597. }
  60598. declare module BABYLON {
  60599. /** @hidden */
  60600. export var furVertexShader: {
  60601. name: string;
  60602. shader: string;
  60603. };
  60604. }
  60605. declare module BABYLON {
  60606. export class FurMaterial extends BABYLON.PushMaterial {
  60607. private _diffuseTexture;
  60608. diffuseTexture: BABYLON.BaseTexture;
  60609. private _heightTexture;
  60610. heightTexture: BABYLON.BaseTexture;
  60611. diffuseColor: BABYLON.Color3;
  60612. furLength: number;
  60613. furAngle: number;
  60614. furColor: BABYLON.Color3;
  60615. furOffset: number;
  60616. furSpacing: number;
  60617. furGravity: BABYLON.Vector3;
  60618. furSpeed: number;
  60619. furDensity: number;
  60620. furOcclusion: number;
  60621. furTexture: BABYLON.DynamicTexture;
  60622. private _disableLighting;
  60623. disableLighting: boolean;
  60624. private _maxSimultaneousLights;
  60625. maxSimultaneousLights: number;
  60626. highLevelFur: boolean; meshes: BABYLON.AbstractMesh[];
  60627. private _renderId;
  60628. private _furTime;
  60629. constructor(name: string, scene: BABYLON.Scene);
  60630. furTime: number;
  60631. needAlphaBlending(): boolean;
  60632. needAlphaTesting(): boolean;
  60633. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60634. updateFur(): void;
  60635. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60636. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60637. getAnimatables(): BABYLON.IAnimatable[];
  60638. getActiveTextures(): BABYLON.BaseTexture[];
  60639. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60640. dispose(forceDisposeEffect?: boolean): void;
  60641. clone(name: string): FurMaterial;
  60642. serialize(): any;
  60643. getClassName(): string;
  60644. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  60645. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  60646. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  60647. }
  60648. }
  60649. declare module BABYLON {
  60650. /** @hidden */
  60651. export var gradientPixelShader: {
  60652. name: string;
  60653. shader: string;
  60654. };
  60655. }
  60656. declare module BABYLON {
  60657. /** @hidden */
  60658. export var gradientVertexShader: {
  60659. name: string;
  60660. shader: string;
  60661. };
  60662. }
  60663. declare module BABYLON {
  60664. export class GradientMaterial extends BABYLON.PushMaterial {
  60665. private _maxSimultaneousLights;
  60666. maxSimultaneousLights: number;
  60667. topColor: BABYLON.Color3;
  60668. topColorAlpha: number;
  60669. bottomColor: BABYLON.Color3;
  60670. bottomColorAlpha: number;
  60671. offset: number;
  60672. scale: number;
  60673. smoothness: number;
  60674. private _disableLighting;
  60675. disableLighting: boolean;
  60676. private _renderId;
  60677. constructor(name: string, scene: BABYLON.Scene);
  60678. needAlphaBlending(): boolean;
  60679. needAlphaTesting(): boolean;
  60680. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60681. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60682. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60683. getAnimatables(): BABYLON.IAnimatable[];
  60684. dispose(forceDisposeEffect?: boolean): void;
  60685. clone(name: string): GradientMaterial;
  60686. serialize(): any;
  60687. getClassName(): string;
  60688. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  60689. }
  60690. }
  60691. declare module BABYLON {
  60692. /** @hidden */
  60693. export var gridPixelShader: {
  60694. name: string;
  60695. shader: string;
  60696. };
  60697. }
  60698. declare module BABYLON {
  60699. /** @hidden */
  60700. export var gridVertexShader: {
  60701. name: string;
  60702. shader: string;
  60703. };
  60704. }
  60705. declare module BABYLON {
  60706. /**
  60707. * The grid materials allows you to wrap any shape with a grid.
  60708. * Colors are customizable.
  60709. */
  60710. export class GridMaterial extends BABYLON.PushMaterial {
  60711. /**
  60712. * Main color of the grid (e.g. between lines)
  60713. */
  60714. mainColor: BABYLON.Color3;
  60715. /**
  60716. * Color of the grid lines.
  60717. */
  60718. lineColor: BABYLON.Color3;
  60719. /**
  60720. * The scale of the grid compared to unit.
  60721. */
  60722. gridRatio: number;
  60723. /**
  60724. * Allows setting an offset for the grid lines.
  60725. */
  60726. gridOffset: BABYLON.Vector3;
  60727. /**
  60728. * The frequency of thicker lines.
  60729. */
  60730. majorUnitFrequency: number;
  60731. /**
  60732. * The visibility of minor units in the grid.
  60733. */
  60734. minorUnitVisibility: number;
  60735. /**
  60736. * The grid opacity outside of the lines.
  60737. */
  60738. opacity: number;
  60739. /**
  60740. * Determine RBG output is premultiplied by alpha value.
  60741. */
  60742. preMultiplyAlpha: boolean;
  60743. private _opacityTexture;
  60744. opacityTexture: BABYLON.BaseTexture;
  60745. private _gridControl;
  60746. private _renderId;
  60747. /**
  60748. * constructor
  60749. * @param name The name given to the material in order to identify it afterwards.
  60750. * @param scene The scene the material is used in.
  60751. */
  60752. constructor(name: string, scene: BABYLON.Scene);
  60753. /**
  60754. * Returns wehter or not the grid requires alpha blending.
  60755. */
  60756. needAlphaBlending(): boolean;
  60757. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  60758. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60759. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60760. /**
  60761. * Dispose the material and its associated resources.
  60762. * @param forceDisposeEffect will also dispose the used effect when true
  60763. */
  60764. dispose(forceDisposeEffect?: boolean): void;
  60765. clone(name: string): GridMaterial;
  60766. serialize(): any;
  60767. getClassName(): string;
  60768. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  60769. }
  60770. }
  60771. declare module BABYLON {
  60772. /** @hidden */
  60773. export var lavaPixelShader: {
  60774. name: string;
  60775. shader: string;
  60776. };
  60777. }
  60778. declare module BABYLON {
  60779. /** @hidden */
  60780. export var lavaVertexShader: {
  60781. name: string;
  60782. shader: string;
  60783. };
  60784. }
  60785. declare module BABYLON {
  60786. export class LavaMaterial extends BABYLON.PushMaterial {
  60787. private _diffuseTexture;
  60788. diffuseTexture: BABYLON.BaseTexture;
  60789. noiseTexture: BABYLON.BaseTexture;
  60790. fogColor: BABYLON.Color3;
  60791. speed: number;
  60792. movingSpeed: number;
  60793. lowFrequencySpeed: number;
  60794. fogDensity: number;
  60795. private _lastTime;
  60796. diffuseColor: BABYLON.Color3;
  60797. private _disableLighting;
  60798. disableLighting: boolean;
  60799. private _unlit;
  60800. unlit: boolean;
  60801. private _maxSimultaneousLights;
  60802. maxSimultaneousLights: number;
  60803. private _scaledDiffuse;
  60804. private _renderId;
  60805. constructor(name: string, scene: BABYLON.Scene);
  60806. needAlphaBlending(): boolean;
  60807. needAlphaTesting(): boolean;
  60808. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60809. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60810. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60811. getAnimatables(): BABYLON.IAnimatable[];
  60812. getActiveTextures(): BABYLON.BaseTexture[];
  60813. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60814. dispose(forceDisposeEffect?: boolean): void;
  60815. clone(name: string): LavaMaterial;
  60816. serialize(): any;
  60817. getClassName(): string;
  60818. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  60819. }
  60820. }
  60821. declare module BABYLON {
  60822. /** @hidden */
  60823. export var mixPixelShader: {
  60824. name: string;
  60825. shader: string;
  60826. };
  60827. }
  60828. declare module BABYLON {
  60829. /** @hidden */
  60830. export var mixVertexShader: {
  60831. name: string;
  60832. shader: string;
  60833. };
  60834. }
  60835. declare module BABYLON {
  60836. export class MixMaterial extends BABYLON.PushMaterial {
  60837. /**
  60838. * Mix textures
  60839. */
  60840. private _mixTexture1;
  60841. mixTexture1: BABYLON.BaseTexture;
  60842. private _mixTexture2;
  60843. mixTexture2: BABYLON.BaseTexture;
  60844. /**
  60845. * Diffuse textures
  60846. */
  60847. private _diffuseTexture1;
  60848. diffuseTexture1: BABYLON.Texture;
  60849. private _diffuseTexture2;
  60850. diffuseTexture2: BABYLON.Texture;
  60851. private _diffuseTexture3;
  60852. diffuseTexture3: BABYLON.Texture;
  60853. private _diffuseTexture4;
  60854. diffuseTexture4: BABYLON.Texture;
  60855. private _diffuseTexture5;
  60856. diffuseTexture5: BABYLON.Texture;
  60857. private _diffuseTexture6;
  60858. diffuseTexture6: BABYLON.Texture;
  60859. private _diffuseTexture7;
  60860. diffuseTexture7: BABYLON.Texture;
  60861. private _diffuseTexture8;
  60862. diffuseTexture8: BABYLON.Texture;
  60863. /**
  60864. * Uniforms
  60865. */
  60866. diffuseColor: BABYLON.Color3;
  60867. specularColor: BABYLON.Color3;
  60868. specularPower: number;
  60869. private _disableLighting;
  60870. disableLighting: boolean;
  60871. private _maxSimultaneousLights;
  60872. maxSimultaneousLights: number;
  60873. private _renderId;
  60874. constructor(name: string, scene: BABYLON.Scene);
  60875. needAlphaBlending(): boolean;
  60876. needAlphaTesting(): boolean;
  60877. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60878. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60879. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60880. getAnimatables(): BABYLON.IAnimatable[];
  60881. getActiveTextures(): BABYLON.BaseTexture[];
  60882. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60883. dispose(forceDisposeEffect?: boolean): void;
  60884. clone(name: string): MixMaterial;
  60885. serialize(): any;
  60886. getClassName(): string;
  60887. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  60888. }
  60889. }
  60890. declare module BABYLON {
  60891. /** @hidden */
  60892. export var normalPixelShader: {
  60893. name: string;
  60894. shader: string;
  60895. };
  60896. }
  60897. declare module BABYLON {
  60898. /** @hidden */
  60899. export var normalVertexShader: {
  60900. name: string;
  60901. shader: string;
  60902. };
  60903. }
  60904. declare module BABYLON {
  60905. export class NormalMaterial extends BABYLON.PushMaterial {
  60906. private _diffuseTexture;
  60907. diffuseTexture: BABYLON.BaseTexture;
  60908. diffuseColor: BABYLON.Color3;
  60909. private _disableLighting;
  60910. disableLighting: boolean;
  60911. private _maxSimultaneousLights;
  60912. maxSimultaneousLights: number;
  60913. private _renderId;
  60914. constructor(name: string, scene: BABYLON.Scene);
  60915. needAlphaBlending(): boolean;
  60916. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  60917. needAlphaTesting(): boolean;
  60918. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60919. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60920. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60921. getAnimatables(): BABYLON.IAnimatable[];
  60922. getActiveTextures(): BABYLON.BaseTexture[];
  60923. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60924. dispose(forceDisposeEffect?: boolean): void;
  60925. clone(name: string): NormalMaterial;
  60926. serialize(): any;
  60927. getClassName(): string;
  60928. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  60929. }
  60930. }
  60931. declare module BABYLON {
  60932. /** @hidden */
  60933. export var shadowOnlyPixelShader: {
  60934. name: string;
  60935. shader: string;
  60936. };
  60937. }
  60938. declare module BABYLON {
  60939. /** @hidden */
  60940. export var shadowOnlyVertexShader: {
  60941. name: string;
  60942. shader: string;
  60943. };
  60944. }
  60945. declare module BABYLON {
  60946. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  60947. private _renderId;
  60948. private _activeLight;
  60949. constructor(name: string, scene: BABYLON.Scene);
  60950. shadowColor: BABYLON.Color3;
  60951. needAlphaBlending(): boolean;
  60952. needAlphaTesting(): boolean;
  60953. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60954. activeLight: BABYLON.IShadowLight;
  60955. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60956. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60957. clone(name: string): ShadowOnlyMaterial;
  60958. serialize(): any;
  60959. getClassName(): string;
  60960. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  60961. }
  60962. }
  60963. declare module BABYLON {
  60964. /** @hidden */
  60965. export var simplePixelShader: {
  60966. name: string;
  60967. shader: string;
  60968. };
  60969. }
  60970. declare module BABYLON {
  60971. /** @hidden */
  60972. export var simpleVertexShader: {
  60973. name: string;
  60974. shader: string;
  60975. };
  60976. }
  60977. declare module BABYLON {
  60978. export class SimpleMaterial extends BABYLON.PushMaterial {
  60979. private _diffuseTexture;
  60980. diffuseTexture: BABYLON.BaseTexture;
  60981. diffuseColor: BABYLON.Color3;
  60982. private _disableLighting;
  60983. disableLighting: boolean;
  60984. private _maxSimultaneousLights;
  60985. maxSimultaneousLights: number;
  60986. private _renderId;
  60987. constructor(name: string, scene: BABYLON.Scene);
  60988. needAlphaBlending(): boolean;
  60989. needAlphaTesting(): boolean;
  60990. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60991. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60992. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60993. getAnimatables(): BABYLON.IAnimatable[];
  60994. getActiveTextures(): BABYLON.BaseTexture[];
  60995. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60996. dispose(forceDisposeEffect?: boolean): void;
  60997. clone(name: string): SimpleMaterial;
  60998. serialize(): any;
  60999. getClassName(): string;
  61000. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  61001. }
  61002. }
  61003. declare module BABYLON {
  61004. /** @hidden */
  61005. export var skyPixelShader: {
  61006. name: string;
  61007. shader: string;
  61008. };
  61009. }
  61010. declare module BABYLON {
  61011. /** @hidden */
  61012. export var skyVertexShader: {
  61013. name: string;
  61014. shader: string;
  61015. };
  61016. }
  61017. declare module BABYLON {
  61018. /**
  61019. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  61020. * @see https://doc.babylonjs.com/extensions/sky
  61021. */
  61022. export class SkyMaterial extends BABYLON.PushMaterial {
  61023. /**
  61024. * Defines the overall luminance of sky in interval ]0, 1[.
  61025. */
  61026. luminance: number;
  61027. /**
  61028. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  61029. */
  61030. turbidity: number;
  61031. /**
  61032. * Defines the sky appearance (light intensity).
  61033. */
  61034. rayleigh: number;
  61035. /**
  61036. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  61037. */
  61038. mieCoefficient: number;
  61039. /**
  61040. * Defines the amount of haze particles following the Mie scattering theory.
  61041. */
  61042. mieDirectionalG: number;
  61043. /**
  61044. * Defines the distance of the sun according to the active scene camera.
  61045. */
  61046. distance: number;
  61047. /**
  61048. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  61049. * "inclined".
  61050. */
  61051. inclination: number;
  61052. /**
  61053. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  61054. * an object direction and a reference direction.
  61055. */
  61056. azimuth: number;
  61057. /**
  61058. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  61059. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  61060. */
  61061. sunPosition: BABYLON.Vector3;
  61062. /**
  61063. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  61064. * .sunPosition property.
  61065. */
  61066. useSunPosition: boolean;
  61067. /**
  61068. * Defines an offset vector used to get a horizon offset.
  61069. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  61070. */
  61071. cameraOffset: BABYLON.Vector3;
  61072. private _cameraPosition;
  61073. private _renderId;
  61074. /**
  61075. * Instantiates a new sky material.
  61076. * This material allows to create dynamic and texture free
  61077. * effects for skyboxes by taking care of the atmosphere state.
  61078. * @see https://doc.babylonjs.com/extensions/sky
  61079. * @param name Define the name of the material in the scene
  61080. * @param scene Define the scene the material belong to
  61081. */
  61082. constructor(name: string, scene: BABYLON.Scene);
  61083. /**
  61084. * Specifies if the material will require alpha blending
  61085. * @returns a boolean specifying if alpha blending is needed
  61086. */
  61087. needAlphaBlending(): boolean;
  61088. /**
  61089. * Specifies if this material should be rendered in alpha test mode
  61090. * @returns false as the sky material doesn't need alpha testing.
  61091. */
  61092. needAlphaTesting(): boolean;
  61093. /**
  61094. * Get the texture used for alpha test purpose.
  61095. * @returns null as the sky material has no texture.
  61096. */
  61097. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  61098. /**
  61099. * Get if the submesh is ready to be used and all its information available.
  61100. * Child classes can use it to update shaders
  61101. * @param mesh defines the mesh to check
  61102. * @param subMesh defines which submesh to check
  61103. * @param useInstances specifies that instances should be used
  61104. * @returns a boolean indicating that the submesh is ready or not
  61105. */
  61106. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  61107. /**
  61108. * Binds the submesh to this material by preparing the effect and shader to draw
  61109. * @param world defines the world transformation matrix
  61110. * @param mesh defines the mesh containing the submesh
  61111. * @param subMesh defines the submesh to bind the material to
  61112. */
  61113. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  61114. /**
  61115. * Get the list of animatables in the material.
  61116. * @returns the list of animatables object used in the material
  61117. */
  61118. getAnimatables(): BABYLON.IAnimatable[];
  61119. /**
  61120. * Disposes the material
  61121. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  61122. */
  61123. dispose(forceDisposeEffect?: boolean): void;
  61124. /**
  61125. * Makes a duplicate of the material, and gives it a new name
  61126. * @param name defines the new name for the duplicated material
  61127. * @returns the cloned material
  61128. */
  61129. clone(name: string): SkyMaterial;
  61130. /**
  61131. * Serializes this material in a JSON representation
  61132. * @returns the serialized material object
  61133. */
  61134. serialize(): any;
  61135. /**
  61136. * Gets the current class name of the material e.g. "SkyMaterial"
  61137. * Mainly use in serialization.
  61138. * @returns the class name
  61139. */
  61140. getClassName(): string;
  61141. /**
  61142. * Creates a sky material from parsed material data
  61143. * @param source defines the JSON representation of the material
  61144. * @param scene defines the hosting scene
  61145. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61146. * @returns a new sky material
  61147. */
  61148. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  61149. }
  61150. }
  61151. declare module BABYLON {
  61152. /** @hidden */
  61153. export var terrainPixelShader: {
  61154. name: string;
  61155. shader: string;
  61156. };
  61157. }
  61158. declare module BABYLON {
  61159. /** @hidden */
  61160. export var terrainVertexShader: {
  61161. name: string;
  61162. shader: string;
  61163. };
  61164. }
  61165. declare module BABYLON {
  61166. export class TerrainMaterial extends BABYLON.PushMaterial {
  61167. private _mixTexture;
  61168. mixTexture: BABYLON.BaseTexture;
  61169. private _diffuseTexture1;
  61170. diffuseTexture1: BABYLON.Texture;
  61171. private _diffuseTexture2;
  61172. diffuseTexture2: BABYLON.Texture;
  61173. private _diffuseTexture3;
  61174. diffuseTexture3: BABYLON.Texture;
  61175. private _bumpTexture1;
  61176. bumpTexture1: BABYLON.Texture;
  61177. private _bumpTexture2;
  61178. bumpTexture2: BABYLON.Texture;
  61179. private _bumpTexture3;
  61180. bumpTexture3: BABYLON.Texture;
  61181. diffuseColor: BABYLON.Color3;
  61182. specularColor: BABYLON.Color3;
  61183. specularPower: number;
  61184. private _disableLighting;
  61185. disableLighting: boolean;
  61186. private _maxSimultaneousLights;
  61187. maxSimultaneousLights: number;
  61188. private _renderId;
  61189. constructor(name: string, scene: BABYLON.Scene);
  61190. needAlphaBlending(): boolean;
  61191. needAlphaTesting(): boolean;
  61192. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  61193. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  61194. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  61195. getAnimatables(): BABYLON.IAnimatable[];
  61196. getActiveTextures(): BABYLON.BaseTexture[];
  61197. hasTexture(texture: BABYLON.BaseTexture): boolean;
  61198. dispose(forceDisposeEffect?: boolean): void;
  61199. clone(name: string): TerrainMaterial;
  61200. serialize(): any;
  61201. getClassName(): string;
  61202. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  61203. }
  61204. }
  61205. declare module BABYLON {
  61206. /** @hidden */
  61207. export var triplanarPixelShader: {
  61208. name: string;
  61209. shader: string;
  61210. };
  61211. }
  61212. declare module BABYLON {
  61213. /** @hidden */
  61214. export var triplanarVertexShader: {
  61215. name: string;
  61216. shader: string;
  61217. };
  61218. }
  61219. declare module BABYLON {
  61220. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  61221. mixTexture: BABYLON.BaseTexture;
  61222. private _diffuseTextureX;
  61223. diffuseTextureX: BABYLON.BaseTexture;
  61224. private _diffuseTextureY;
  61225. diffuseTextureY: BABYLON.BaseTexture;
  61226. private _diffuseTextureZ;
  61227. diffuseTextureZ: BABYLON.BaseTexture;
  61228. private _normalTextureX;
  61229. normalTextureX: BABYLON.BaseTexture;
  61230. private _normalTextureY;
  61231. normalTextureY: BABYLON.BaseTexture;
  61232. private _normalTextureZ;
  61233. normalTextureZ: BABYLON.BaseTexture;
  61234. tileSize: number;
  61235. diffuseColor: BABYLON.Color3;
  61236. specularColor: BABYLON.Color3;
  61237. specularPower: number;
  61238. private _disableLighting;
  61239. disableLighting: boolean;
  61240. private _maxSimultaneousLights;
  61241. maxSimultaneousLights: number;
  61242. private _renderId;
  61243. constructor(name: string, scene: BABYLON.Scene);
  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. getAnimatables(): BABYLON.IAnimatable[];
  61250. getActiveTextures(): BABYLON.BaseTexture[];
  61251. hasTexture(texture: BABYLON.BaseTexture): boolean;
  61252. dispose(forceDisposeEffect?: boolean): void;
  61253. clone(name: string): TriPlanarMaterial;
  61254. serialize(): any;
  61255. getClassName(): string;
  61256. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  61257. }
  61258. }
  61259. declare module BABYLON {
  61260. /** @hidden */
  61261. export var waterPixelShader: {
  61262. name: string;
  61263. shader: string;
  61264. };
  61265. }
  61266. declare module BABYLON {
  61267. /** @hidden */
  61268. export var waterVertexShader: {
  61269. name: string;
  61270. shader: string;
  61271. };
  61272. }
  61273. declare module BABYLON {
  61274. export class WaterMaterial extends BABYLON.PushMaterial {
  61275. renderTargetSize: BABYLON.Vector2;
  61276. private _bumpTexture;
  61277. bumpTexture: BABYLON.BaseTexture;
  61278. diffuseColor: BABYLON.Color3;
  61279. specularColor: BABYLON.Color3;
  61280. specularPower: number;
  61281. private _disableLighting;
  61282. disableLighting: boolean;
  61283. private _maxSimultaneousLights;
  61284. maxSimultaneousLights: number;
  61285. /**
  61286. * @param {number}: Represents the wind force
  61287. */
  61288. windForce: number;
  61289. /**
  61290. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  61291. */
  61292. windDirection: BABYLON.Vector2;
  61293. /**
  61294. * @param {number}: Wave height, represents the height of the waves
  61295. */
  61296. waveHeight: number;
  61297. /**
  61298. * @param {number}: Bump height, represents the bump height related to the bump map
  61299. */
  61300. bumpHeight: number;
  61301. /**
  61302. * @param {boolean}: Add a smaller moving bump to less steady waves.
  61303. */
  61304. private _bumpSuperimpose;
  61305. bumpSuperimpose: boolean;
  61306. /**
  61307. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  61308. */
  61309. private _fresnelSeparate;
  61310. fresnelSeparate: boolean;
  61311. /**
  61312. * @param {boolean}: bump Waves modify the reflection.
  61313. */
  61314. private _bumpAffectsReflection;
  61315. bumpAffectsReflection: boolean;
  61316. /**
  61317. * @param {number}: The water color blended with the refraction (near)
  61318. */
  61319. waterColor: BABYLON.Color3;
  61320. /**
  61321. * @param {number}: The blend factor related to the water color
  61322. */
  61323. colorBlendFactor: number;
  61324. /**
  61325. * @param {number}: The water color blended with the reflection (far)
  61326. */
  61327. waterColor2: BABYLON.Color3;
  61328. /**
  61329. * @param {number}: The blend factor related to the water color (reflection, far)
  61330. */
  61331. colorBlendFactor2: number;
  61332. /**
  61333. * @param {number}: Represents the maximum length of a wave
  61334. */
  61335. waveLength: number;
  61336. /**
  61337. * @param {number}: Defines the waves speed
  61338. */
  61339. waveSpeed: number;
  61340. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  61341. private _mesh;
  61342. private _refractionRTT;
  61343. private _reflectionRTT;
  61344. private _reflectionTransform;
  61345. private _lastTime;
  61346. private _lastDeltaTime;
  61347. private _renderId;
  61348. private _useLogarithmicDepth;
  61349. private _waitingRenderList;
  61350. /**
  61351. * Gets a boolean indicating that current material needs to register RTT
  61352. */
  61353. readonly hasRenderTargetTextures: boolean;
  61354. /**
  61355. * Constructor
  61356. */
  61357. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  61358. useLogarithmicDepth: boolean;
  61359. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  61360. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  61361. addToRenderList(node: any): void;
  61362. enableRenderTargets(enable: boolean): void;
  61363. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  61364. readonly renderTargetsEnabled: boolean;
  61365. needAlphaBlending(): boolean;
  61366. needAlphaTesting(): boolean;
  61367. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  61368. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  61369. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  61370. private _createRenderTargets;
  61371. getAnimatables(): BABYLON.IAnimatable[];
  61372. getActiveTextures(): BABYLON.BaseTexture[];
  61373. hasTexture(texture: BABYLON.BaseTexture): boolean;
  61374. dispose(forceDisposeEffect?: boolean): void;
  61375. clone(name: string): WaterMaterial;
  61376. serialize(): any;
  61377. getClassName(): string;
  61378. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  61379. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  61380. }
  61381. }
  61382. declare module BABYLON {
  61383. /** @hidden */
  61384. export var asciiartPixelShader: {
  61385. name: string;
  61386. shader: string;
  61387. };
  61388. }
  61389. declare module BABYLON {
  61390. /**
  61391. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  61392. *
  61393. * It basically takes care rendering the font front the given font size to a texture.
  61394. * This is used later on in the postprocess.
  61395. */
  61396. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  61397. private _font;
  61398. private _text;
  61399. private _charSize;
  61400. /**
  61401. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  61402. */
  61403. readonly charSize: number;
  61404. /**
  61405. * Create a new instance of the Ascii Art FontTexture class
  61406. * @param name the name of the texture
  61407. * @param font the font to use, use the W3C CSS notation
  61408. * @param text the caracter set to use in the rendering.
  61409. * @param scene the scene that owns the texture
  61410. */
  61411. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  61412. /**
  61413. * Gets the max char width of a font.
  61414. * @param font the font to use, use the W3C CSS notation
  61415. * @return the max char width
  61416. */
  61417. private getFontWidth;
  61418. /**
  61419. * Gets the max char height of a font.
  61420. * @param font the font to use, use the W3C CSS notation
  61421. * @return the max char height
  61422. */
  61423. private getFontHeight;
  61424. /**
  61425. * Clones the current AsciiArtTexture.
  61426. * @return the clone of the texture.
  61427. */
  61428. clone(): AsciiArtFontTexture;
  61429. /**
  61430. * Parses a json object representing the texture and returns an instance of it.
  61431. * @param source the source JSON representation
  61432. * @param scene the scene to create the texture for
  61433. * @return the parsed texture
  61434. */
  61435. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  61436. }
  61437. /**
  61438. * Option available in the Ascii Art Post Process.
  61439. */
  61440. export interface IAsciiArtPostProcessOptions {
  61441. /**
  61442. * The font to use following the w3c font definition.
  61443. */
  61444. font?: string;
  61445. /**
  61446. * The character set to use in the postprocess.
  61447. */
  61448. characterSet?: string;
  61449. /**
  61450. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  61451. * This number is defined between 0 and 1;
  61452. */
  61453. mixToTile?: number;
  61454. /**
  61455. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  61456. * This number is defined between 0 and 1;
  61457. */
  61458. mixToNormal?: number;
  61459. }
  61460. /**
  61461. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  61462. *
  61463. * Simmply add it to your scene and let the nerd that lives in you have fun.
  61464. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  61465. */
  61466. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  61467. /**
  61468. * The font texture used to render the char in the post process.
  61469. */
  61470. private _asciiArtFontTexture;
  61471. /**
  61472. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  61473. * This number is defined between 0 and 1;
  61474. */
  61475. mixToTile: number;
  61476. /**
  61477. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  61478. * This number is defined between 0 and 1;
  61479. */
  61480. mixToNormal: number;
  61481. /**
  61482. * Instantiates a new Ascii Art Post Process.
  61483. * @param name the name to give to the postprocess
  61484. * @camera the camera to apply the post process to.
  61485. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  61486. */
  61487. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  61488. }
  61489. }
  61490. declare module BABYLON {
  61491. /** @hidden */
  61492. export var digitalrainPixelShader: {
  61493. name: string;
  61494. shader: string;
  61495. };
  61496. }
  61497. declare module BABYLON {
  61498. /**
  61499. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  61500. *
  61501. * It basically takes care rendering the font front the given font size to a texture.
  61502. * This is used later on in the postprocess.
  61503. */
  61504. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  61505. private _font;
  61506. private _text;
  61507. private _charSize;
  61508. /**
  61509. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  61510. */
  61511. readonly charSize: number;
  61512. /**
  61513. * Create a new instance of the Digital Rain FontTexture class
  61514. * @param name the name of the texture
  61515. * @param font the font to use, use the W3C CSS notation
  61516. * @param text the caracter set to use in the rendering.
  61517. * @param scene the scene that owns the texture
  61518. */
  61519. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  61520. /**
  61521. * Gets the max char width of a font.
  61522. * @param font the font to use, use the W3C CSS notation
  61523. * @return the max char width
  61524. */
  61525. private getFontWidth;
  61526. /**
  61527. * Gets the max char height of a font.
  61528. * @param font the font to use, use the W3C CSS notation
  61529. * @return the max char height
  61530. */
  61531. private getFontHeight;
  61532. /**
  61533. * Clones the current DigitalRainFontTexture.
  61534. * @return the clone of the texture.
  61535. */
  61536. clone(): DigitalRainFontTexture;
  61537. /**
  61538. * Parses a json object representing the texture and returns an instance of it.
  61539. * @param source the source JSON representation
  61540. * @param scene the scene to create the texture for
  61541. * @return the parsed texture
  61542. */
  61543. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  61544. }
  61545. /**
  61546. * Option available in the Digital Rain Post Process.
  61547. */
  61548. export interface IDigitalRainPostProcessOptions {
  61549. /**
  61550. * The font to use following the w3c font definition.
  61551. */
  61552. font?: string;
  61553. /**
  61554. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  61555. * This number is defined between 0 and 1;
  61556. */
  61557. mixToTile?: number;
  61558. /**
  61559. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  61560. * This number is defined between 0 and 1;
  61561. */
  61562. mixToNormal?: number;
  61563. }
  61564. /**
  61565. * DigitalRainPostProcess helps rendering everithing in digital rain.
  61566. *
  61567. * Simmply add it to your scene and let the nerd that lives in you have fun.
  61568. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  61569. */
  61570. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  61571. /**
  61572. * The font texture used to render the char in the post process.
  61573. */
  61574. private _digitalRainFontTexture;
  61575. /**
  61576. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  61577. * This number is defined between 0 and 1;
  61578. */
  61579. mixToTile: number;
  61580. /**
  61581. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  61582. * This number is defined between 0 and 1;
  61583. */
  61584. mixToNormal: number;
  61585. /**
  61586. * Instantiates a new Digital Rain Post Process.
  61587. * @param name the name to give to the postprocess
  61588. * @camera the camera to apply the post process to.
  61589. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  61590. */
  61591. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  61592. }
  61593. }
  61594. declare module BABYLON {
  61595. /** @hidden */
  61596. export var brickProceduralTexturePixelShader: {
  61597. name: string;
  61598. shader: string;
  61599. };
  61600. }
  61601. declare module BABYLON {
  61602. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  61603. private _numberOfBricksHeight;
  61604. private _numberOfBricksWidth;
  61605. private _jointColor;
  61606. private _brickColor;
  61607. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61608. updateShaderUniforms(): void;
  61609. numberOfBricksHeight: number;
  61610. numberOfBricksWidth: number;
  61611. jointColor: BABYLON.Color3;
  61612. brickColor: BABYLON.Color3;
  61613. /**
  61614. * Serializes this brick procedural texture
  61615. * @returns a serialized brick procedural texture object
  61616. */
  61617. serialize(): any;
  61618. /**
  61619. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  61620. * @param parsedTexture defines parsed texture data
  61621. * @param scene defines the current scene
  61622. * @param rootUrl defines the root URL containing brick procedural texture information
  61623. * @returns a parsed Brick Procedural BABYLON.Texture
  61624. */
  61625. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  61626. }
  61627. }
  61628. declare module BABYLON {
  61629. /** @hidden */
  61630. export var cloudProceduralTexturePixelShader: {
  61631. name: string;
  61632. shader: string;
  61633. };
  61634. }
  61635. declare module BABYLON {
  61636. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  61637. private _skyColor;
  61638. private _cloudColor;
  61639. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61640. updateShaderUniforms(): void;
  61641. skyColor: BABYLON.Color4;
  61642. cloudColor: BABYLON.Color4;
  61643. /**
  61644. * Serializes this cloud procedural texture
  61645. * @returns a serialized cloud procedural texture object
  61646. */
  61647. serialize(): any;
  61648. /**
  61649. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  61650. * @param parsedTexture defines parsed texture data
  61651. * @param scene defines the current scene
  61652. * @param rootUrl defines the root URL containing cloud procedural texture information
  61653. * @returns a parsed Cloud Procedural BABYLON.Texture
  61654. */
  61655. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  61656. }
  61657. }
  61658. declare module BABYLON {
  61659. /** @hidden */
  61660. export var fireProceduralTexturePixelShader: {
  61661. name: string;
  61662. shader: string;
  61663. };
  61664. }
  61665. declare module BABYLON {
  61666. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  61667. private _time;
  61668. private _speed;
  61669. private _autoGenerateTime;
  61670. private _fireColors;
  61671. private _alphaThreshold;
  61672. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61673. updateShaderUniforms(): void;
  61674. render(useCameraPostProcess?: boolean): void;
  61675. static readonly PurpleFireColors: BABYLON.Color3[];
  61676. static readonly GreenFireColors: BABYLON.Color3[];
  61677. static readonly RedFireColors: BABYLON.Color3[];
  61678. static readonly BlueFireColors: BABYLON.Color3[];
  61679. autoGenerateTime: boolean;
  61680. fireColors: BABYLON.Color3[];
  61681. time: number;
  61682. speed: BABYLON.Vector2;
  61683. alphaThreshold: number;
  61684. /**
  61685. * Serializes this fire procedural texture
  61686. * @returns a serialized fire procedural texture object
  61687. */
  61688. serialize(): any;
  61689. /**
  61690. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  61691. * @param parsedTexture defines parsed texture data
  61692. * @param scene defines the current scene
  61693. * @param rootUrl defines the root URL containing fire procedural texture information
  61694. * @returns a parsed Fire Procedural BABYLON.Texture
  61695. */
  61696. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  61697. }
  61698. }
  61699. declare module BABYLON {
  61700. /** @hidden */
  61701. export var grassProceduralTexturePixelShader: {
  61702. name: string;
  61703. shader: string;
  61704. };
  61705. }
  61706. declare module BABYLON {
  61707. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  61708. private _grassColors;
  61709. private _groundColor;
  61710. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61711. updateShaderUniforms(): void;
  61712. grassColors: BABYLON.Color3[];
  61713. groundColor: BABYLON.Color3;
  61714. /**
  61715. * Serializes this grass procedural texture
  61716. * @returns a serialized grass procedural texture object
  61717. */
  61718. serialize(): any;
  61719. /**
  61720. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  61721. * @param parsedTexture defines parsed texture data
  61722. * @param scene defines the current scene
  61723. * @param rootUrl defines the root URL containing grass procedural texture information
  61724. * @returns a parsed Grass Procedural BABYLON.Texture
  61725. */
  61726. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  61727. }
  61728. }
  61729. declare module BABYLON {
  61730. /** @hidden */
  61731. export var marbleProceduralTexturePixelShader: {
  61732. name: string;
  61733. shader: string;
  61734. };
  61735. }
  61736. declare module BABYLON {
  61737. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  61738. private _numberOfTilesHeight;
  61739. private _numberOfTilesWidth;
  61740. private _amplitude;
  61741. private _jointColor;
  61742. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61743. updateShaderUniforms(): void;
  61744. numberOfTilesHeight: number;
  61745. amplitude: number;
  61746. numberOfTilesWidth: number;
  61747. jointColor: BABYLON.Color3;
  61748. /**
  61749. * Serializes this marble procedural texture
  61750. * @returns a serialized marble procedural texture object
  61751. */
  61752. serialize(): any;
  61753. /**
  61754. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  61755. * @param parsedTexture defines parsed texture data
  61756. * @param scene defines the current scene
  61757. * @param rootUrl defines the root URL containing marble procedural texture information
  61758. * @returns a parsed Marble Procedural BABYLON.Texture
  61759. */
  61760. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  61761. }
  61762. }
  61763. declare module BABYLON {
  61764. /** @hidden */
  61765. export var normalMapProceduralTexturePixelShader: {
  61766. name: string;
  61767. shader: string;
  61768. };
  61769. }
  61770. declare module BABYLON {
  61771. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  61772. private _baseTexture;
  61773. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61774. updateShaderUniforms(): void;
  61775. render(useCameraPostProcess?: boolean): void;
  61776. resize(size: any, generateMipMaps: any): void;
  61777. baseTexture: BABYLON.Texture;
  61778. /**
  61779. * Serializes this normal map procedural texture
  61780. * @returns a serialized normal map procedural texture object
  61781. */
  61782. serialize(): any;
  61783. /**
  61784. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  61785. * @param parsedTexture defines parsed texture data
  61786. * @param scene defines the current scene
  61787. * @param rootUrl defines the root URL containing normal map procedural texture information
  61788. * @returns a parsed Normal Map Procedural BABYLON.Texture
  61789. */
  61790. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  61791. }
  61792. }
  61793. declare module BABYLON {
  61794. /** @hidden */
  61795. export var perlinNoiseProceduralTexturePixelShader: {
  61796. name: string;
  61797. shader: string;
  61798. };
  61799. }
  61800. declare module BABYLON {
  61801. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  61802. time: number;
  61803. timeScale: number;
  61804. translationSpeed: number;
  61805. private _currentTranslation;
  61806. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61807. updateShaderUniforms(): void;
  61808. render(useCameraPostProcess?: boolean): void;
  61809. resize(size: any, generateMipMaps: any): void;
  61810. /**
  61811. * Serializes this perlin noise procedural texture
  61812. * @returns a serialized perlin noise procedural texture object
  61813. */
  61814. serialize(): any;
  61815. /**
  61816. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  61817. * @param parsedTexture defines parsed texture data
  61818. * @param scene defines the current scene
  61819. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  61820. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  61821. */
  61822. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  61823. }
  61824. }
  61825. declare module BABYLON {
  61826. /** @hidden */
  61827. export var roadProceduralTexturePixelShader: {
  61828. name: string;
  61829. shader: string;
  61830. };
  61831. }
  61832. declare module BABYLON {
  61833. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  61834. private _roadColor;
  61835. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61836. updateShaderUniforms(): void;
  61837. roadColor: BABYLON.Color3;
  61838. /**
  61839. * Serializes this road procedural texture
  61840. * @returns a serialized road procedural texture object
  61841. */
  61842. serialize(): any;
  61843. /**
  61844. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  61845. * @param parsedTexture defines parsed texture data
  61846. * @param scene defines the current scene
  61847. * @param rootUrl defines the root URL containing road procedural texture information
  61848. * @returns a parsed Road Procedural BABYLON.Texture
  61849. */
  61850. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  61851. }
  61852. }
  61853. declare module BABYLON {
  61854. /** @hidden */
  61855. export var starfieldProceduralTexturePixelShader: {
  61856. name: string;
  61857. shader: string;
  61858. };
  61859. }
  61860. declare module BABYLON {
  61861. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  61862. private _time;
  61863. private _alpha;
  61864. private _beta;
  61865. private _zoom;
  61866. private _formuparam;
  61867. private _stepsize;
  61868. private _tile;
  61869. private _brightness;
  61870. private _darkmatter;
  61871. private _distfading;
  61872. private _saturation;
  61873. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61874. updateShaderUniforms(): void;
  61875. time: number;
  61876. alpha: number;
  61877. beta: number;
  61878. formuparam: number;
  61879. stepsize: number;
  61880. zoom: number;
  61881. tile: number;
  61882. brightness: number;
  61883. darkmatter: number;
  61884. distfading: number;
  61885. saturation: number;
  61886. /**
  61887. * Serializes this starfield procedural texture
  61888. * @returns a serialized starfield procedural texture object
  61889. */
  61890. serialize(): any;
  61891. /**
  61892. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  61893. * @param parsedTexture defines parsed texture data
  61894. * @param scene defines the current scene
  61895. * @param rootUrl defines the root URL containing startfield procedural texture information
  61896. * @returns a parsed Starfield Procedural BABYLON.Texture
  61897. */
  61898. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  61899. }
  61900. }
  61901. declare module BABYLON {
  61902. /** @hidden */
  61903. export var woodProceduralTexturePixelShader: {
  61904. name: string;
  61905. shader: string;
  61906. };
  61907. }
  61908. declare module BABYLON {
  61909. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  61910. private _ampScale;
  61911. private _woodColor;
  61912. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61913. updateShaderUniforms(): void;
  61914. ampScale: number;
  61915. woodColor: BABYLON.Color3;
  61916. /**
  61917. * Serializes this wood procedural texture
  61918. * @returns a serialized wood procedural texture object
  61919. */
  61920. serialize(): any;
  61921. /**
  61922. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  61923. * @param parsedTexture defines parsed texture data
  61924. * @param scene defines the current scene
  61925. * @param rootUrl defines the root URL containing wood procedural texture information
  61926. * @returns a parsed Wood Procedural BABYLON.Texture
  61927. */
  61928. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  61929. }
  61930. }